gsstruct.def (DEFGSSTRUCT): Remove printable-name argument...
authorRichard Henderson <rth@redhat.com>
Sat, 12 Sep 2009 05:49:09 +0000 (22:49 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Sat, 12 Sep 2009 05:49:09 +0000 (22:49 -0700)
* 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.

From-SVN: r151650

gcc/ChangeLog
gcc/gimple.c
gcc/gimple.def
gcc/gimple.h
gcc/gsstruct.def

index 002d19c..4b2aee5 100644 (file)
@@ -1,3 +1,19 @@
+2009-09-11  Richard Henderson  <rth@redhat.com>
+
+       * 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  <dave.anglin@nrc-cnrc.gc.ca>
 
        * config/pa/predicates.md (symbolic_operand): Require a CONST symbolic
index 9223aaa..3be6d84 100644 (file)
@@ -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,
-const char *const gimple_code_name[] = {
-#include "gimple.def"
-};
-#undef DEFGSCODE
 
-/* All the tuples have their operand vector at the very bottom
+/* 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 DEFGSCODE(SYM, NAME, STRUCT)   (sizeof (STRUCT) - sizeof (tree)),
+#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
+
+#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.  */
 
index 716f6e2..1a3f345 100644 (file)
@@ -20,19 +20,11 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 /* 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 <TARGET> 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 <LABEL> represents label statements.  LABEL is a
    LABEL_DECL representing a jump target.  */
-DEFGSCODE(GIMPLE_LABEL, "gimple_label", struct gimple_statement_with_ops)
+DEFGSCODE(GIMPLE_LABEL, "gimple_label", GSS_WITH_OPS)
 
 /* GIMPLE_SWITCH <INDEX, DEFAULT_LAB, LAB1, ..., LABN> represents the
    multiway branch:
@@ -79,7 +71,7 @@ DEFGSCODE(GIMPLE_LABEL, "gimple_label", struct gimple_statement_with_ops)
 
    DEFAULT_LAB, LAB1 ... LABN are the tree nodes representing case labels.
    They must be CASE_LABEL_EXPR nodes.  */
-DEFGSCODE(GIMPLE_SWITCH, "gimple_switch", struct gimple_statement_with_ops)
+DEFGSCODE(GIMPLE_SWITCH, "gimple_switch", GSS_WITH_OPS)
 
 /* IMPORTANT.
    
@@ -106,8 +98,7 @@ DEFGSCODE(GIMPLE_SWITCH, "gimple_switch", struct gimple_statement_with_ops)
    RHS2 is the second operand on the RHS of the assignment.  It must be a tree
    node accepted by is_gimple_val.  This argument exists only if SUBCODE is
    of class GIMPLE_BINARY_RHS.  */
-DEFGSCODE(GIMPLE_ASSIGN, "gimple_assign",
-         struct gimple_statement_with_memory_ops)
+DEFGSCODE(GIMPLE_ASSIGN, "gimple_assign", GSS_WITH_MEM_OPS)
 
 /* GIMPLE_ASM <STRING, I1, ..., IN, O1, ... OM, C1, ..., CP>
    represents inline assembly statements.
@@ -116,7 +107,7 @@ DEFGSCODE(GIMPLE_ASSIGN, "gimple_assign",
    I1 ... IN are the N input operands.
    O1 ... OM are the M output operands.
    C1 ... CP are the P clobber operands.  */
-DEFGSCODE(GIMPLE_ASM, "gimple_asm", struct gimple_statement_asm)
+DEFGSCODE(GIMPLE_ASM, "gimple_asm", GSS_ASM)
 
 /* GIMPLE_CALL <FN, LHS, ARG1, ..., ARGN[, CHAIN]> represents function
    calls.
@@ -130,31 +121,29 @@ DEFGSCODE(GIMPLE_ASM, "gimple_asm", struct gimple_statement_asm)
    is_gimple_operand.
 
     CHAIN is the optional static chain link for nested functions.  */
-DEFGSCODE(GIMPLE_CALL, "gimple_call",
-         struct gimple_statement_with_memory_ops)
+DEFGSCODE(GIMPLE_CALL, "gimple_call", GSS_WITH_MEM_OPS)
 
 /* GIMPLE_RETURN <RETVAL> represents return statements.
 
    RETVAL is the value to return or NULL.  If a value is returned it
    must be accepted by is_gimple_operand.  */
-DEFGSCODE(GIMPLE_RETURN, "gimple_return",
-         struct gimple_statement_with_memory_ops)
+DEFGSCODE(GIMPLE_RETURN, "gimple_return", GSS_WITH_MEM_OPS)
 
 /* GIMPLE_BIND <VARS, BLOCK, BODY> represents a lexical scope.
    VARS is the set of variables declared in that scope.
    BLOCK is the symbol binding block used for debug information.  
    BODY is the sequence of statements in the scope.  */
-DEFGSCODE(GIMPLE_BIND, "gimple_bind", NULL)
+DEFGSCODE(GIMPLE_BIND, "gimple_bind", GSS_BIND)
 
 /* GIMPLE_CATCH <TYPES, HANDLER> represents a typed exception handler.
    TYPES is the type (or list of types) handled.  HANDLER is the
    sequence of statements that handle these types.  */
-DEFGSCODE(GIMPLE_CATCH, "gimple_catch", NULL)
+DEFGSCODE(GIMPLE_CATCH, "gimple_catch", GSS_CATCH)
 
 /* GIMPLE_EH_FILTER <TYPES, FAILURE> represents an exception
    specification.  TYPES is a list of allowed types and FAILURE is the
    sequence of statements to execute on failure.  */
-DEFGSCODE(GIMPLE_EH_FILTER, "gimple_eh_filter", NULL)
+DEFGSCODE(GIMPLE_EH_FILTER, "gimple_eh_filter", GSS_EH_FILTER)
 
 /* GIMPLE_PHI <RESULT, ARG1, ..., ARGN> represents the PHI node
 
@@ -166,11 +155,11 @@ DEFGSCODE(GIMPLE_EH_FILTER, "gimple_eh_filter", NULL)
    exactly the same as the number of incoming edges to the basic block
    holding the PHI node.  Every argument is either an SSA name or a
    tree node of class tcc_constant.  */
-DEFGSCODE(GIMPLE_PHI, "gimple_phi", NULL)
+DEFGSCODE(GIMPLE_PHI, "gimple_phi", GSS_PHI)
 
 /* GIMPLE_RESX <REGION> resumes execution after an exception.
    REGION is the region number being left.  */
-DEFGSCODE(GIMPLE_RESX, "gimple_resx", NULL)
+DEFGSCODE(GIMPLE_RESX, "gimple_resx", GSS_RESX)
 
 /* GIMPLE_TRY <TRY_KIND, EVAL, CLEANUP>
    represents a try/catch or a try/finally statement.
@@ -185,10 +174,10 @@ DEFGSCODE(GIMPLE_RESX, "gimple_resx", NULL)
    GIMPLE_TRY_FINALLY, CLEANUP is always executed after executing EVAL
    (regardless of whether EVAL finished normally, or jumped out or an
    exception was thrown).  */
-DEFGSCODE(GIMPLE_TRY, "gimple_try", NULL)
+DEFGSCODE(GIMPLE_TRY, "gimple_try", GSS_TRY)
 
 /* GIMPLE_NOP represents the "do nothing" statement.  */
-DEFGSCODE(GIMPLE_NOP, "gimple_nop", NULL)
+DEFGSCODE(GIMPLE_NOP, "gimple_nop", GSS_BASE)
 
 
 /* IMPORTANT.
@@ -206,12 +195,14 @@ DEFGSCODE(GIMPLE_NOP, "gimple_nop", NULL)
    GIMPLE_OMP_LOAD (tmp, mem)
    val = some computations involving tmp;
    GIMPLE_OMP_STORE (val).  */
-DEFGSCODE(GIMPLE_OMP_ATOMIC_LOAD, "gimple_omp_atomic_load", NULL)
-DEFGSCODE(GIMPLE_OMP_ATOMIC_STORE, "gimple_omp_atomic_store", NULL)
+DEFGSCODE(GIMPLE_OMP_ATOMIC_LOAD, "gimple_omp_atomic_load",
+         GSS_OMP_ATOMIC_LOAD)
+DEFGSCODE(GIMPLE_OMP_ATOMIC_STORE, "gimple_omp_atomic_store",
+         GSS_OMP_ATOMIC_STORE)
 
 /* GIMPLE_OMP_CONTINUE marks the location of the loop or sections
    iteration in partially lowered OpenMP code.  */
-DEFGSCODE(GIMPLE_OMP_CONTINUE, "gimple_omp_continue", NULL)
+DEFGSCODE(GIMPLE_OMP_CONTINUE, "gimple_omp_continue", GSS_OMP_CONTINUE)
 
 /* GIMPLE_OMP_CRITICAL <NAME, BODY> represents
 
@@ -219,7 +210,7 @@ DEFGSCODE(GIMPLE_OMP_CONTINUE, "gimple_omp_continue", NULL)
 
    NAME is the name given to the critical section.
    BODY is the sequence of statements that are inside the critical section.  */
-DEFGSCODE(GIMPLE_OMP_CRITICAL, "gimple_omp_critical", NULL)
+DEFGSCODE(GIMPLE_OMP_CRITICAL, "gimple_omp_critical", GSS_OMP_CRITICAL)
 
 /* GIMPLE_OMP_FOR <BODY, CLAUSES, INDEX, INITIAL, FINAL, COND, INCR, PRE_BODY>
    represents
@@ -256,15 +247,15 @@ DEFGSCODE(GIMPLE_OMP_CRITICAL, "gimple_omp_critical", NULL)
    expressions that are evaluated without any synchronization.
    The evaluation order, frequency of evaluation and side-effects are
    unspecified by the standard.  */
-DEFGSCODE(GIMPLE_OMP_FOR, "gimple_omp_for", NULL)
+DEFGSCODE(GIMPLE_OMP_FOR, "gimple_omp_for", GSS_OMP_FOR)
 
 /* GIMPLE_OMP_MASTER <BODY> represents #pragma omp master.
    BODY is the sequence of statements to execute in the master section.  */
-DEFGSCODE(GIMPLE_OMP_MASTER, "gimple_omp_master", NULL)
+DEFGSCODE(GIMPLE_OMP_MASTER, "gimple_omp_master", GSS_OMP)
 
 /* GIMPLE_OMP_ORDERED <BODY> represents #pragma omp ordered.
    BODY is the sequence of statements to execute in the ordered section.  */
-DEFGSCODE(GIMPLE_OMP_ORDERED, "gimple_omp_ordered", NULL)
+DEFGSCODE(GIMPLE_OMP_ORDERED, "gimple_omp_ordered", GSS_OMP)
 
 /* GIMPLE_OMP_PARALLEL <BODY, CLAUSES, CHILD_FN, DATA_ARG> represents
 
@@ -282,7 +273,7 @@ DEFGSCODE(GIMPLE_OMP_ORDERED, "gimple_omp_ordered", NULL)
    DATA_ARG is a local variable in the parent function containing data
    to be shared with CHILD_FN.  This is used to implement all the data
    sharing clauses.  */
-DEFGSCODE(GIMPLE_OMP_PARALLEL, "gimple_omp_parallel", NULL)
+DEFGSCODE(GIMPLE_OMP_PARALLEL, "gimple_omp_parallel", GSS_OMP_PARALLEL)
 
 /* GIMPLE_OMP_TASK <BODY, CLAUSES, CHILD_FN, DATA_ARG, COPY_FN,
                    ARG_SIZE, ARG_ALIGN> represents
@@ -308,14 +299,14 @@ DEFGSCODE(GIMPLE_OMP_PARALLEL, "gimple_omp_parallel", NULL)
 
    ARG_SIZE and ARG_ALIGN are the size and alignment of the incoming
    data area allocated by GOMP_task and passed to CHILD_FN.  */
-DEFGSCODE(GIMPLE_OMP_TASK, "gimple_omp_task", NULL)
+DEFGSCODE(GIMPLE_OMP_TASK, "gimple_omp_task", GSS_OMP_TASK)
 
 /* OMP_RETURN marks the end of an OpenMP directive.  */
-DEFGSCODE(GIMPLE_OMP_RETURN, "gimple_omp_return", NULL)
+DEFGSCODE(GIMPLE_OMP_RETURN, "gimple_omp_return", GSS_BASE)
 
 /* OMP_SECTION <BODY> represents #pragma omp section.
    BODY is the sequence of statements in the section body.  */
-DEFGSCODE(GIMPLE_OMP_SECTION, "gimple_omp_section", NULL)
+DEFGSCODE(GIMPLE_OMP_SECTION, "gimple_omp_section", GSS_OMP)
 
 /* OMP_SECTIONS <BODY, CLAUSES, CONTROL> represents #pragma omp sections.
 
@@ -323,28 +314,28 @@ DEFGSCODE(GIMPLE_OMP_SECTION, "gimple_omp_section", NULL)
    CLAUSES is a TREE_LIST node holding the list of associated clauses.
    CONTROL is a VAR_DECL used for deciding which of the sections
    to execute.  */
-DEFGSCODE(GIMPLE_OMP_SECTIONS, "gimple_omp_sections", NULL)
+DEFGSCODE(GIMPLE_OMP_SECTIONS, "gimple_omp_sections", GSS_OMP_SECTIONS)
 
 /* GIMPLE_OMP_SECTIONS_SWITCH is a marker placed immediately after
    OMP_SECTIONS.  It represents the GIMPLE_SWITCH used to decide which
    branch is taken.  */
-DEFGSCODE(GIMPLE_OMP_SECTIONS_SWITCH, "gimple_omp_sections_switch", NULL)
+DEFGSCODE(GIMPLE_OMP_SECTIONS_SWITCH, "gimple_omp_sections_switch", GSS_BASE)
 
 /* GIMPLE_OMP_SINGLE <BODY, CLAUSES> represents #pragma omp single
    BODY is the sequence of statements inside the single section.
    CLAUSES is a TREE_LIST node holding the associated clauses.  */
-DEFGSCODE(GIMPLE_OMP_SINGLE, "gimple_omp_single", NULL)
+DEFGSCODE(GIMPLE_OMP_SINGLE, "gimple_omp_single", GSS_OMP_SINGLE)
 
 /* GIMPLE_PREDICT <PREDICT, OUTCOME> specifies a hint for branch prediction.
 
    PREDICT is one of the predictors from predict.def.
 
    OUTCOME is NOT_TAKEN or TAKEN.  */
-DEFGSCODE(GIMPLE_PREDICT, "gimple_predict", NULL)
+DEFGSCODE(GIMPLE_PREDICT, "gimple_predict", GSS_BASE)
 
 /*  This node represents a cleanup expression.  It is ONLY USED INTERNALLY
     by the gimplifier as a placeholder for cleanups, and its uses will be
     cleaned up by the time gimplification is done.
     
     This tuple should not exist outside of the gimplifier proper.  */
-DEFGSCODE(GIMPLE_WITH_CLEANUP_EXPR, "gimple_with_cleanup_expr", NULL)
+DEFGSCODE(GIMPLE_WITH_CLEANUP_EXPR, "gimple_with_cleanup_expr", GSS_WCE)
index 6dce0b7..8ca1f28 100644 (file)
@@ -714,12 +714,12 @@ struct GTY(()) gimple_statement_omp_atomic_store {
   tree val;
 };
 
+#define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP)  SYM,
 enum gimple_statement_structure_enum {
-#define DEFGSSTRUCT(SYM, STRING)       SYM,
 #include "gsstruct.def"
-#undef DEFGSSTRUCT
     LAST_GSS_ENUM
 };
+#undef DEFGSSTRUCT
 
 
 /* Define the overall contents of a gimple tuple.  It may be any of the
@@ -750,6 +750,14 @@ union GTY ((desc ("gimple_statement_structure (&%h)"))) gimple_statement_d {
 };
 
 /* In gimple.c.  */
+
+/* Offset in bytes to the location of the operand vector.
+   Zero if there is no operand vector for this tuple structure.  */
+extern size_t const gimple_ops_offset_[];
+
+/* Map GIMPLE codes to GSS codes.  */
+extern enum gimple_statement_structure_enum const gss_for_code_[];
+
 gimple gimple_build_return (tree);
 
 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
@@ -801,7 +809,6 @@ gimple gimple_build_cdt (tree, tree);
 gimple gimple_build_omp_atomic_load (tree, tree);
 gimple gimple_build_omp_atomic_store (tree);
 gimple gimple_build_predict (enum br_predictor, enum prediction);
-enum gimple_statement_structure_enum gimple_statement_structure (gimple);
 enum gimple_statement_structure_enum gss_for_assign (enum tree_code);
 void sort_case_labels (VEC(tree,heap) *);
 void gimple_set_body (tree, gimple_seq);
@@ -1023,6 +1030,25 @@ gimple_code (const_gimple g)
 }
 
 
