@@ -24,30 +24,27 @@ struct LoweringPreparePass : public LoweringPrepareBase<LoweringPreparePass> {
24
24
void runOnOperation () override ;
25
25
26
26
void runOnOp (Operation *op);
27
- void lowerArrayCtor (ArrayCtor op);
27
+ void lowerArrayCtor (cir:: ArrayCtor op);
28
28
};
29
29
30
30
} // namespace
31
31
32
- void LoweringPreparePass::runOnOp (Operation *op) {
32
+ void LoweringPreparePass::runOnOp (mlir:: Operation *op) {
33
33
if (auto arrayCtor = dyn_cast<ArrayCtor>(op)) {
34
34
lowerArrayCtor (arrayCtor);
35
35
}
36
36
}
37
37
38
- static void lowerArrayDtorCtorIntoLoop (CIRBaseBuilderTy &builder,
38
+ static void lowerArrayDtorCtorIntoLoop (cir:: CIRBaseBuilderTy &builder,
39
39
mlir::Operation *op, mlir::Type eltTy,
40
40
mlir::Value arrayAddr,
41
41
uint64_t arrayLen) {
42
42
// Generate loop to call into ctor/dtor for every element.
43
- Location loc = op->getLoc ();
43
+ mlir:: Location loc = op->getLoc ();
44
44
45
45
// TODO: instead of fixed integer size, create alias for PtrDiffTy and unify
46
46
// with CIRGen stuff.
47
- auto ptrDiffTy =
48
- cir::IntType::get (builder.getContext (), 64 , /* isSigned=*/ false );
49
- auto numArrayElementsConst = builder.create <cir::ConstantOp>(
50
- loc, ptrDiffTy, cir::IntAttr::get (ptrDiffTy, arrayLen));
47
+ cir::ConstantOp numArrayElementsConst = builder.getUnsignedInt (loc, 64 , arrayLen);
51
48
52
49
auto begin = builder.create <cir::CastOp>(
53
50
loc, eltTy, cir::CastKind::array_to_ptrdecay, arrayAddr);
@@ -73,8 +70,8 @@ static void lowerArrayDtorCtorIntoLoop(CIRBaseBuilderTy &builder,
73
70
[&](mlir::OpBuilder &b, mlir::Location loc) {
74
71
auto currentElement = b.create <cir::LoadOp>(loc, eltTy, tmpAddr);
75
72
76
- CallOp ctorCall;
77
- op->walk ([&](CallOp c) { ctorCall = c; });
73
+ cir:: CallOp ctorCall;
74
+ op->walk ([&](cir:: CallOp c) { ctorCall = c; });
78
75
assert (ctorCall && " expected ctor call" );
79
76
80
77
auto one = builder.create <cir::ConstantOp>(
@@ -94,23 +91,23 @@ static void lowerArrayDtorCtorIntoLoop(CIRBaseBuilderTy &builder,
94
91
op->erase ();
95
92
}
96
93
97
- void LoweringPreparePass::lowerArrayCtor (ArrayCtor op) {
98
- CIRBaseBuilderTy builder (getContext ());
94
+ void LoweringPreparePass::lowerArrayCtor (cir:: ArrayCtor op) {
95
+ cir:: CIRBaseBuilderTy builder (getContext ());
99
96
builder.setInsertionPointAfter (op.getOperation ());
100
97
101
- Type eltTy = op->getRegion (0 ).getArgument (0 ).getType ();
98
+ mlir:: Type eltTy = op->getRegion (0 ).getArgument (0 ).getType ();
102
99
auto arrayLen =
103
100
mlir::cast<cir::ArrayType>(op.getAddr ().getType ().getPointee ()).getSize ();
104
101
lowerArrayDtorCtorIntoLoop (builder, op, eltTy, op.getAddr (), arrayLen);
105
102
}
106
103
107
104
void LoweringPreparePass::runOnOperation () {
108
- Operation *op = getOperation ();
105
+ mlir:: Operation *op = getOperation ();
109
106
110
- llvm::SmallVector<Operation *> opsToTransform;
107
+ llvm::SmallVector<mlir:: Operation *> opsToTransform;
111
108
112
- op->walk ([&](Operation *op) {
113
- if (isa<ArrayCtor>(op)) {
109
+ op->walk ([&](mlir:: Operation *op) {
110
+ if (mlir:: isa<cir:: ArrayCtor>(op)) {
114
111
opsToTransform.push_back (op);
115
112
}
116
113
});
0 commit comments