@@ -75,7 +75,11 @@ static bool verifyTypeParamCount(mlir::Type inType, unsigned numParams) {
75
75
return false ;
76
76
}
77
77
78
- // Parser shared by Alloca and Allocmem
78
+ // / Parser shared by Alloca and Allocmem
79
+ // /
80
+ // / operation ::= %res = (`fir.alloca` | `fir.allocmem`) $in_type
81
+ // / ( `(` $typeparams `)` )? ( `,` $shape )?
82
+ // / attr-dict-without-keyword
79
83
template <typename FN>
80
84
static mlir::ParseResult parseAllocatableOp (FN wrapResultType,
81
85
mlir::OpAsmParser &parser,
@@ -151,15 +155,6 @@ static mlir::Type wrapAllocaResultType(mlir::Type intype) {
151
155
return ReferenceType::get (intype);
152
156
}
153
157
154
- static mlir::ParseResult parseAlloca (mlir::OpAsmParser &parser,
155
- mlir::OperationState &result) {
156
- return parseAllocatableOp (wrapAllocaResultType, parser, result);
157
- }
158
-
159
- static void printAlloca (mlir::OpAsmPrinter &p, fir::AllocaOp &op) {
160
- printAllocatableOp (p, op);
161
- }
162
-
163
158
mlir::Type fir::AllocaOp::getAllocatedType () {
164
159
return getType ().cast <ReferenceType>().getEleTy ();
165
160
}
@@ -169,35 +164,35 @@ mlir::Type fir::AllocaOp::getRefTy(mlir::Type ty) {
169
164
}
170
165
171
166
void fir::AllocaOp::build (mlir::OpBuilder &builder,
172
- mlir::OperationState &result, mlir::Type in_type ,
173
- llvm::StringRef uniq_name ,
174
- mlir::ValueRange typeparams, mlir::ValueRange shape,
167
+ mlir::OperationState &result, mlir::Type inType ,
168
+ llvm::StringRef uniqName, mlir::ValueRange typeparams ,
169
+ mlir::ValueRange shape,
175
170
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
176
- auto nameAttr = builder.getStringAttr (uniq_name );
177
- build (builder, result, wrapAllocaResultType (in_type ), in_type , nameAttr, {},
171
+ auto nameAttr = builder.getStringAttr (uniqName );
172
+ build (builder, result, wrapAllocaResultType (inType ), inType , nameAttr, {},
178
173
typeparams, shape);
179
174
result.addAttributes (attributes);
180
175
}
181
176
182
177
void fir::AllocaOp::build (mlir::OpBuilder &builder,
183
- mlir::OperationState &result, mlir::Type in_type ,
184
- llvm::StringRef uniq_name , llvm::StringRef bindc_name ,
178
+ mlir::OperationState &result, mlir::Type inType ,
179
+ llvm::StringRef uniqName , llvm::StringRef bindcName ,
185
180
mlir::ValueRange typeparams, mlir::ValueRange shape,
186
181
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
187
182
auto nameAttr =
188
- uniq_name .empty () ? mlir::StringAttr{} : builder.getStringAttr (uniq_name );
189
- auto bindcAttr = bindc_name. empty () ? mlir::StringAttr{}
190
- : builder.getStringAttr (bindc_name );
191
- build (builder, result, wrapAllocaResultType (in_type ), in_type , nameAttr,
183
+ uniqName .empty () ? mlir::StringAttr{} : builder.getStringAttr (uniqName );
184
+ auto bindcAttr =
185
+ bindcName. empty () ? mlir::StringAttr{} : builder.getStringAttr (bindcName );
186
+ build (builder, result, wrapAllocaResultType (inType ), inType , nameAttr,
192
187
bindcAttr, typeparams, shape);
193
188
result.addAttributes (attributes);
194
189
}
195
190
196
191
void fir::AllocaOp::build (mlir::OpBuilder &builder,
197
- mlir::OperationState &result, mlir::Type in_type ,
192
+ mlir::OperationState &result, mlir::Type inType ,
198
193
mlir::ValueRange typeparams, mlir::ValueRange shape,
199
194
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
200
- build (builder, result, wrapAllocaResultType (in_type ), in_type , {}, {},
195
+ build (builder, result, wrapAllocaResultType (inType ), inType , {}, {},
201
196
typeparams, shape);
202
197
result.addAttributes (attributes);
203
198
}
@@ -231,15 +226,6 @@ static mlir::Type wrapAllocMemResultType(mlir::Type intype) {
231
226
return HeapType::get (intype);
232
227
}
233
228
234
- static mlir::ParseResult parseAllocMem (mlir::OpAsmParser &parser,
235
- mlir::OperationState &result) {
236
- return parseAllocatableOp (wrapAllocMemResultType, parser, result);
237
- }
238
-
239
- static void printAllocMem (mlir::OpAsmPrinter &p, fir::AllocMemOp &op) {
240
- printAllocatableOp (p, op);
241
- }
242
-
243
229
mlir::Type fir::AllocMemOp::getAllocatedType () {
244
230
return getType ().cast <HeapType>().getEleTy ();
245
231
}
@@ -249,34 +235,34 @@ mlir::Type fir::AllocMemOp::getRefTy(mlir::Type ty) {
249
235
}
250
236
251
237
void fir::AllocMemOp::build (mlir::OpBuilder &builder,
252
- mlir::OperationState &result, mlir::Type in_type ,
253
- llvm::StringRef uniq_name ,
238
+ mlir::OperationState &result, mlir::Type inType ,
239
+ llvm::StringRef uniqName ,
254
240
mlir::ValueRange typeparams, mlir::ValueRange shape,
255
241
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
256
- auto nameAttr = builder.getStringAttr (uniq_name );
257
- build (builder, result, wrapAllocMemResultType (in_type ), in_type , nameAttr, {},
242
+ auto nameAttr = builder.getStringAttr (uniqName );
243
+ build (builder, result, wrapAllocMemResultType (inType ), inType , nameAttr, {},
258
244
typeparams, shape);
259
245
result.addAttributes (attributes);
260
246
}
261
247
262
248
void fir::AllocMemOp::build (mlir::OpBuilder &builder,
263
- mlir::OperationState &result, mlir::Type in_type ,
264
- llvm::StringRef uniq_name ,
265
- llvm::StringRef bindc_name ,
249
+ mlir::OperationState &result, mlir::Type inType ,
250
+ llvm::StringRef uniqName ,
251
+ llvm::StringRef bindcName ,
266
252
mlir::ValueRange typeparams, mlir::ValueRange shape,
267
253
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
268
- auto nameAttr = builder.getStringAttr (uniq_name );
269
- auto bindcAttr = builder.getStringAttr (bindc_name );
270
- build (builder, result, wrapAllocMemResultType (in_type ), in_type , nameAttr,
254
+ auto nameAttr = builder.getStringAttr (uniqName );
255
+ auto bindcAttr = builder.getStringAttr (bindcName );
256
+ build (builder, result, wrapAllocMemResultType (inType ), inType , nameAttr,
271
257
bindcAttr, typeparams, shape);
272
258
result.addAttributes (attributes);
273
259
}
274
260
275
261
void fir::AllocMemOp::build (mlir::OpBuilder &builder,
276
- mlir::OperationState &result, mlir::Type in_type ,
262
+ mlir::OperationState &result, mlir::Type inType ,
277
263
mlir::ValueRange typeparams, mlir::ValueRange shape,
278
264
llvm::ArrayRef<mlir::NamedAttribute> attributes) {
279
- build (builder, result, wrapAllocMemResultType (in_type ), in_type , {}, {},
265
+ build (builder, result, wrapAllocMemResultType (inType ), inType , {}, {},
280
266
typeparams, shape);
281
267
result.addAttributes (attributes);
282
268
}
0 commit comments