gcc 源码分析--gimple 关键数据结构

发布于:2025-07-16 ⋅ 阅读:(15) ⋅ 点赞:(0)

gimple 操作码,支持这些:

DEFGSCODE(GIMPLE_symbol, printable name, GSS_symbol).  */
DEFGSCODE(GIMPLE_ERROR_MARK, "gimple_error_mark", GSS_BASE)
DEFGSCODE(GIMPLE_COND, "gimple_cond", GSS_WITH_OPS)
DEFGSCODE(GIMPLE_DEBUG, "gimple_debug", GSS_WITH_OPS)
DEFGSCODE(GIMPLE_GOTO, "gimple_goto", GSS_WITH_OPS)
DEFGSCODE(GIMPLE_LABEL, "gimple_label", GSS_WITH_OPS)
DEFGSCODE(GIMPLE_SWITCH, "gimple_switch", GSS_WITH_OPS)
DEFGSCODE(GIMPLE_ASSIGN, "gimple_assign", GSS_WITH_MEM_OPS)
DEFGSCODE(GIMPLE_ASM, "gimple_asm", GSS_ASM)
DEFGSCODE(GIMPLE_CALL, "gimple_call", GSS_CALL)
DEFGSCODE(GIMPLE_TRANSACTION, "gimple_transaction", GSS_TRANSACTION)
DEFGSCODE(GIMPLE_RETURN, "gimple_return", GSS_WITH_MEM_OPS)
DEFGSCODE(GIMPLE_BIND, "gimple_bind", GSS_BIND)
DEFGSCODE(GIMPLE_CATCH, "gimple_catch", GSS_CATCH)
DEFGSCODE(GIMPLE_EH_FILTER, "gimple_eh_filter", GSS_EH_FILTER)
DEFGSCODE(GIMPLE_EH_MUST_NOT_THROW, "gimple_eh_must_not_throw", GSS_EH_MNT)
DEFGSCODE(GIMPLE_EH_ELSE, "gimple_eh_else", GSS_EH_ELSE)
DEFGSCODE(GIMPLE_RESX, "gimple_resx", GSS_EH_CTRL)
DEFGSCODE(GIMPLE_EH_DISPATCH, "gimple_eh_dispatch", GSS_EH_CTRL)
DEFGSCODE(GIMPLE_PHI, "gimple_phi", GSS_PHI)
DEFGSCODE(GIMPLE_TRY, "gimple_try", GSS_TRY)
DEFGSCODE(GIMPLE_NOP, "gimple_nop", GSS_BASE)
DEFGSCODE(GIMPLE_OMP_ATOMIC_LOAD, "gimple_omp_atomic_load",
DEFGSCODE(GIMPLE_OMP_ATOMIC_STORE, "gimple_omp_atomic_store",
DEFGSCODE(GIMPLE_OMP_CONTINUE, "gimple_omp_continue", GSS_OMP_CONTINUE)
DEFGSCODE(GIMPLE_OMP_CRITICAL, "gimple_omp_critical", GSS_OMP_CRITICAL)
DEFGSCODE(GIMPLE_OMP_FOR, "gimple_omp_for", GSS_OMP_FOR)
DEFGSCODE(GIMPLE_OMP_STRUCTURED_BLOCK, "gimple_omp_structured_block", GSS_OMP)
DEFGSCODE(GIMPLE_OMP_MASTER, "gimple_omp_master", GSS_OMP)
DEFGSCODE(GIMPLE_OMP_MASKED, "gimple_omp_masked", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_TASKGROUP, "gimple_omp_taskgroup", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_PARALLEL, "gimple_omp_parallel", GSS_OMP_PARALLEL_LAYOUT)
DEFGSCODE(GIMPLE_OMP_TASK, "gimple_omp_task", GSS_OMP_TASK)
DEFGSCODE(GIMPLE_OMP_RETURN, "gimple_omp_return", GSS_OMP_ATOMIC_STORE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_SCAN, "gimple_omp_scan", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_SCOPE, "gimple_omp_scope", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_DISPATCH, "gimple_omp_dispatch", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_INTEROP, "gimple_omp_interop", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_SECTION, "gimple_omp_section", GSS_OMP)
DEFGSCODE(GIMPLE_OMP_SECTIONS, "gimple_omp_sections", GSS_OMP_SECTIONS)
DEFGSCODE(GIMPLE_OMP_SECTIONS_SWITCH, "gimple_omp_sections_switch", GSS_BASE)
DEFGSCODE(GIMPLE_OMP_SINGLE, "gimple_omp_single", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_OMP_TARGET, "gimple_omp_target", GSS_OMP_PARALLEL_LAYOUT)
DEFGSCODE(GIMPLE_OMP_TEAMS, "gimple_omp_teams", GSS_OMP_PARALLEL_LAYOUT)
DEFGSCODE(GIMPLE_OMP_ORDERED, "gimple_omp_ordered", GSS_OMP_SINGLE_LAYOUT)
DEFGSCODE(GIMPLE_PREDICT, "gimple_predict", GSS_BASE)
DEFGSCODE(GIMPLE_WITH_CLEANUP_EXPR, "gimple_with_cleanup_expr", GSS_WCE)
DEFGSCODE(GIMPLE_ASSUME, "gimple_assume", GSS_ASSUME)

/* Class of GIMPLE expressions suitable for the RHS of assignments.  See
   get_gimple_rhs_class.  */

enum gimple_rhs_class
{
  GIMPLE_INVALID_RHS,    /* The expression cannot be used on the RHS.  */
  GIMPLE_TERNARY_RHS,    /* The expression is a ternary operation.  */
  GIMPLE_BINARY_RHS,    /* The expression is a binary operation.  */
  GIMPLE_UNARY_RHS,    /* The expression is a unary operation.  */
  GIMPLE_SINGLE_RHS    /* The expression is a single object (an SSA
               name, a _DECL, a _REF, etc.  */
};

gimple 操作指令基础结构

struct 
  gimple

{
  /* [ WORD 1 ]
     Main identifying code for a tuple.  */
  ENUM_BITFIELD(gimple_code) code : 8;

  /* Nonzero if a warning should not be emitted on this tuple.  */
  unsigned int no_warning    : 1;

  /* Nonzero if this tuple has been visited.  Passes are responsible
     for clearing this bit before using it.  */
  unsigned int visited        : 1;

  /* Nonzero if this tuple represents a non-temporal move; currently
     only stores are supported.  */
  unsigned int nontemporal_move    : 1;

  /* Pass local flags.  These flags are free for any pass to use as
     they see fit.  Passes should not assume that these flags contain
     any useful value when the pass starts.  Any initial state that
     the pass requires should be set on entry to the pass.  See
     gimple_set_plf and gimple_plf for usage.  */
  unsigned int plf        : 2;

  /* Nonzero if this statement has been modified and needs to have its
     operands rescanned.  */
  unsigned modified         : 1;

  /* Nonzero if this statement contains volatile operands.  */
  unsigned has_volatile_ops     : 1;

  /* Padding to get subcode to 16 bit alignment.  */
  unsigned pad            : 1;

  /* The SUBCODE field can be used for tuple-specific flags for tuples
     that do not require subcodes.  Note that SUBCODE should be at
     least as wide as tree codes, as several tuples store tree codes
     in there.  */
  unsigned int subcode        : 16;

  /* UID of this statement.  This is used by passes that want to assign IDs
     to statements.  It must be assigned and used by each pass.  By default
     it should be assumed to contain garbage.  */
  unsigned uid;

  /* [ WORD 2 ]
     Number of operands in this tuple.  */
  unsigned num_ops;

  /* Unused 32 bits padding on 64-bit hosts.  */

  /* [ WORD 3 ]
     Locus information for debug info.  */
  location_t location;

  /* [ WORD 4 ]
     Basic block holding this statement.  */
  basic_block bb;

  /* [ WORD 5-6 ]
     Linked lists of gimple statements.  The next pointers form
     a NULL terminated list, the prev pointers are a cyclic list.
     A gimple statement is hence also a double-ended list of
     statements, with the pointer itself being the first element,
     and the prev pointer being the last.  */
  gimple *next;
  gimple * prev;
}

继续自gimple的各个不同指令结构的实现:

295:  gimple_statement_with_ops_base : public gimple
311:  gimple_statement_with_ops : public gimple_statement_with_ops_base
326:  gimple_statement_with_memory_ops_base : public gimple_statement_with_ops_base
342:    public gimple_statement_with_memory_ops_base
357:  gcall : public gimple_statement_with_memory_ops_base
384:  gimple_statement_omp : public gimple
396:  gbind : public gimple
420:  gcatch : public gimple
435:  geh_filter : public gimple
451:  geh_else : public gimple
462:  geh_mnt : public gimple
473:  gphi : public gimple
492:  gimple_statement_eh_ctrl : public gimple
502:  gresx : public gimple_statement_eh_ctrl
509:  geh_dispatch : public gimple_statement_eh_ctrl
519:  gtry : public gimple
549:  gimple_statement_wce : public gimple
567:  gasm : public gimple_statement_with_memory_ops_base
592:  gomp_critical : public gimple_statement_omp
625:  gomp_for : public gimple_statement_omp
648:  gimple_statement_omp_parallel_layout : public gimple_statement_omp
667:  gimple_statement_omp_taskreg : public gimple_statement_omp_parallel_layout
677:  gomp_parallel : public gimple_statement_omp_taskreg
685:  gomp_target : public gimple_statement_omp_parallel_layout
694:  gomp_task : public gimple_statement_omp_taskreg
716:  gomp_sections : public gimple_statement_omp
735:  gomp_continue : public gimple
751:  gimple_statement_omp_single_layout : public gimple_statement_omp
760:  gomp_single : public gimple_statement_omp_single_layout
767:  gomp_teams : public gimple_statement_omp_taskreg
774:  gomp_ordered : public gimple_statement_omp_single_layout
781:  gomp_scan : public gimple_statement_omp_single_layout
793:  gomp_atomic_load : public gimple
805:  gimple_statement_omp_atomic_store_layout : public gimple
815:    public gimple_statement_omp_atomic_store_layout
823:    public gimple_statement_omp_atomic_store_layout
832:  gimple_statement_assume : public gimple
872:  gtransaction : public gimple_statement_with_memory_ops_base
897:  gcond : public gimple_statement_with_ops
908:  gdebug : public gimple_statement_with_ops
918:  ggoto : public gimple_statement_with_ops
928:  glabel : public gimple_statement_with_ops
938:  gswitch : public gimple_statement_with_ops
948:  gassign : public gimple_statement_with_memory_ops
959:  greturn : public gimple_statement_with_memory_ops

类型定义

typedef gimple *gimple_seq_node;


网站公告

今日签到

点亮在社区的每一天
去签到