1use crate::codegen;
4use crate::lir::expressions::{Expression, Operand};
5use crate::lir::lir_type::InternalCallTy;
6use crate::sema::ast::{CallTy, ExternalCallAccounts};
7use solang_parser::pt::Loc;
8
9use super::lir_type::PhiInput;
10
11#[derive(Debug)]
13pub enum Instruction {
14 Nop,
15
16 ReturnData {
18 loc: Loc,
19 data: Operand,
20 data_len: Operand,
21 },
22 ReturnCode {
23 loc: Loc,
24 code: codegen::cfg::ReturnCode,
25 },
26
27 Set {
28 loc: Loc,
29 res: usize,
30 expr: Expression,
31 },
32 Store {
33 loc: Loc,
34 dest: Operand,
35 data: Operand,
36 },
37 PushMemory {
38 loc: Loc,
39 res: usize,
40 array: usize,
41 value: Operand,
42 },
43 PopMemory {
44 loc: Loc,
45 res: usize,
46 array: usize,
47 },
48 Constructor {
49 loc: Loc,
50 success: Option<usize>,
51 res: usize,
52 contract_no: usize,
53 constructor_no: Option<usize>,
54 encoded_args: Operand,
55 value: Option<Operand>,
56 gas: Operand,
57 salt: Option<Operand>,
58 address: Option<Operand>,
59 seeds: Option<Operand>,
60 accounts: ExternalCallAccounts<Operand>,
61 },
62
63 LoadStorage {
64 loc: Loc,
65 res: usize,
66 storage: Operand,
67 },
68 ClearStorage {
69 loc: Loc,
70 storage: Operand,
71 },
72 SetStorage {
73 loc: Loc,
74 value: Operand,
75 storage: Operand,
76 },
77 SetStorageBytes {
78 loc: Loc,
79 value: Operand,
80 storage: Operand,
81 offset: Operand,
82 },
83 PushStorage {
84 loc: Loc,
85 res: usize,
86 value: Option<Operand>,
87 storage: Operand,
88 },
89 PopStorage {
90 loc: Loc,
91 res: Option<usize>,
92 storage: Operand,
93 },
94
95 Call {
96 loc: Loc,
97 res: Vec<usize>,
98 call: InternalCallTy,
99 args: Vec<Operand>,
100 },
101 Print {
103 loc: Loc,
104 operand: Operand,
105 },
106 MemCopy {
107 loc: Loc,
108 src: Operand,
109 dest: Operand,
110 bytes: Operand,
111 },
112
113 ExternalCall {
114 loc: Loc,
115 success: Option<usize>,
117 address: Option<Operand>,
118 accounts: ExternalCallAccounts<Operand>,
119 seeds: Option<Operand>,
122 payload: Operand,
123 value: Operand,
126 gas: Operand,
129 callty: CallTy,
132 contract_function_no: Option<(usize, usize)>,
134 flags: Option<Operand>,
136 },
137 ValueTransfer {
140 loc: Loc,
141 success: Option<usize>,
142 address: Operand,
143 value: Operand,
144 },
145 SelfDestruct {
149 loc: Loc,
150 recipient: Operand,
151 },
152 EmitEvent {
153 loc: Loc,
154 event_no: usize,
155 data: Operand,
156 topics: Vec<Operand>,
157 },
158 WriteBuffer {
159 loc: Loc,
160 buf: Operand,
161 offset: Operand,
162 value: Operand,
163 },
164
165 Branch {
166 loc: Loc,
167 block: usize,
168 },
169 BranchCond {
170 loc: Loc,
171 cond: Operand,
172 true_block: usize,
173 false_block: usize,
174 },
175 Switch {
176 loc: Loc,
177 cond: Operand,
178 cases: Vec<(Operand, usize)>,
179 default: usize,
180 },
181 Return {
182 loc: Loc,
183 value: Vec<Operand>,
184 },
185
186 AssertFailure {
187 loc: Loc,
188 encoded_args: Option<Operand>,
189 },
190
191 Phi {
192 loc: Loc,
193 res: usize,
194 vars: Vec<PhiInput>,
195 },
196}