+/* Return the GSS code used by a GIMPLE code.  */
+
+static inline enum gimple_statement_structure_enum
+gss_for_code (enum gimple_code code)
+{
+  gcc_assert ((unsigned int)code < LAST_AND_UNUSED_GIMPLE_CODE);
+  return gss_for_code_[code];
+}
+
+
+/* Return which GSS code is used by GS.  */
+
+static inline enum gimple_statement_structure_enum
+gimple_statement_structure (gimple gs)
+{
+  return gss_for_code (gimple_code (gs));
+}
+
+
 /* Return true if statement G has sub-statements.  This is only true for
    High GIMPLE statements.  */
 
@@ -1557,16 +1583,15 @@ gimple_set_num_ops (gimple gs, unsigned num_ops)
 static inline tree *
 gimple_ops (gimple gs)
 {
-  /* Offset in bytes to the location of the operand vector in every
-     tuple structure.  Defined in gimple.c  */
-  extern size_t const gimple_ops_offset_[];
-
-  if (!gimple_has_ops (gs))
-    return NULL;
+  size_t off;
 
   /* All the tuples have their operand vector at the very bottom
-     of the structure.  */
-  return ((tree *) ((char *) gs + gimple_ops_offset_[gimple_code (gs)]));
+     of the structure.  Note that those structures that do not
+     have an operand vector have a zero offset.  */
+  off = gimple_ops_offset_[gimple_statement_structure (gs)];
+  gcc_assert (off != 0);
+
+  return (tree *) ((char *) gs + off);
 }
 
 
