File tree Expand file tree Collapse file tree 3 files changed +12
-15
lines changed
include/mlir/Dialect/EmitC/IR Expand file tree Collapse file tree 3 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -1267,8 +1267,7 @@ def EmitC_GetGlobalOp : EmitC_Op<"get_global",
1267
1267
}];
1268
1268
1269
1269
let arguments = (ins FlatSymbolRefAttr:$name);
1270
- let results = (outs AnyTypeOf<[EmitC_ArrayType, EmitC_LValueType,
1271
- EmitC_PointerType]>:$result);
1270
+ let results = (outs AnyTypeOf<[EmitC_ArrayType, EmitC_LValueType]>:$result);
1272
1271
let assemblyFormat = "$name `:` type($result) attr-dict";
1273
1272
}
1274
1273
@@ -1687,8 +1686,7 @@ def EmitC_GetFieldOp
1687
1686
}];
1688
1687
1689
1688
let arguments = (ins FlatSymbolRefAttr:$field_name);
1690
- let results = (outs AnyTypeOf<[EmitC_ArrayType, EmitC_LValueType,
1691
- EmitC_PointerType]>:$result);
1689
+ let results = (outs AnyTypeOf<[EmitC_ArrayType, EmitC_LValueType]>:$result);
1692
1690
let assemblyFormat = "$field_name `:` type($result) attr-dict";
1693
1691
}
1694
1692
Original file line number Diff line number Diff line change @@ -152,13 +152,21 @@ struct ConvertGetGlobal final
152
152
153
153
MemRefType opTy = op.getType ();
154
154
Type resultTy = convertMemRefType (opTy, getTypeConverter ());
155
- if (opTy.getRank () == 0 )
156
- resultTy = emitc::PointerType::get (resultTy);
157
155
158
156
if (!resultTy) {
159
157
return rewriter.notifyMatchFailure (op.getLoc (),
160
158
" cannot convert result type" );
161
159
}
160
+
161
+ if (opTy.getRank () == 0 ) {
162
+ auto lvalueType = emitc::LValueType::get (resultTy);
163
+ auto globalLValue = rewriter.create <emitc::GetGlobalOp>(
164
+ op.getLoc (), lvalueType, operands.getNameAttr ());
165
+ auto pointerType = emitc::PointerType::get (resultTy);
166
+ rewriter.replaceOpWithNewOp <emitc::ApplyOp>(
167
+ op, pointerType, rewriter.getStringAttr (" &" ), globalLValue);
168
+ return success ();
169
+ }
162
170
rewriter.replaceOpWithNewOp <emitc::GetGlobalOp>(op, resultTy,
163
171
operands.getNameAttr ());
164
172
return success ();
Original file line number Diff line number Diff line change @@ -1248,15 +1248,6 @@ GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
1248
1248
}
1249
1249
1250
1250
// global has non-array type
1251
- if (auto pointerType = llvm::dyn_cast<PointerType>(resultType)) {
1252
- if (pointerType.getPointee () != globalType) {
1253
- return emitOpError (" on pointer type expects result pointee type " )
1254
- << pointerType.getPointee () << " to match type " << globalType
1255
- << " of the global @" << getName ();
1256
- }
1257
- return success ();
1258
- }
1259
-
1260
1251
auto lvalueType = dyn_cast<LValueType>(resultType);
1261
1252
if (!lvalueType || lvalueType.getValueType () != globalType)
1262
1253
return emitOpError (" on non-array type expects result inner type " )
You can’t perform that action at this time.
0 commit comments