@@ -175,9 +175,9 @@ def RLC_DeclarationStatement : RLC_Dialect<"decl", [Symbol, DeclareOpInterfaceMe
175
175
176
176
177
177
class RLC_FunctionBase<string mnemonic> :
178
- RLC_Dialect<mnemonic, [Symbol, CallableOpInterface, AutomaticAllocationScope, TypeCheckable]> {
178
+ RLC_Dialect<mnemonic, [CallableOpInterface, AutomaticAllocationScope, TypeCheckable]> {
179
179
180
- let arguments = (ins StrAttr:$unmangledName, SymbolNameAttr:$sym_name, StrArrayAttr:$argNames);
180
+ let arguments = (ins StrAttr:$unmangledName, StrArrayAttr:$argNames);
181
181
let description = [{
182
182
expression.
183
183
}];
@@ -191,17 +191,21 @@ RLC_Dialect<mnemonic, [Symbol, CallableOpInterface, AutomaticAllocationScope, Ty
191
191
192
192
let builders = [
193
193
OpBuilder<(ins "StringRef":$name, "FunctionType":$type, "ArrayAttr":$argNames), [{
194
- build($_builder, $_state, type, name ,mangledName(name, type), argNames);
194
+ build($_builder, $_state, type, name ,argNames);
195
195
}]>];
196
196
197
197
let assemblyFormat = [{
198
- $unmangledName $argNames type($result) $sym_name $ precondition $body attr-dict
198
+ $unmangledName $argNames type($result) $precondition $body attr-dict
199
199
}];
200
- let extraClassDeclaration = [{
200
+ code extraBaseClassDeclaration = [{
201
201
Region *getCallableRegion() {
202
202
return isDeclaration() ? nullptr : &getBody();
203
203
}
204
204
205
+ std::string getMangledName() {
206
+ return rlc::mangledName(getUnmangledName(), getType());
207
+ }
208
+
205
209
mlir::FunctionType getType() {
206
210
return getResult().getType().cast<mlir::FunctionType>();
207
211
}
@@ -228,7 +232,7 @@ RLC_Dialect<mnemonic, [Symbol, CallableOpInterface, AutomaticAllocationScope, Ty
228
232
}
229
233
230
234
bool isInternal() {
231
- return getName ().startswith("_");
235
+ return getUnmangledName ().startswith("_");
232
236
}
233
237
234
238
bool isDeclaration() {
@@ -289,18 +293,37 @@ RLC_Dialect<mnemonic, [Symbol, CallableOpInterface, AutomaticAllocationScope, Ty
289
293
290
294
def RLC_FlatFunctionOp : RLC_FunctionBase<"flat_fun"> {
291
295
let summary = "function.";
296
+ let extraClassDeclaration = extraBaseClassDeclaration;
292
297
}
293
298
294
299
def RLC_FunctionOp : RLC_FunctionBase<"fun"> {
295
300
let summary = "function.";
301
+ let extraClassDeclaration = extraBaseClassDeclaration;
296
302
}
297
303
298
304
def RLC_ActionFunction : RLC_FunctionBase<"action_fun"> {
299
305
let summary = "function.";
300
306
let results = (outs FunctionType:$result, Variadic<FunctionType>:$actions);
301
307
let assemblyFormat = [{
302
- $unmangledName $argNames type($result) type($actions) $sym_name $ precondition $body attr-dict
308
+ $unmangledName $argNames type($result) type($actions) $precondition $body attr-dict
303
309
}];
310
+ let extraClassDeclaration = extraBaseClassDeclaration # [{
311
+
312
+ size_t getSubActionsSize() {
313
+ return getActions().size();
314
+ }
315
+
316
+ mlir::FunctionType getSubActionType(size_t index) {
317
+ return getActions().getTypes()[index].cast<mlir::FunctionType>();
318
+ }
319
+
320
+ mlir::FunctionType getMainActionType() {
321
+ return getResult().getType().cast<mlir::FunctionType>();
322
+ }
323
+ mlir::rlc::EntityType getEntityType() {
324
+ return getMainActionType().getResult(0).cast<mlir::rlc::EntityType>();
325
+ }
326
+ }];
304
327
305
328
}
306
329
0 commit comments