diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 002d19c4b7c..4b2aee5ab33 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2009-09-11 Richard Henderson + + * gsstruct.def (DEFGSSTRUCT): Remove printable-name argument; add + structure-name and has-tree-operands arguments; update all entries. + * gimple.def (DEFGSCODE): Replace 3rd argument with GSS_symbol; + update all entries. + * gimple.c (gimple_ops_offset_): Use HAS_TREE_OP argument. + (gsstruct_code_size): New. + (gss_for_code_): New. + (gss_for_code): Remove. + (gimple_size): Rewrite using gsstruct_code_size. + (gimple_statement_structure): Move to gimple.h. + * gimple.h (gimple_ops_offset_, gss_for_code_): Declare. + (gss_for_code, gimple_statement_structure): New. + (gimple_ops): Use new arrays; tidy. + 2009-09-11 John David Anglin * config/pa/predicates.md (symbolic_operand): Require a CONST symbolic diff --git a/gcc/gimple.c b/gcc/gimple.c index 9223aaa8824..3be6d843fe2 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -35,18 +35,32 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "demangle.h" -#define DEFGSCODE(SYM, NAME, STRUCT) NAME, + +/* All the tuples have their operand vector (if present) at the very bottom + of the structure. Therefore, the offset required to find the + operands vector the size of the structure minus the size of the 1 + element tree array at the end (see gimple_ops). */ +#define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) \ + (HAS_TREE_OP ? sizeof (struct STRUCT) - sizeof (tree) : 0), +EXPORTED_CONST size_t gimple_ops_offset_[] = { +#include "gsstruct.def" +}; +#undef DEFGSSTRUCT + +#define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) sizeof(struct STRUCT), +static const size_t gsstruct_code_size[] = { +#include "gsstruct.def" +}; +#undef DEFGSSTRUCT + +#define DEFGSCODE(SYM, NAME, GSSCODE) NAME, const char *const gimple_code_name[] = { #include "gimple.def" }; #undef DEFGSCODE -/* All the tuples have their operand vector at the very bottom - of the structure. Therefore, the offset required to find the - operands vector the size of the structure minus the size of the 1 - element tree array at the end (see gimple_ops). */ -#define DEFGSCODE(SYM, NAME, STRUCT) (sizeof (STRUCT) - sizeof (tree)), -EXPORTED_CONST size_t gimple_ops_offset_[] = { +#define DEFGSCODE(SYM, NAME, GSSCODE) GSSCODE, +EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = { #include "gimple.def" }; #undef DEFGSCODE @@ -89,118 +103,15 @@ gimple_set_code (gimple g, enum gimple_code code) g->gsbase.code = code; } - -/* Return the GSS_* identifier for the given GIMPLE statement CODE. */ - -static enum gimple_statement_structure_enum -gss_for_code (enum gimple_code code) -{ - switch (code) - { - case GIMPLE_ASSIGN: - case GIMPLE_CALL: - case GIMPLE_RETURN: return GSS_WITH_MEM_OPS; - case GIMPLE_COND: - case GIMPLE_GOTO: - case GIMPLE_LABEL: - case GIMPLE_DEBUG: - case GIMPLE_SWITCH: return GSS_WITH_OPS; - case GIMPLE_ASM: return GSS_ASM; - case GIMPLE_BIND: return GSS_BIND; - case GIMPLE_CATCH: return GSS_CATCH; - case GIMPLE_EH_FILTER: return GSS_EH_FILTER; - case GIMPLE_NOP: return GSS_BASE; - case GIMPLE_PHI: return GSS_PHI; - case GIMPLE_RESX: return GSS_RESX; - case GIMPLE_TRY: return GSS_TRY; - case GIMPLE_WITH_CLEANUP_EXPR: return GSS_WCE; - case GIMPLE_OMP_CRITICAL: return GSS_OMP_CRITICAL; - case GIMPLE_OMP_FOR: return GSS_OMP_FOR; - case GIMPLE_OMP_MASTER: - case GIMPLE_OMP_ORDERED: - case GIMPLE_OMP_SECTION: return GSS_OMP; - case GIMPLE_OMP_RETURN: - case GIMPLE_OMP_SECTIONS_SWITCH: return GSS_BASE; - case GIMPLE_OMP_CONTINUE: return GSS_OMP_CONTINUE; - case GIMPLE_OMP_PARALLEL: return GSS_OMP_PARALLEL; - case GIMPLE_OMP_TASK: return GSS_OMP_TASK; - case GIMPLE_OMP_SECTIONS: return GSS_OMP_SECTIONS; - case GIMPLE_OMP_SINGLE: return GSS_OMP_SINGLE; - case GIMPLE_OMP_ATOMIC_LOAD: return GSS_OMP_ATOMIC_LOAD; - case GIMPLE_OMP_ATOMIC_STORE: return GSS_OMP_ATOMIC_STORE; - case GIMPLE_PREDICT: return GSS_BASE; - default: gcc_unreachable (); - } -} - - /* Return the number of bytes needed to hold a GIMPLE statement with code CODE. */ -static size_t +static inline size_t gimple_size (enum gimple_code code) { - enum gimple_statement_structure_enum gss = gss_for_code (code); - - if (gss == GSS_WITH_OPS) - return sizeof (struct gimple_statement_with_ops); - else if (gss == GSS_WITH_MEM_OPS) - return sizeof (struct gimple_statement_with_memory_ops); - - switch (code) - { - case GIMPLE_ASM: - return sizeof (struct gimple_statement_asm); - case GIMPLE_NOP: - return sizeof (struct gimple_statement_base); - case GIMPLE_BIND: - return sizeof (struct gimple_statement_bind); - case GIMPLE_CATCH: - return sizeof (struct gimple_statement_catch); - case GIMPLE_EH_FILTER: - return sizeof (struct gimple_statement_eh_filter); - case GIMPLE_TRY: - return sizeof (struct gimple_statement_try); - case GIMPLE_RESX: - return sizeof (struct gimple_statement_resx); - case GIMPLE_OMP_CRITICAL: - return sizeof (struct gimple_statement_omp_critical); - case GIMPLE_OMP_FOR: - return sizeof (struct gimple_statement_omp_for); - case GIMPLE_OMP_PARALLEL: - return sizeof (struct gimple_statement_omp_parallel); - case GIMPLE_OMP_TASK: - return sizeof (struct gimple_statement_omp_task); - case GIMPLE_OMP_SECTION: - case GIMPLE_OMP_MASTER: - case GIMPLE_OMP_ORDERED: - return sizeof (struct gimple_statement_omp); - case GIMPLE_OMP_RETURN: - return sizeof (struct gimple_statement_base); - case GIMPLE_OMP_CONTINUE: - return sizeof (struct gimple_statement_omp_continue); - case GIMPLE_OMP_SECTIONS: - return sizeof (struct gimple_statement_omp_sections); - case GIMPLE_OMP_SECTIONS_SWITCH: - return sizeof (struct gimple_statement_base); - case GIMPLE_OMP_SINGLE: - return sizeof (struct gimple_statement_omp_single); - case GIMPLE_OMP_ATOMIC_LOAD: - return sizeof (struct gimple_statement_omp_atomic_load); - case GIMPLE_OMP_ATOMIC_STORE: - return sizeof (struct gimple_statement_omp_atomic_store); - case GIMPLE_WITH_CLEANUP_EXPR: - return sizeof (struct gimple_statement_wce); - case GIMPLE_PREDICT: - return sizeof (struct gimple_statement_base); - default: - break; - } - - gcc_unreachable (); + return gsstruct_code_size[gss_for_code (code)]; } - /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS operands. */ @@ -1103,15 +1014,6 @@ gimple_build_predict (enum br_predictor predictor, enum prediction outcome) return p; } -/* Return which gimple structure is used by T. The enums here are defined - in gsstruct.def. */ - -enum gimple_statement_structure_enum -gimple_statement_structure (gimple gs) -{ - return gss_for_code (gimple_code (gs)); -} - #if defined ENABLE_GIMPLE_CHECKING /* Complain of a gimple type mismatch and die. */ diff --git a/gcc/gimple.def b/gcc/gimple.def index 716f6e2acbb..1a3f345e106 100644 --- a/gcc/gimple.def +++ b/gcc/gimple.def @@ -20,19 +20,11 @@ along with GCC; see the file COPYING3. If not see . */ /* The format of this file is - DEFGSCODE(GIMPLE_symbol, printable name, structure). + DEFGSCODE(GIMPLE_symbol, printable name, GSS_symbol). */ - Where symbol is the enumeration name without the ``GIMPLE_''. - The argument STRUCTURE is used to compute offsets into each of the - tuple structures that contain operands. Since vector operands - are at different offsets depending on the particular structure - used, these offsets are computed at compile time for efficient - lookup at runtime. See gimple_ops(). - - If a code does not use operand vectors, STRUCTURE should be NULL. */ /* Error marker. This is used in similar ways as ERROR_MARK in tree.def. */ -DEFGSCODE(GIMPLE_ERROR_MARK, "gimple_error_mark", NULL) +DEFGSCODE(GIMPLE_ERROR_MARK, "gimple_error_mark", GSS_BASE) /* IMPORTANT. Do not rearrange the codes between GIMPLE_COND and GIMPLE_RETURN. The ordering is exposed by gimple_has_ops calls. @@ -51,18 +43,18 @@ DEFGSCODE(GIMPLE_ERROR_MARK, "gimple_error_mark", NULL) TRUE_LABEL and FALSE_LABEL are the LABEL_DECL nodes used as the jump target for the comparison. */ -DEFGSCODE(GIMPLE_COND, "gimple_cond", struct gimple_statement_with_ops) +DEFGSCODE(GIMPLE_COND, "gimple_cond", GSS_WITH_OPS) /* GIMPLE_DEBUG represents a debug statement. */ -DEFGSCODE(GIMPLE_DEBUG, "gimple_debug", struct gimple_statement_with_ops) +DEFGSCODE(GIMPLE_DEBUG, "gimple_debug", GSS_WITH_OPS) /* GIMPLE_GOTO represents unconditional jumps. TARGET is a LABEL_DECL or an expression node for computed GOTOs. */ -DEFGSCODE(GIMPLE_GOTO, "gimple_goto", struct gimple_statement_with_ops) +DEFGSCODE(GIMPLE_GOTO, "gimple_goto", GSS_WITH_OPS) /* GIMPLE_LABEL