Skip to content

Commit 63812c9

Browse files
Modified the Alloca/Global-Op/Copy ops for pointer-array type and Test files
Signed-off-by: LekkalaSravya3 <[email protected]>
1 parent a76c5a4 commit 63812c9

File tree

9 files changed

+171
-119
lines changed

9 files changed

+171
-119
lines changed

mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitC.cpp

Lines changed: 98 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct ConvertAlloca final : public OpConversionPattern<memref::AllocaOp> {
6767
LogicalResult
6868
matchAndRewrite(memref::AllocaOp op, OpAdaptor operands,
6969
ConversionPatternRewriter &rewriter) const override {
70-
70+
auto memRefType = op.getType();
7171
if (!op.getType().hasStaticShape()) {
7272
return rewriter.notifyMatchFailure(
7373
op.getLoc(), "cannot transform alloca with dynamic shape");
@@ -80,12 +80,48 @@ struct ConvertAlloca final : public OpConversionPattern<memref::AllocaOp> {
8080
op.getLoc(), "cannot transform alloca with alignment requirement");
8181
}
8282

83-
auto resultTy = getTypeConverter()->convertType(op.getType());
84-
if (!resultTy) {
85-
return rewriter.notifyMatchFailure(op.getLoc(), "cannot convert type");
83+
if (op.getType().getRank() == 0 ||
84+
llvm::is_contained(memRefType.getShape(), 0)) {
85+
return rewriter.notifyMatchFailure(
86+
op.getLoc(), "cannot transform alloca with rank 0 or zero-sized dim");
8687
}
88+
89+
auto convertedTy = getTypeConverter()->convertType(memRefType);
90+
if (!convertedTy) {
91+
return rewriter.notifyMatchFailure(op.getLoc(),
92+
"cannot convert memref type");
93+
}
94+
95+
auto arrayTy = emitc::ArrayType::get(memRefType.getShape(),
96+
memRefType.getElementType());
97+
auto elemTy = memRefType.getElementType();
98+
8799
auto noInit = emitc::OpaqueAttr::get(getContext(), "");
88-
rewriter.replaceOpWithNewOp<emitc::VariableOp>(op, resultTy, noInit);
100+
auto arrayVar =
101+
rewriter.create<emitc::VariableOp>(op.getLoc(), arrayTy, noInit);
102+
103+
// Build zero indices for the base subscript.
104+
SmallVector<Value> indices;
105+
for (unsigned i = 0; i < memRefType.getRank(); ++i) {
106+
auto zero = rewriter.create<emitc::ConstantOp>(
107+
op.getLoc(), rewriter.getIndexType(), rewriter.getIndexAttr(0));
108+
indices.push_back(zero);
109+
}
110+
111+
auto current = rewriter.create<emitc::SubscriptOp>(
112+
op.getLoc(), emitc::LValueType::get(elemTy), arrayVar.getResult(),
113+
indices);
114+
115+
auto ptrElemTy = emitc::PointerType::get(elemTy);
116+
auto addrOf = rewriter.create<emitc::ApplyOp>(op.getLoc(), ptrElemTy,
117+
rewriter.getStringAttr("&"),
118+
current.getResult());
119+
120+
auto ptrArrayTy = emitc::PointerType::get(arrayTy);
121+
auto casted = rewriter.create<emitc::CastOp>(op.getLoc(), ptrArrayTy,
122+
addrOf.getResult());
123+
124+
rewriter.replaceOp(op, casted.getResult());
89125
return success();
90126
}
91127
};
@@ -122,24 +158,6 @@ static Value calculateMemrefTotalSizeBytes(Location loc, MemRefType memrefType,
122158
return totalSizeBytes.getResult();
123159
}
124160

125-
static emitc::ApplyOp
126-
createPointerFromEmitcArray(Location loc, OpBuilder &builder,
127-
TypedValue<emitc::ArrayType> arrayValue) {
128-
129-
emitc::ConstantOp zeroIndex = emitc::ConstantOp::create(
130-
builder, loc, builder.getIndexType(), builder.getIndexAttr(0));
131-
132-
emitc::ArrayType arrayType = arrayValue.getType();
133-
llvm::SmallVector<mlir::Value> indices(arrayType.getRank(), zeroIndex);
134-
emitc::SubscriptOp subPtr =
135-
emitc::SubscriptOp::create(builder, loc, arrayValue, ValueRange(indices));
136-
emitc::ApplyOp ptr = emitc::ApplyOp::create(
137-
builder, loc, emitc::PointerType::get(arrayType.getElementType()),
138-
builder.getStringAttr("&"), subPtr);
139-
140-
return ptr;
141-
}
142-
143161
struct ConvertAlloc final : public OpConversionPattern<memref::AllocOp> {
144162
using OpConversionPattern::OpConversionPattern;
145163
LogicalResult
@@ -224,20 +242,10 @@ struct ConvertCopy final : public OpConversionPattern<memref::CopyOp> {
224242
return rewriter.notifyMatchFailure(
225243
loc, "incompatible target memref type for EmitC conversion");
226244

227-
auto srcArrayValue =
228-
cast<TypedValue<emitc::ArrayType>>(operands.getSource());
229-
emitc::ApplyOp srcPtr =
230-
createPointerFromEmitcArray(loc, rewriter, srcArrayValue);
231-
232-
auto targetArrayValue =
233-
cast<TypedValue<emitc::ArrayType>>(operands.getTarget());
234-
emitc::ApplyOp targetPtr =
235-
createPointerFromEmitcArray(loc, rewriter, targetArrayValue);
236-
237245
emitc::CallOpaqueOp memCpyCall = emitc::CallOpaqueOp::create(
238246
rewriter, loc, TypeRange{}, "memcpy",
239247
ValueRange{
240-
targetPtr.getResult(), srcPtr.getResult(),
248+
operands.getTarget(), operands.getSource(),
241249
calculateMemrefTotalSizeBytes(loc, srcMemrefType, rewriter)});
242250

243251
rewriter.replaceOp(copyOp, memCpyCall.getResults());
@@ -265,11 +273,14 @@ struct ConvertGlobal final : public OpConversionPattern<memref::GlobalOp> {
265273
"currently not supported");
266274
}
267275

268-
Type resultTy = convertMemRefType(opTy, getTypeConverter());
269-
270-
if (!resultTy) {
271-
return rewriter.notifyMatchFailure(op.getLoc(),
272-
"cannot convert result type");
276+
Type elemTy = getTypeConverter()->convertType(opTy.getElementType());
277+
Type globalType;
278+
if (opTy.getRank() == 0) {
279+
globalType = elemTy;
280+
} else {
281+
SmallVector<int64_t> shape(opTy.getShape().begin(),
282+
opTy.getShape().end());
283+
globalType = emitc::ArrayType::get(shape, elemTy);
273284
}
274285

275286
SymbolTable::Visibility visibility = SymbolTable::getSymbolVisibility(op);
@@ -293,7 +304,7 @@ struct ConvertGlobal final : public OpConversionPattern<memref::GlobalOp> {
293304
initialValue = {};
294305

295306
rewriter.replaceOpWithNewOp<emitc::GlobalOp>(
296-
op, operands.getSymName(), resultTy, initialValue, externSpecifier,
307+
op, operands.getSymName(), globalType, initialValue, externSpecifier,
297308
staticSpecifier, operands.getConstant());
298309
return success();
299310
}
@@ -308,24 +319,64 @@ struct ConvertGetGlobal final
308319
ConversionPatternRewriter &rewriter) const override {
309320

310321
MemRefType opTy = op.getType();
322+
Location loc = op.getLoc();
323+
324+
Type elemTy = getTypeConverter()->convertType(opTy.getElementType());
325+
if (!elemTy)
326+
return rewriter.notifyMatchFailure(loc, "cannot convert element type");
327+
311328
Type resultTy = convertMemRefType(opTy, getTypeConverter());
312329

313330
if (!resultTy) {
314331
return rewriter.notifyMatchFailure(op.getLoc(),
315332
"cannot convert result type");
316-
}
333+
334+
Type globalType;
335+
if (opTy.getRank() == 0) {
336+
globalType = elemTy;
337+
} else {
338+
SmallVector<int64_t> shape(opTy.getShape().begin(),
339+
opTy.getShape().end());
340+
globalType = emitc::ArrayType::get(shape, elemTy);
341+
}
317342

318343
if (opTy.getRank() == 0) {
319-
emitc::LValueType lvalueType = emitc::LValueType::get(resultTy);
344+
emitc::LValueType lvalueType = emitc::LValueType::get(globalType);
320345
emitc::GetGlobalOp globalLValue = emitc::GetGlobalOp::create(
321346
rewriter, op.getLoc(), lvalueType, operands.getNameAttr());
322-
emitc::PointerType pointerType = emitc::PointerType::get(resultTy);
323-
rewriter.replaceOpWithNewOp<emitc::ApplyOp>(
324-
op, pointerType, rewriter.getStringAttr("&"), globalLValue);
347+
emitc::PointerType pointerType = emitc::PointerType::get(globalType);
348+
auto addrOf = rewriter.create<emitc::ApplyOp>(
349+
loc, ptrElemTy, rewriter.getStringAttr("&"), globalLVal.getResult());
350+
351+
auto arrayTy = emitc::ArrayType::get({1}, globalType);
352+
auto ptrArrayTy = emitc::PointerType::get(arrayTy);
353+
auto casted =
354+
rewriter.create<emitc::CastOp>(loc, ptrArrayTy, addrOf.getResult());
355+
rewriter.replaceOp(op, casted.getResult());
325356
return success();
326357
}
327-
rewriter.replaceOpWithNewOp<emitc::GetGlobalOp>(op, resultTy,
328-
operands.getNameAttr());
358+
359+
auto getGlobal = rewriter.create<emitc::GetGlobalOp>(
360+
loc, globalType, operands.getNameAttr());
361+
362+
SmallVector<Value> indices;
363+
for (unsigned i = 0; i < opTy.getRank(); ++i) {
364+
auto zero = rewriter.create<emitc::ConstantOp>(
365+
loc, rewriter.getIndexType(), rewriter.getIndexAttr(0));
366+
indices.push_back(zero);
367+
}
368+
369+
auto current = rewriter.create<emitc::SubscriptOp>(
370+
loc, emitc::LValueType::get(elemTy), getGlobal.getResult(), indices);
371+
372+
auto ptrElemTy = emitc::PointerType::get(opTy.getElementType());
373+
auto addrOf = rewriter.create<emitc::ApplyOp>(
374+
loc, ptrElemTy, rewriter.getStringAttr("&"), current.getResult());
375+
376+
auto casted =
377+
rewriter.create<emitc::CastOp>(loc, resultTy, addrOf.getResult());
378+
379+
rewriter.replaceOp(op, casted.getResult());
329380
return success();
330381
}
331382
};

mlir/lib/Target/Cpp/TranslateToCpp.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,16 +1366,25 @@ std::string CppEmitter::getApplyName(emitc::ApplyOp op) {
13661366
StringRef opStr = op.getApplicableOperator();
13671367
Value operand = op.getOperand();
13681368

1369-
// Handle dereference and address-of operators specially
1370-
if (opStr == "*") {
1371-
ss << "(*" << getOrCreateName(operand) << ")";
1372-
} else if (opStr == "&") {
1369+
if (opStr == "&") {
13731370
ss << "&" << getOrCreateName(operand);
1374-
} else {
1375-
// Generic operator form: operand followed by operator
1376-
ss << getOrCreateName(operand) << opStr;
1371+
return ss.str();
1372+
}
1373+
1374+
// Emit '*(&x)' form
1375+
if (opStr == "*") {
1376+
if (auto innerApply = operand.getDefiningOp<emitc::ApplyOp>()) {
1377+
StringRef innerOp = innerApply.getApplicableOperator();
1378+
if (innerOp == "&") {
1379+
ss << "*(&" << getOrCreateName(innerApply.getOperand()) << ")";
1380+
return ss.str();
1381+
}
1382+
}
1383+
ss << "*" << getOrCreateName(operand);
1384+
return ss.str();
13771385
}
13781386

1387+
ss << getOrCreateName(operand) << opStr;
13791388
return ss.str();
13801389
}
13811390

@@ -1829,6 +1838,9 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
18291838
return success();
18301839
})
18311840
.Case<emitc::ApplyOp>([&](emitc::ApplyOp op) {
1841+
if (emittedExpression) {
1842+
return printOperation(*this, op);
1843+
}
18321844
std::string expr = getApplyName(op);
18331845
cacheDeferredOpResult(op.getResult(), expr);
18341846
// If the result is unused, emit it as a standalone statement.

mlir/test/Conversion/ConvertToEmitC/tosa.mlir

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@
2020
// RUN: mlir-opt --pass-pipeline=%{pipeline} %s | FileCheck %s
2121
// -----
2222

23-
// CHECK: emitc.func private @main(%[[ARG0:.*]]: !emitc.array<2xf32>, %[[ARG1:.*]]: !emitc.array<2xf32>, %[[RES:.*]]: !emitc.array<2xf32>)
24-
// CHECK-DAG: %[[C0:.*]] = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
25-
// CHECK-DAG: %[[C1:.*]] = "emitc.constant"() <{value = 1 : index}> : () -> !emitc.size_t
26-
// CHECK-DAG: %[[C2:.*]] = "emitc.constant"() <{value = 2 : index}> : () -> !emitc.size_t
27-
// CHECK-NEXT: for %[[INDEX:.*]] = %[[C0]] to %[[C2]] step %[[C1]] : !emitc.size_t {
28-
// CHECK-NEXT: %[[V0_LVALUE:.*]] = subscript %[[ARG0]][%[[INDEX]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
29-
// CHECK-NEXT: %[[V0:.*]] = load %[[V0_LVALUE]] : <f32>
30-
// CHECK-NEXT: %[[V1_LVALUE:.*]] = subscript %[[ARG1]][%[[INDEX]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
31-
// CHECK-NEXT: %[[V1:.*]] = load %[[V1_LVALUE]] : <f32>
32-
// CHECK-NEXT: %[[VADD:.*]] = add %[[V0]], %[[V1]] : (f32, f32) -> f32
33-
// CHECK-NEXT: %[[RES_LVALUE:.*]] = subscript %[[RES]][%[[INDEX]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
34-
// CHECK-NEXT: assign %[[VADD]] : f32 to %[[RES_LVALUE]] : <f32>
35-
// CHECK-NEXT: }
36-
// CHECK-NEXT: return
37-
// CHECK-NEXT: }
23+
// CHECK: emitc.func private @main(%[[ARG0:.*]]: !emitc.ptr<!emitc.array<2xf32>>, %[[ARG1:.*]]: !emitc.ptr<!emitc.array<2xf32>>, %[[RES:.*]]: !emitc.ptr<!emitc.array<2xf32>>)
24+
// CHECK-DAG: [[VAR_0_:%.+]] = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
25+
// CHECK-DAG: [[VAR_1_:%.+]] = "emitc.constant"() <{value = 2 : index}> : () -> !emitc.size_t
26+
// CHECK-DAG: [[VAR_2_:%.+]] = "emitc.constant"() <{value = 1 : index}> : () -> !emitc.size_t
27+
// CHECK: for [[I_0_:%.+]] = [[VAR_0_]] to [[VAR_1_]] step [[VAR_2_]] : !emitc.size_t {
28+
// CHECK: [[VAR_3_:%.+]] = apply "*"(%[[ARG0]]) : (!emitc.ptr<!emitc.array<2xf32>>) -> !emitc.array<2xf32>
29+
// CHECK: [[VAR_4_:%.+]] = subscript [[VAR_3_]]{{.}}[[I_0_]]{{.}} : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
30+
// CHECK-DAG: [[LOAD_VAR_4_MEM_:%.+]] = load [[VAR_4_]] : <f32>
31+
// CHECK-DAG: [[VAR_6_:%.+]] = apply "*"(%[[ARG1]]) : (!emitc.ptr<!emitc.array<2xf32>>) -> !emitc.array<2xf32>
32+
// CHECK: [[VAR_7_:%.+]] = subscript [[VAR_6_]]{{.}}[[I_0_]]{{.}} : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
33+
// CHECK: [[LOAD_VAR_7_MEM_:%.+]] = load [[VAR_7_]] : <f32>
34+
// CHECK-DAG: [[VAR_9_:%.+]] = add [[LOAD_VAR_4_MEM_]], [[LOAD_VAR_7_MEM_]] : (f32, f32) -> f32
35+
// CHECK-DAG: [[VAR_10_:%.+]] = apply "*"(%[[RES]]) : (!emitc.ptr<!emitc.array<2xf32>>) -> !emitc.array<2xf32>
36+
// CHECK: [[VAR_11_:%.+]] = subscript [[VAR_10_]]{{.}}[[I_0_]]{{.}} : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
37+
// CHECK: assign [[VAR_9_]] : f32 to [[VAR_11_]] : <f32>
38+
// CHECK: }
39+
// CHECK: return
40+
// CHECK: }
3841
func.func private @main(%arg0: tensor<2xf32>, %arg1: tensor<2xf32>) -> tensor<2xf32> {
3942
%0 = tosa.add %arg0, %arg1 : (tensor<2xf32>, tensor<2xf32>) -> tensor<2xf32>
4043
return %0 : tensor<2xf32>

mlir/test/Conversion/MemRefToEmitC/memref-to-emitc-alloc-copy.mlir

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,18 @@ func.func @alloc_copy(%arg0: memref<999xi32>) {
2323
// CHECK-NEXT: "emitc.constant"() <{value = 999 : index}> : () -> index
2424
// CHECK-NEXT: emitc.mul %1, %2 : (!emitc.size_t, index) -> !emitc.size_t
2525
// CHECK-NEXT: emitc.call_opaque "malloc"(%3) : (!emitc.size_t) -> !emitc.ptr<!emitc.opaque<"void">>
26-
// CHECK-NEXT: emitc.cast %4 : !emitc.ptr<!emitc.opaque<"void">> to !emitc.ptr<i32>
27-
// CHECK-NEXT: builtin.unrealized_conversion_cast %5 : !emitc.ptr<i32> to !emitc.array<999xi32>
28-
// CHECK-NEXT: "emitc.constant"() <{value = 0 : index}> : () -> index
29-
// CHECK-NEXT: emitc.subscript %0[%7] : (!emitc.array<999xi32>, index) -> !emitc.lvalue<i32>
30-
// CHECK-NEXT: emitc.apply "&"(%8) : (!emitc.lvalue<i32>) -> !emitc.ptr<i32>
26+
// CHECK-NEXT: emitc.cast %4 : !emitc.ptr<!emitc.opaque<"void">> to !emitc.ptr<!emitc.array<999xi32>>
3127
// CHECK-NEXT: emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.size_t
3228
// CHECK-NEXT: "emitc.constant"() <{value = 999 : index}> : () -> index
33-
// CHECK-NEXT: emitc.mul %12, %13 : (!emitc.size_t, index) -> !emitc.size_t
34-
// CHECK-NEXT: emitc.call_opaque "memcpy"(%11, %9, %14) : (!emitc.ptr<i32>, !emitc.ptr<i32>, !emitc.size_t) -> ()
29+
// CHECK-NEXT: emitc.mul %6, %7 : (!emitc.size_t, index) -> !emitc.size_t
30+
// CHECK-NEXT: emitc.call_opaque "memcpy"(%5, %0, %8) : (!emitc.ptr<i32>, !emitc.ptr<i32>, !emitc.size_t) -> ()
3531
// CHECK-NEXT: emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.size_t
3632
// CHECK-NEXT: "emitc.constant"() <{value = 999 : index}> : () -> index
37-
// CHECK-NEXT: emitc.mul %15, %16 : (!emitc.size_t, index) -> !emitc.size_t
38-
// CHECK-NEXT: emitc.call_opaque "malloc"(%17) : (!emitc.size_t) -> !emitc.ptr<!emitc.opaque<"void">>
39-
// CHECK-NEXT: emitc.cast %18 : !emitc.ptr<!emitc.opaque<"void">> to !emitc.ptr<i32>
40-
// CHECK-NEXT: builtin.unrealized_conversion_cast %19 : !emitc.ptr<i32> to !emitc.array<999xi32>
41-
// CHECK-NEXT: "emitc.constant"() <{value = 0 : index}> : () -> index
42-
// CHECK-NEXT: emitc.subscript %0[%21] : (!emitc.array<999xi32>, index) -> !emitc.lvalue<i32>
43-
// CHECK-NEXT: emitc.apply "&"(%22) : (!emitc.lvalue<i32>) -> !emitc.ptr<i32>
44-
// CHECK-NEXT: emitc.subscript %20[%21] : (!emitc.array<999xi32>, index) -> !emitc.lvalue<i32>
45-
// CHECK-NEXT: emitc.apply "&"(%24) : (!emitc.lvalue<i32>) -> !emitc.ptr<i32>
33+
// CHECK-NEXT: emitc.mul %9, %10 : (!emitc.size_t, index) -> !emitc.size_t
34+
// CHECK-NEXT: emitc.call_opaque "malloc"(%11) : (!emitc.size_t) -> !emitc.ptr<!emitc.opaque<"void">>
35+
// CHECK-NEXT: emitc.cast %12 : !emitc.ptr<!emitc.opaque<"void">> to !emitc.ptr<!emitc.array<999xi32>>
4636
// CHECK-NEXT: emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.size_t
4737
// CHECK-NEXT: "emitc.constant"() <{value = 999 : index}> : () -> index
48-
// CHECK-NEXT: emitc.mul %26, %27 : (!emitc.size_t, index) -> !emitc.size_t
49-
// CHECK-NEXT: emitc.call_opaque "memcpy"(%25, %23, %28) : (!emitc.ptr<i32>, !emitc.ptr<i32>, !emitc.size_t) -> ()
38+
// CHECK-NEXT: emitc.mul %14, %15 : (!emitc.size_t, index) -> !emitc.size_t
39+
// CHECK-NEXT: emitc.call_opaque "memcpy"(%13, %0, %16) : (!emitc.ptr<i32>, !emitc.ptr<i32>, !emitc.size_t) -> ()
5040
// CHECK-NEXT: return

mlir/test/Conversion/MemRefToEmitC/memref-to-emitc-copy.mlir

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,12 @@ func.func @copying(%arg0 : memref<9x4x5x7xf32>, %arg1 : memref<9x4x5x7xf32>) {
1212

1313
// CHECK-LABEL: copying
1414
// CHECK-SAME: %[[arg0:.*]]: memref<9x4x5x7xf32>, %[[arg1:.*]]: memref<9x4x5x7xf32>
15-
// CHECK-NEXT: %0 = builtin.unrealized_conversion_cast %arg1 : memref<9x4x5x7xf32> to !emitc.array<9x4x5x7xf32>
16-
// CHECK-NEXT: %1 = builtin.unrealized_conversion_cast %arg0 : memref<9x4x5x7xf32> to !emitc.array<9x4x5x7xf32>
17-
// CHECK-NEXT: %2 = "emitc.constant"() <{value = 0 : index}> : () -> index
18-
// CHECK-NEXT: %3 = emitc.subscript %1[%2, %2, %2, %2] : (!emitc.array<9x4x5x7xf32>, index, index, index, index) -> !emitc.lvalue<f32>
19-
// CHECK-NEXT: %4 = emitc.apply "&"(%3) : (!emitc.lvalue<f32>) -> !emitc.ptr<f32>
20-
// CHECK-NEXT: %5 = emitc.subscript %0[%2, %2, %2, %2] : (!emitc.array<9x4x5x7xf32>, index, index, index, index) -> !emitc.lvalue<f32>
21-
// CHECK-NEXT: %6 = emitc.apply "&"(%5) : (!emitc.lvalue<f32>) -> !emitc.ptr<f32>
22-
// CHECK-NEXT: %7 = emitc.call_opaque "sizeof"() {args = [f32]} : () -> !emitc.size_t
23-
// CHECK-NEXT: %8 = "emitc.constant"() <{value = 1260 : index}> : () -> index
24-
// CHECK-NEXT: %9 = emitc.mul %7, %8 : (!emitc.size_t, index) -> !emitc.size_t
25-
// CHECK-NEXT: emitc.call_opaque "memcpy"(%6, %4, %9) : (!emitc.ptr<f32>, !emitc.ptr<f32>, !emitc.size_t) -> ()
15+
// CHECK-NEXT: %0 = builtin.unrealized_conversion_cast %arg1 : memref<9x4x5x7xf32> to !emitc.ptr<!emitc.array<9x4x5x7xf32>>
16+
// CHECK-NEXT: %1 = builtin.unrealized_conversion_cast %arg0 : memref<9x4x5x7xf32> to !emitc.ptr<!emitc.array<9x4x5x7xf32>>
17+
// CHECK-NEXT: %2 = emitc.call_opaque "sizeof"() {args = [f32]} : () -> !emitc.size_t
18+
// CHECK-NEXT: %3 = "emitc.constant"() <{value = 1260 : index}> : () -> index
19+
// CHECK-NEXT: %4 = emitc.mul %2, %3 : (!emitc.size_t, index) -> !emitc.size_t
20+
// CHECK-NEXT: emitc.call_opaque "memcpy"(%0, %1, %4) : (!emitc.ptr<!emitc.array<9x4x5x7xf32>>, !emitc.ptr<!emitc.array<9x4x5x7xf32>>, !emitc.size_t) -> ()
2621
// CHECK-NEXT: return
2722
// CHECK-NEXT: }
2823
// CHECK-NEXT:}

0 commit comments

Comments
 (0)