1 /* 2 * Copyright (C) 2002-2011, Parrot Foundation. 3 */ 4 5 6 /* Data structures: */ 7 8 /* Two-way linked list of predecessors and successors */ 9 #ifndef PARROT_CFG_H_GUARD 10 #define PARROT_CFG_H_GUARD 11 12 typedef struct _edge { 13 struct _basic_block *from; 14 struct _basic_block *to; 15 struct _edge *pred_next; 16 struct _edge *succ_next; 17 struct _edge *next; 18 } Edge; 19 20 typedef struct _basic_block { 21 Instruction *start; /* First instruction in basic block */ 22 Instruction *end; /* Last instruction in basic block */ 23 Edge *pred_list; 24 Edge *succ_list; 25 int loop_depth; 26 unsigned int index; /* on bb_list*/ 27 int flag; 28 } Basic_block; 29 30 enum block_enum_flags_t { 31 BB_IS_SUB = 1 << 0 32 }; 33 34 35 typedef struct _loop_info { 36 Set *loop; /* loop set containing bb's */ 37 Set *exits; /* blocks that exit the loop */ 38 int depth; /* depth of this loop */ 39 unsigned int n_entries; /* nr of entries to this loop */ 40 unsigned int header; /* header block of loop */ 41 unsigned int preheader; /* preheader block of loop, if 1 entry point */ 42 unsigned int size; /* no of blocks in loop */ 43 } Loop_info; 44 45 46 /* Functions: */ 47 48 /* HEADERIZER BEGIN: compilers/imcc/cfg.c */ 49 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 50 51 void build_cfg(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) 52 __attribute__nonnull__(1) 53 __attribute__nonnull__(2) 54 FUNC_MODIFIES(*imcc) 55 FUNC_MODIFIES(*unit); 56 57 void clear_basic_blocks(ARGMOD(IMC_Unit *unit)) 58 __attribute__nonnull__(1) 59 FUNC_MODIFIES(*unit); 60 61 void compute_dominance_frontiers( 62 ARGMOD(imc_info_t *imcc), 63 ARGMOD(IMC_Unit *unit)) 64 __attribute__nonnull__(1) 65 __attribute__nonnull__(2) 66 FUNC_MODIFIES(*imcc) 67 FUNC_MODIFIES(*unit); 68 69 void compute_dominators(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) 70 __attribute__nonnull__(1) 71 __attribute__nonnull__(2) 72 FUNC_MODIFIES(*imcc) 73 FUNC_MODIFIES(*unit); 74 75 PARROT_WARN_UNUSED_RESULT 76 PARROT_PURE_FUNCTION 77 int edge_count(ARGIN(const IMC_Unit *unit)) 78 __attribute__nonnull__(1); 79 80 void find_basic_blocks( 81 ARGMOD(imc_info_t *imcc), 82 ARGMOD(IMC_Unit *unit), 83 int first) 84 __attribute__nonnull__(1) 85 __attribute__nonnull__(2) 86 FUNC_MODIFIES(*imcc) 87 FUNC_MODIFIES(*unit); 88 89 void find_loops(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) 90 __attribute__nonnull__(1) 91 __attribute__nonnull__(2) 92 FUNC_MODIFIES(*imcc) 93 FUNC_MODIFIES(*unit); 94 95 PARROT_WARN_UNUSED_RESULT 96 PARROT_PURE_FUNCTION 97 int natural_preheader( 98 ARGIN(const IMC_Unit *unit), 99 ARGIN(const Loop_info *loop_info)) 100 __attribute__nonnull__(1) 101 __attribute__nonnull__(2); 102 103 void search_predecessors_not_in( 104 ARGIN(const Basic_block *node), 105 ARGMOD(Set *s)) 106 __attribute__nonnull__(1) 107 __attribute__nonnull__(2) 108 FUNC_MODIFIES(*s); 109 110 #define ASSERT_ARGS_build_cfg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 111 PARROT_ASSERT_ARG(imcc) \ 112 , PARROT_ASSERT_ARG(unit)) 113 #define ASSERT_ARGS_clear_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 114 PARROT_ASSERT_ARG(unit)) 115 #define ASSERT_ARGS_compute_dominance_frontiers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 116 PARROT_ASSERT_ARG(imcc) \ 117 , PARROT_ASSERT_ARG(unit)) 118 #define ASSERT_ARGS_compute_dominators __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 119 PARROT_ASSERT_ARG(imcc) \ 120 , PARROT_ASSERT_ARG(unit)) 121 #define ASSERT_ARGS_edge_count __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 122 PARROT_ASSERT_ARG(unit)) 123 #define ASSERT_ARGS_find_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 124 PARROT_ASSERT_ARG(imcc) \ 125 , PARROT_ASSERT_ARG(unit)) 126 #define ASSERT_ARGS_find_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 127 PARROT_ASSERT_ARG(imcc) \ 128 , PARROT_ASSERT_ARG(unit)) 129 #define ASSERT_ARGS_natural_preheader __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 130 PARROT_ASSERT_ARG(unit) \ 131 , PARROT_ASSERT_ARG(loop_info)) 132 #define ASSERT_ARGS_search_predecessors_not_in __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 133 PARROT_ASSERT_ARG(node) \ 134 , PARROT_ASSERT_ARG(s)) 135 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 136 /* HEADERIZER END: compilers/imcc/cfg.c */ 137 138 #endif /* PARROT_CFG_H_GUARD */ 139 140 141 /* 142 * Local variables: 143 * c-file-style: "parrot" 144 * End: 145 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 146 */ 147 148