diff options
author | Andrea Ornstein <andrea.ornstein@st.com> | 2009-07-09 10:25:05 +0000 |
---|---|---|
committer | Andrea Ornstein <andrea.ornstein@st.com> | 2009-07-09 10:25:05 +0000 |
commit | 9d3ebf6a6e92adf432c1a2cbc2ee57d1c218a3db (patch) | |
tree | f8e29d68b5c4aeb2d5f62923b9de4880094f44ee | |
parent | 3bdcb6938ca1bbef8c694c2789bce6362f155cca (diff) |
use .def files to define CIL instruction (enum, argument type, ...)
methods cil_prefix_unaligned, cil_prefix_volatile and cil_prefix_tail can now be used on every CIL IR node
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/st/cli-be@149412 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/config/cil32/cil-stmt.c | 139 | ||||
-rw-r--r-- | gcc/config/cil32/cil-types.h | 129 |
2 files changed, 49 insertions, 219 deletions
diff --git a/gcc/config/cil32/cil-stmt.c b/gcc/config/cil32/cil-stmt.c index a5db27cb647..de59b2d8850 100644 --- a/gcc/config/cil32/cil-stmt.c +++ b/gcc/config/cil32/cil-stmt.c @@ -49,6 +49,16 @@ Erven Rohou <erven.rohou@inria.fr> often so it's better to keep the fred ones around. */ static GTY ((deletable)) struct cil_seq_d *cil_seq_cache = NULL; + +/* Returns the type of argument of the opcode specified by the OPCODE + argument. */ + +enum cil_arg_type opcode_arg_types[] = { +#define CIL_INSTRDEF(A,B,C,D) B, +#include "cil-instr.def" +#undef CIL_INSTRDEF +}; + /****************************************************************************** * Local function prototypes * ******************************************************************************/ @@ -145,8 +155,7 @@ cil_build_call_generic (enum cil_opcode opcode, tree type_or_decl) tree arg_types; size_t i; - gcc_assert (opcode == CIL_CALL || opcode == CIL_CALLI || - opcode == CIL_JMP || opcode == CIL_NEWOBJ); + gcc_assert (opcode_arg_type (opcode) == CIL_FCALL); if (opcode != CIL_CALLI) { @@ -251,10 +260,7 @@ cil_call_nargs_base (const_cil_stmt stmt) { tree arg_types; - gcc_assert (stmt->opcode == CIL_CALL - || stmt->opcode == CIL_CALLI - || stmt->opcode == CIL_JMP - || stmt->opcode == CIL_NEWOBJ); + gcc_assert (opcode_arg_type (stmt->opcode) == CIL_FCALL); arg_types = TYPE_ARG_TYPES (stmt->arg.fcall->ftype); @@ -314,7 +320,7 @@ cil_copy_stmt (const_cil_stmt stmt) new_stmt = GGC_NEW (struct cil_stmt_d); memcpy (new_stmt, stmt, sizeof (struct cil_stmt_d)); - if (stmt->opcode == CIL_SWITCH) + if (opcode_arg_type (stmt->opcode) == CIL_LABELS) { cil_switch_arg arg = GGC_NEW (struct cil_switch_arg_d); unsigned int ncases = stmt->arg.labels->ncases; @@ -324,9 +330,7 @@ cil_copy_stmt (const_cil_stmt stmt) memcpy (arg->cases, stmt->arg.labels->cases, sizeof (tree) * ncases); new_stmt->arg.labels = arg; } - else if (stmt->opcode == CIL_CALL - || stmt->opcode == CIL_CALLI - || stmt->opcode == CIL_JMP) + else if (opcode_arg_type (stmt->opcode) == CIL_FCALL) { cil_call_arg arg = GGC_NEW (struct cil_call_arg_d); unsigned int nargs = stmt->arg.fcall->nargs; @@ -349,9 +353,8 @@ cil_copy_stmt (const_cil_stmt stmt) bool cil_prefix_tail (const_cil_stmt stmt) { - gcc_assert ((stmt->opcode == CIL_CALL) || (stmt->opcode == CIL_CALLI)); - - return stmt->prefix_tail; + return (((stmt->opcode == CIL_CALL) || (stmt->opcode == CIL_CALLI)) + && stmt->prefix_tail); } /* Sets the tail. prefix to STATUS in the CIL statment pointed by STMT. */ @@ -371,14 +374,17 @@ cil_set_prefix_tail (cil_stmt stmt, bool status) int cil_prefix_unaligned (const_cil_stmt stmt) { - gcc_assert ((stmt->opcode == CIL_CPBLK) || (stmt->opcode == CIL_INITBLK) - || (stmt->opcode == CIL_LDOBJ) || (stmt->opcode == CIL_STOBJ) - || (stmt->opcode == CIL_LDVEC) || (stmt->opcode == CIL_STVEC) - || ((stmt->opcode >= CIL_LDIND_I1) && (stmt->opcode <= CIL_LDIND_I)) - || ((stmt->opcode >= CIL_STIND_I1) && (stmt->opcode <= CIL_STIND_I)) - || (stmt->opcode == CIL_LDFLD) || (stmt->opcode == CIL_STFLD)); - - return stmt->prefix_unaligned ? stmt->alignment : 0; + int result = 0; + if (((stmt->opcode == CIL_CPBLK) || (stmt->opcode == CIL_INITBLK) + || (stmt->opcode == CIL_LDOBJ) || (stmt->opcode == CIL_STOBJ) + || (stmt->opcode == CIL_LDVEC) || (stmt->opcode == CIL_STVEC) + || ((stmt->opcode >= CIL_LDIND_I1) && (stmt->opcode <= CIL_LDIND_I)) + || ((stmt->opcode >= CIL_STIND_I1) && (stmt->opcode <= CIL_STIND_I)) + || (stmt->opcode == CIL_LDFLD) || (stmt->opcode == CIL_STFLD)) + && stmt->prefix_unaligned) + result = stmt->alignment; + + return result; } /* Sets the unaligned. prefix in the CIL statement pointed by STMT. The actual @@ -421,90 +427,15 @@ cil_set_prefix_volatile (cil_stmt stmt, bool status) bool cil_prefix_volatile (const_cil_stmt stmt) { - gcc_assert ((stmt->opcode == CIL_CPBLK) || (stmt->opcode == CIL_INITBLK) - || (stmt->opcode == CIL_LDOBJ) || (stmt->opcode == CIL_STOBJ) - || (stmt->opcode == CIL_LDVEC) || (stmt->opcode == CIL_STVEC) - || ((stmt->opcode >= CIL_LDIND_I1) && (stmt->opcode <= CIL_LDIND_I)) - || ((stmt->opcode >= CIL_STIND_I1) && (stmt->opcode <= CIL_STIND_I)) - || (stmt->opcode == CIL_LDFLD) || (stmt->opcode == CIL_STFLD) - || (stmt->opcode == CIL_LDSFLD) || (stmt->opcode == CIL_STSFLD)); - - return stmt->prefix_volatile; + return (((stmt->opcode == CIL_CPBLK) || (stmt->opcode == CIL_INITBLK) + || (stmt->opcode == CIL_LDOBJ) || (stmt->opcode == CIL_STOBJ) + || (stmt->opcode == CIL_LDVEC) || (stmt->opcode == CIL_STVEC) + || ((stmt->opcode >= CIL_LDIND_I1) && (stmt->opcode <= CIL_LDIND_I)) + || ((stmt->opcode >= CIL_STIND_I1) && (stmt->opcode <= CIL_STIND_I)) + || (stmt->opcode == CIL_LDFLD) || (stmt->opcode == CIL_STFLD) + || (stmt->opcode == CIL_LDSFLD) || (stmt->opcode == CIL_STSFLD)) + && stmt->prefix_volatile); } - -/* Returns the type of argument of the opcode specified by the OPCODE - argument. */ - -enum cil_arg_type -opcode_arg_type (enum cil_opcode opcode) -{ - switch (opcode) - { - case CIL_LDARG: - case CIL_LDARGA: - case CIL_LDLOC: - case CIL_LDLOCA: - case CIL_STARG: - case CIL_STLOC: - return CIL_VAR; - - case CIL_INITOBJ: - case CIL_LDOBJ: - case CIL_STOBJ: - /* vector types */ - case CIL_VEC_CTOR: - case CIL_LDVEC: - case CIL_STVEC: - return CIL_TYPE; - - case CIL_LDFLD: - case CIL_LDFLDA: - case CIL_LDSFLD: - case CIL_LDSFLDA: - case CIL_STFLD: - case CIL_STSFLD: - return CIL_FIELD; - - case CIL_BEQ: - case CIL_BGE: - case CIL_BGE_UN: - case CIL_BGT: - case CIL_BGT_UN: - case CIL_BLE: - case CIL_BLE_UN: - case CIL_BLT: - case CIL_BLT_UN: - case CIL_BNE_UN: - case CIL_BR: - case CIL_BRFALSE: - case CIL_BRTRUE: - return CIL_LABEL; - - case CIL_SWITCH: - return CIL_LABELS; - - case CIL_LDFTN: - return CIL_FUNC; - - case CIL_CALL: - case CIL_CALLI: - case CIL_JMP: - return CIL_FCALL; - - case CIL_LDC_I4: - case CIL_LDC_I8: - case CIL_LDC_R4: - case CIL_LDC_R8: - return CIL_CST; - - case CIL_ASM: - return CIL_STRING; - - default: - return CIL_NONE; - } -} - /* Returns TRUE if the CIL stsatement STMT represents a conversion, FALSE otherwise. */ diff --git a/gcc/config/cil32/cil-types.h b/gcc/config/cil32/cil-types.h index f36a6a497f0..6db6eeefb49 100644 --- a/gcc/config/cil32/cil-types.h +++ b/gcc/config/cil32/cil-types.h @@ -77,129 +77,28 @@ typedef const struct label_addr_d *const_label_addr; enum cil_opcode { - CIL_ADD, /* Add numeric values */ - CIL_AND, /* Logical and */ - CIL_ARGLIST, /* Get argument list */ - CIL_BEQ, /* Branch on equal */ - CIL_BGE, /* Branch on greater or equal */ - CIL_BGE_UN, /* Branch on greater or equal, unsigned or unordered */ - CIL_BGT, /* Branch on greater than */ - CIL_BGT_UN, /* Branch on greater than, unsigned or unordered */ - CIL_BLE, /* Branch on less or equal */ - CIL_BLE_UN, /* Branch on less or equal, unsigned or unordered */ - CIL_BLT, /* Branch on less than */ - CIL_BLT_UN, /* Branch on less than, unsigned or unordered */ - CIL_BNE_UN, /* Branch on not equal, unsigned or unordered */ - CIL_BR, /* Branch unconditional */ - CIL_BREAK, /* Breakpoint instruction */ - CIL_BRFALSE, /* Branch on false, null or zero */ - CIL_BRTRUE, /* Branch on non-false, non-null, or non-zero */ - CIL_CALL, /* Method call */ - CIL_CALLI, /* Indirect method call */ - CIL_CEQ, /* Compare equal */ - CIL_CGT, /* Compare greater than */ - CIL_CGT_UN, /* Compare greater than, unsigned or unordered */ - CIL_CKFINITE, /* Check for a finite real number */ - CIL_CLT, /* Compare less than */ - CIL_CLT_UN, /* Compare less than unordered */ - CIL_CONV_I1, /* Convert to int8 */ - CIL_CONV_I2, /* Convert to int16 */ - CIL_CONV_I4, /* Convert to int32 */ - CIL_CONV_I8, /* Convert to int64 */ - CIL_CONV_R4, /* Convert to float32 */ - CIL_CONV_R8, /* Convert to float64 */ - CIL_CONV_U1, /* Convert to unsigned int8 */ - CIL_CONV_U2, /* Convert to unsigned int16 */ - CIL_CONV_U4, /* Convert to unsigned int32 */ - CIL_CONV_U8, /* Convert to unsigned int64 */ - CIL_CONV_I, /* Convert to native int */ - CIL_CONV_U, /* Convert to unsigned native int */ - CIL_CONV_R_UN, /* Convert unsigned integer to floating-point */ - CIL_CPBLK, /* Copy data from memory to memory */ - CIL_DIV, /* Divide values */ - CIL_DIV_UN, /* Divide values, unsigned */ - CIL_DUP, /* Duplicate the value on top of the stack */ - CIL_INITBLK, /* Set all bytes in a block of memory to a given byte value */ - CIL_INITOBJ, /* Initialize the value at an address */ - CIL_JMP, /* Jump to method */ - CIL_LDARG, /* Load an argument on the operand stack */ - CIL_LDARGA, /* Load an argument's address */ - CIL_LDC_I4, /* Load an int32 numeric constant on the stack */ - CIL_LDC_I8, /* Load an int64 numeric constant on the stack */ - CIL_LDC_R4, /* Load a float32 numeric constant on the stack */ - CIL_LDC_R8, /* Load a float64 numeric constant on the stack */ - CIL_LDFLD, /* Load field of an object */ - CIL_LDFLDA, /* Load field address */ - CIL_LDFTN, /* Load method pointer */ - CIL_LDIND_I1, /* Indirect load value of type int8 */ - CIL_LDIND_I2, /* Indirect load value of type int16 */ - CIL_LDIND_I4, /* Indirect load value of type int32 */ - CIL_LDIND_I8, /* Indirect load value of type int64 */ - CIL_LDIND_U1, /* Indirect load value of type unsigned int8 */ - CIL_LDIND_U2, /* Indirect load value of type unsigned int16 */ - CIL_LDIND_U4, /* Indirect load value of type unsigned int32 */ - CIL_LDIND_U8, /* Indirect load value of type unsigned int64 */ - CIL_LDIND_R4, /* Indirect load value of type float32 */ - CIL_LDIND_R8, /* Indirect load value of type float64 */ - CIL_LDIND_I, /* Indirect load value of type native int */ - CIL_LDLOC, /* Load local variable onto the stack */ - CIL_LDLOCA, /* Load local variable address */ - CIL_LDOBJ, /* Copy a value from an address to the stack */ - CIL_LDSFLD, /* Load static field of a class */ - CIL_LDSFLDA, /* Load static field address */ - CIL_LDVEC, /* Copy a vector value from an address to the stack */ - CIL_LOCALLOC, /* Allocate space from the local memory pool */ - CIL_MUL, /* Multiply values */ - CIL_NEG, /* Negate value */ - CIL_NEWOBJ, /* Negate value */ - CIL_NOT, /* Bitwise complement */ - CIL_OR, /* Bitwise or */ - CIL_POP, /* Remove the top element of the stack */ - CIL_REM, /* Compute remainder */ - CIL_REM_UN, /* Compute integer remainder, unsigned */ - CIL_RET, /* Return from method */ - CIL_SHL, /* Shift integer left */ - CIL_SHR, /* Shift integer right */ - CIL_SHR_UN, /* Shift integer right, unsigned */ - CIL_STARG, /* Store a value in an argument slot */ - CIL_STFLD, /* Store field of an object */ - CIL_STIND_I1, /* Store int8 value indirect from stack */ - CIL_STIND_I2, /* Store int16 value indirect from stack */ - CIL_STIND_I4, /* Store int32 value indirect from stack */ - CIL_STIND_I8, /* Store int64 value indirect from stack */ - CIL_STIND_R4, /* Store float32 value indirect from stack */ - CIL_STIND_R8, /* Store float64 value indirect from stack */ - CIL_STIND_I, /* Store native int value indirect from stack */ - CIL_STLOC, /* Pop value from stack to local variable */ - CIL_STOBJ, /* Store a value at an address */ - CIL_STVEC, /* Store a vector value at an address */ - CIL_STSFLD, /* Store static field of a class */ - CIL_SUB, /* Substract numeric value */ - CIL_SWITCH, /* Table switch based on value */ - CIL_VEC_CTOR, /* New vector */ - CIL_XOR, /* Bitwise exclusive or */ - - /* Artificial opcodes */ - CIL_ASM /* Artificial opcode representing ASM_EXPR statements */ +#define CIL_INSTRDEF(A,B,C,D) A, +#include "cil-instr.def" +#undef CIL_INSTRDEF +CIL_NUM_INSTRS }; /* CIL statement argument type, used by the garbage collector. */ enum cil_arg_type { - CIL_VAR, /* Variable declaration */ - CIL_TYPE, /* Type declaration */ - CIL_FIELD, /* Field declaration */ - CIL_LABEL, /* Label declaration */ - CIL_LABELS, /* Switch case labels */ - CIL_FUNC, /* Function declaration */ - CIL_FCALL, /* Function call description */ - CIL_CST, /* Integer or real constant */ - CIL_STRING, /* A string (held in a tree, not a char *) */ - CIL_NONE /* No argument */ +#define CIL_ARGTYPE(A) A, +#include "cil-argdef.def" +#undef CIL_ARGTYPE +CIL_NUM_ARGTYPE }; -extern enum cil_arg_type opcode_arg_type (enum cil_opcode); +extern enum cil_arg_type opcode_arg_types[]; + +static inline enum cil_arg_type opcode_arg_type (enum cil_opcode cil_opcode) +{ + return opcode_arg_types[cil_opcode]; +} /* Represents the information provided by a CALL_EXPR when converted to a CIL CALL or CALLI instruction. The FTYPE fields points to the called function |