index 58f4476..97875c9 100644 (file)
@@ -21,28 +21,28 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 /* The format of this file is
-   DEFGSSTRUCT(GSS_enumeration value, printable name).
+   DEFGSSTRUCT(GSS enumeration value, structure name, has-tree-operands).
    Each enum value should correspond with a single member of the union
    gimple_statement_d.  */
 
-DEFGSSTRUCT(GSS_BASE, "base")
-DEFGSSTRUCT(GSS_WITH_OPS, "with_ops")
-DEFGSSTRUCT(GSS_WITH_MEM_OPS, "with_mem_ops")
-DEFGSSTRUCT(GSS_OMP, "omp")
-DEFGSSTRUCT(GSS_BIND, "bind")
-DEFGSSTRUCT(GSS_CATCH, "catch")
-DEFGSSTRUCT(GSS_EH_FILTER, "eh_filter")
-DEFGSSTRUCT(GSS_PHI, "phi")
-DEFGSSTRUCT(GSS_RESX, "resx")
-DEFGSSTRUCT(GSS_TRY, "try")
-DEFGSSTRUCT(GSS_WCE, "with_cleanup_expression")
-DEFGSSTRUCT(GSS_ASM, "asm")
-DEFGSSTRUCT(GSS_OMP_CRITICAL, "omp_critical")
-DEFGSSTRUCT(GSS_OMP_FOR, "omp_for")
-DEFGSSTRUCT(GSS_OMP_PARALLEL, "omp_parallel")
-DEFGSSTRUCT(GSS_OMP_TASK, "omp_task")
-DEFGSSTRUCT(GSS_OMP_SECTIONS, "sections")
-DEFGSSTRUCT(GSS_OMP_SINGLE, "single")
-DEFGSSTRUCT(GSS_OMP_CONTINUE, "omp_continue")
-DEFGSSTRUCT(GSS_OMP_ATOMIC_LOAD, "omp_atomic_load")
-DEFGSSTRUCT(GSS_OMP_ATOMIC_STORE, "omp_atomic_store")
+DEFGSSTRUCT(GSS_BASE, gimple_statement_base, false)
+DEFGSSTRUCT(GSS_WITH_OPS, gimple_statement_with_ops, true)
+DEFGSSTRUCT(GSS_WITH_MEM_OPS, gimple_statement_with_memory_ops, true)
+DEFGSSTRUCT(GSS_ASM, gimple_statement_asm, true)
+DEFGSSTRUCT(GSS_BIND, gimple_statement_bind, false)
+DEFGSSTRUCT(GSS_PHI, gimple_statement_phi, false)
+DEFGSSTRUCT(GSS_TRY, gimple_statement_try, false)
+DEFGSSTRUCT(GSS_CATCH, gimple_statement_catch, false)
+DEFGSSTRUCT(GSS_EH_FILTER, gimple_statement_eh_filter, false)
+DEFGSSTRUCT(GSS_RESX, gimple_statement_resx, false)
+DEFGSSTRUCT(GSS_WCE, gimple_statement_wce, false)
+DEFGSSTRUCT(GSS_OMP, gimple_statement_omp, false)
+DEFGSSTRUCT(GSS_OMP_CRITICAL, gimple_statement_omp_critical, false)
+DEFGSSTRUCT(GSS_OMP_FOR, gimple_statement_omp_for, false)
+DEFGSSTRUCT(GSS_OMP_PARALLEL, gimple_statement_omp_parallel, false)
+DEFGSSTRUCT(GSS_OMP_TASK, gimple_statement_omp_task, false)
+DEFGSSTRUCT(GSS_OMP_SECTIONS, gimple_statement_omp_sections, false)
+DEFGSSTRUCT(GSS_OMP_SINGLE, gimple_statement_omp_single, false)
+DEFGSSTRUCT(GSS_OMP_CONTINUE, gimple_statement_omp_continue, false)
+DEFGSSTRUCT(GSS_OMP_ATOMIC_LOAD, gimple_statement_omp_atomic_load, false)
+DEFGSSTRUCT(GSS_OMP_ATOMIC_STORE, gimple_statement_omp_atomic_store, false)