Commit f2c4a81c by Richard Henderson Committed by Richard Henderson

gsstruct.def (DEFGSSTRUCT): Remove printable-name argument...

* 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
parent 0a58a024
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
......
......@@ -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. */
......
......@@ -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);
}
......
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment