Nearly CC
An educational compiler skeleton
highlevel.h
Go to the documentation of this file.
1 #ifndef HIGHLEVEL_H
2 #define HIGHLEVEL_H
3 
4 #include "formatter.h"
5 #include "instruction.h"
6 
7 // Generated high-level opcodes and support functions/classes
8 // Do not edit this file!
9 
13 
16  HINS_nop,
17  HINS_add_b,
18  HINS_add_w,
19  HINS_add_l,
20  HINS_add_q,
21  HINS_sub_b,
22  HINS_sub_w,
23  HINS_sub_l,
24  HINS_sub_q,
25  HINS_mul_b,
26  HINS_mul_w,
27  HINS_mul_l,
28  HINS_mul_q,
29  HINS_div_b,
30  HINS_div_w,
31  HINS_div_l,
32  HINS_div_q,
33  HINS_mod_b,
34  HINS_mod_w,
35  HINS_mod_l,
36  HINS_mod_q,
37  HINS_lshift_b,
38  HINS_lshift_w,
39  HINS_lshift_l,
40  HINS_lshift_q,
41  HINS_rshift_b,
42  HINS_rshift_w,
43  HINS_rshift_l,
44  HINS_rshift_q,
45  HINS_cmplt_b,
46  HINS_cmplt_w,
47  HINS_cmplt_l,
48  HINS_cmplt_q,
49  HINS_cmplte_b,
50  HINS_cmplte_w,
51  HINS_cmplte_l,
52  HINS_cmplte_q,
53  HINS_cmpgt_b,
54  HINS_cmpgt_w,
55  HINS_cmpgt_l,
56  HINS_cmpgt_q,
57  HINS_cmpgte_b,
58  HINS_cmpgte_w,
59  HINS_cmpgte_l,
60  HINS_cmpgte_q,
61  HINS_cmpeq_b,
62  HINS_cmpeq_w,
63  HINS_cmpeq_l,
64  HINS_cmpeq_q,
65  HINS_cmpneq_b,
66  HINS_cmpneq_w,
67  HINS_cmpneq_l,
68  HINS_cmpneq_q,
69  HINS_and_b,
70  HINS_and_w,
71  HINS_and_l,
72  HINS_and_q,
73  HINS_or_b,
74  HINS_or_w,
75  HINS_or_l,
76  HINS_or_q,
77  HINS_xor_b,
78  HINS_xor_w,
79  HINS_xor_l,
80  HINS_xor_q,
81  HINS_neg_b,
82  HINS_neg_w,
83  HINS_neg_l,
84  HINS_neg_q,
85  HINS_not_b,
86  HINS_not_w,
87  HINS_not_l,
88  HINS_not_q,
89  HINS_compl_b,
90  HINS_compl_w,
91  HINS_compl_l,
92  HINS_compl_q,
93  HINS_inc_b,
94  HINS_inc_w,
95  HINS_inc_l,
96  HINS_inc_q,
97  HINS_dec_b,
98  HINS_dec_w,
99  HINS_dec_l,
100  HINS_dec_q,
101  HINS_mov_b,
102  HINS_mov_w,
103  HINS_mov_l,
104  HINS_mov_q,
105  HINS_spill_b,
106  HINS_spill_w,
107  HINS_spill_l,
108  HINS_spill_q,
109  HINS_restore_b,
110  HINS_restore_w,
111  HINS_restore_l,
112  HINS_restore_q,
113  HINS_sconv_bw,
114  HINS_sconv_bl,
115  HINS_sconv_bq,
116  HINS_sconv_wl,
117  HINS_sconv_wq,
118  HINS_sconv_lq,
119  HINS_uconv_bw,
120  HINS_uconv_bl,
121  HINS_uconv_bq,
122  HINS_uconv_wl,
123  HINS_uconv_wq,
124  HINS_uconv_lq,
125  HINS_ret,
126  HINS_jmp,
127  HINS_call,
128  HINS_enter,
129  HINS_leave,
130  HINS_localaddr,
131  HINS_cjmp_t,
132  HINS_cjmp_f,
133 }; // HighLevelOpcode enumeration
134 
140 const char *highlevel_opcode_to_str(HighLevelOpcode opcode);
141 
150 
159 
164 public:
168  bool is_function_call(Instruction *ins) const {
169  return ins->get_opcode() == HINS_call;
170  }
171 
177  bool falls_through(Instruction *ins) const {
178  // only an unconditional jump instruction does not fall through
179  return ins->get_opcode() != HINS_jmp;
180  }
181 };
182 
183 #endif // HIGHLEVEL_H
HighLevelInstructionProperties class: this is used by ControlFlowGraphBuilder to make sense of contro...
Definition: highlevel.h:163
bool is_function_call(Instruction *ins) const
Determine whether an Instruction is a function call.
Definition: highlevel.h:168
bool falls_through(Instruction *ins) const
Determine whether it is possible for an Instruction to fall through to the next sequential instructio...
Definition: highlevel.h:177
Instruction object type.
Definition: instruction.h:31
int get_opcode() const
Get the opcode value.
Definition: instruction.cpp:46
const char * highlevel_opcode_to_str(HighLevelOpcode opcode)
Translate a high-level opcode to its assembler mnemonic.
Definition: highlevel.cpp:6
int highlevel_opcode_get_source_operand_size(HighLevelOpcode opcode)
Determine the source operand size (int bytes) implied by a specified opcode.
Definition: highlevel.cpp:129
int highlevel_opcode_get_dest_operand_size(HighLevelOpcode opcode)
Determine the destination operand size (int bytes) implied by a specified opcode.
Definition: highlevel.cpp:252
HighLevelOpcode
Enumeration of high-level opcodes.
Definition: highlevel.h:15