@@ -50,12 +50,8 @@ pair<YulString, BuiltinFunctionForEVM> createEVMFunction(
50
50
f.name = YulString{_name};
51
51
f.parameters .resize (info.args );
52
52
f.returns .resize (info.ret );
53
- f.movable = eth::SemanticInformation::movable (_instruction);
54
- f.sideEffectFree = eth::SemanticInformation::sideEffectFree (_instruction);
55
- f.sideEffectFreeIfNoMSize = eth::SemanticInformation::sideEffectFreeIfNoMSize (_instruction);
53
+ f.sideEffects = EVMDialect::sideEffectsOfInstruction (_instruction);
56
54
f.isMSize = _instruction == dev::eth::Instruction::MSIZE;
57
- f.invalidatesStorage = eth::SemanticInformation::invalidatesStorage (_instruction);
58
- f.invalidatesMemory = eth::SemanticInformation::invalidatesMemory (_instruction);
59
55
f.literalArguments = false ;
60
56
f.instruction = _instruction;
61
57
f.generateCode = [_instruction](
@@ -75,11 +71,7 @@ pair<YulString, BuiltinFunctionForEVM> createFunction(
75
71
string _name,
76
72
size_t _params,
77
73
size_t _returns,
78
- bool _movable,
79
- bool _sideEffectFree,
80
- bool _sideEffectFreeIfNoMSize,
81
- bool _invalidatesStorage,
82
- bool _invalidatesMemory,
74
+ SideEffects _sideEffects,
83
75
bool _literalArguments,
84
76
std::function<void (FunctionCall const &, AbstractAssembly&, BuiltinContext&, std::function<void ()>)> _generateCode
85
77
)
@@ -89,13 +81,9 @@ pair<YulString, BuiltinFunctionForEVM> createFunction(
89
81
f.name = name;
90
82
f.parameters .resize (_params);
91
83
f.returns .resize (_returns);
92
- f.movable = _movable ;
84
+ f.sideEffects = std::move (_sideEffects) ;
93
85
f.literalArguments = _literalArguments;
94
- f.sideEffectFree = _sideEffectFree;
95
- f.sideEffectFreeIfNoMSize = _sideEffectFreeIfNoMSize;
96
86
f.isMSize = false ;
97
- f.invalidatesStorage = _invalidatesStorage;
98
- f.invalidatesMemory = _invalidatesMemory;
99
87
f.instruction = {};
100
88
f.generateCode = std::move (_generateCode);
101
89
return {name, f};
@@ -116,7 +104,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
116
104
117
105
if (_objectAccess)
118
106
{
119
- builtins.emplace (createFunction (" datasize" , 1 , 1 , true , true , true , false , false , true , [](
107
+ builtins.emplace (createFunction (" datasize" , 1 , 1 , SideEffects{} , true , [](
120
108
FunctionCall const & _call,
121
109
AbstractAssembly& _assembly,
122
110
BuiltinContext& _context,
@@ -137,7 +125,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
137
125
_assembly.appendDataSize (_context.subIDs .at (dataName));
138
126
}
139
127
}));
140
- builtins.emplace (createFunction (" dataoffset" , 1 , 1 , true , true , true , false , false , true , [](
128
+ builtins.emplace (createFunction (" dataoffset" , 1 , 1 , SideEffects{} , true , [](
141
129
FunctionCall const & _call,
142
130
AbstractAssembly& _assembly,
143
131
BuiltinContext& _context,
@@ -158,15 +146,22 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
158
146
_assembly.appendDataOffset (_context.subIDs .at (dataName));
159
147
}
160
148
}));
161
- builtins.emplace (createFunction (" datacopy" , 3 , 0 , false , false , false , false , true , false , [](
162
- FunctionCall const &,
163
- AbstractAssembly& _assembly,
164
- BuiltinContext&,
165
- std::function<void ()> _visitArguments
166
- ) {
167
- _visitArguments ();
168
- _assembly.appendInstruction (dev::eth::Instruction::CODECOPY);
169
- }));
149
+ builtins.emplace (createFunction (
150
+ " datacopy" ,
151
+ 3 ,
152
+ 0 ,
153
+ SideEffects{false , false , false , false , true },
154
+ false ,
155
+ [](
156
+ FunctionCall const &,
157
+ AbstractAssembly& _assembly,
158
+ BuiltinContext&,
159
+ std::function<void ()> _visitArguments
160
+ ) {
161
+ _visitArguments ();
162
+ _assembly.appendInstruction (dev::eth::Instruction::CODECOPY);
163
+ }
164
+ ));
170
165
}
171
166
return builtins;
172
167
}
@@ -225,3 +220,14 @@ EVMDialect const& EVMDialect::yulForEVM(langutil::EVMVersion _version)
225
220
dialects[_version] = make_unique<EVMDialect>(AsmFlavour::Yul, false , _version);
226
221
return *dialects[_version];
227
222
}
223
+
224
+ SideEffects EVMDialect::sideEffectsOfInstruction (eth::Instruction _instruction)
225
+ {
226
+ return SideEffects{
227
+ eth::SemanticInformation::movable (_instruction),
228
+ eth::SemanticInformation::sideEffectFree (_instruction),
229
+ eth::SemanticInformation::sideEffectFreeIfNoMSize (_instruction),
230
+ eth::SemanticInformation::invalidatesStorage (_instruction),
231
+ eth::SemanticInformation::invalidatesMemory (_instruction)
232
+ };
233
+ }
0 commit comments