@@ -69,12 +69,12 @@ void useUnnamedStructTypes(Builder &b) {
69
69
StructType *t2 = StructType::create ({b.getInt32Ty (), b.getInt32Ty ()}, " " );
70
70
StructType *t3 = StructType::create ({b.getInt64Ty ()}, " " );
71
71
72
- Value *z1 = b.create <xd::ReadOp>(t1);
73
- Value *z2 = b.create <xd::ReadOp>(t2);
74
- Value *z3 = b.create <xd::ReadOp>(t3);
75
- b.create <xd::WriteOp>(z1);
76
- b.create <xd::WriteOp>(z2);
77
- b.create <xd::WriteOp>(z3);
72
+ Value *z1 = b.create <xd::cpp:: ReadOp>(t1);
73
+ Value *z2 = b.create <xd::cpp:: ReadOp>(t2);
74
+ Value *z3 = b.create <xd::cpp:: ReadOp>(t3);
75
+ b.create <xd::cpp:: WriteOp>(z1);
76
+ b.create <xd::cpp:: WriteOp>(z2);
77
+ b.create <xd::cpp:: WriteOp>(z3);
78
78
}
79
79
80
80
void createFunctionExample (Module &module , const Twine &name) {
@@ -86,47 +86,47 @@ void createFunctionExample(Module &module, const Twine &name) {
86
86
BasicBlock *bb = BasicBlock::Create (module .getContext (), " entry" , fn);
87
87
b.SetInsertPoint (bb);
88
88
89
- Value *x1 = b.create <xd::ReadOp>(b.getInt32Ty ());
90
- Value *sizeOf = b.create <xd::SizeOfOp>(b.getHalfTy ());
91
- Value *sizeOf32 = b.create <xd::ITruncOp>(b.getInt32Ty (), sizeOf);
92
- Value *x2 = b.create <xd::Add32Op>(x1, sizeOf32, 11 );
93
- Value *x3 = b.create <xd::CombineOp>(x2, x1);
94
- Value *x4 = b.create <xd::IExtOp>(b.getInt64Ty (), x3);
95
- b.create <xd::WriteOp>(x4);
96
-
97
- cast<xd::SizeOfOp>(sizeOf)->setSizeofType (b.getDoubleTy ());
98
- cast<xd::Add32Op>(x2)->setExtra (7 );
99
-
100
- Value *q1 = b.create <xd::ReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
101
- Value *q2 = b.create <xd::FromFixedVectorOp>(
102
- xd::XdVectorType::get (xd::VectorKind::BigEndian, b.getInt32Ty (), 2 ), q1);
103
-
104
- Value *y1 = b.create <xd::ReadOp>(
105
- xd::XdVectorType::get (xd::VectorKind::BigEndian, b.getInt32Ty (), 4 ));
106
- Value *y2 = b.create <xd::ExtractElementOp>(y1, x1);
107
- Value *y3 = b.create <xd::ExtractElementOp>(y1, b.getInt32 (2 ));
89
+ Value *x1 = b.create <xd::cpp:: ReadOp>(b.getInt32Ty ());
90
+ Value *sizeOf = b.create <xd::cpp:: SizeOfOp>(b.getHalfTy ());
91
+ Value *sizeOf32 = b.create <xd::cpp:: ITruncOp>(b.getInt32Ty (), sizeOf);
92
+ Value *x2 = b.create <xd::cpp:: Add32Op>(x1, sizeOf32, 11 );
93
+ Value *x3 = b.create <xd::cpp:: CombineOp>(x2, x1);
94
+ Value *x4 = b.create <xd::cpp:: IExtOp>(b.getInt64Ty (), x3);
95
+ b.create <xd::cpp:: WriteOp>(x4);
96
+
97
+ cast<xd::cpp:: SizeOfOp>(sizeOf)->setSizeofType (b.getDoubleTy ());
98
+ cast<xd::cpp:: Add32Op>(x2)->setExtra (7 );
99
+
100
+ Value *q1 = b.create <xd::cpp:: ReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
101
+ Value *q2 = b.create <xd::cpp:: FromFixedVectorOp>(
102
+ xd::cpp:: XdVectorType::get (xd::cpp ::VectorKind::BigEndian, b.getInt32Ty (), 2 ), q1);
103
+
104
+ Value *y1 = b.create <xd::cpp:: ReadOp>(
105
+ xd::cpp:: XdVectorType::get (xd::cpp ::VectorKind::BigEndian, b.getInt32Ty (), 4 ));
106
+ Value *y2 = b.create <xd::cpp:: ExtractElementOp>(y1, x1);
107
+ Value *y3 = b.create <xd::cpp:: ExtractElementOp>(y1, b.getInt32 (2 ));
108
108
Value *y4 = b.CreateAdd (y2, y3);
109
- Value *y5 = b.create <xd::InsertElementOp>(q2, y4, x1);
110
- auto *y6 = b.create <xd::InsertElementOp>(y5, y2, b.getInt32 (5 ));
111
- b.create <xd::WriteOp>(y6);
109
+ Value *y5 = b.create <xd::cpp:: InsertElementOp>(q2, y4, x1);
110
+ auto *y6 = b.create <xd::cpp:: InsertElementOp>(y5, y2, b.getInt32 (5 ));
111
+ b.create <xd::cpp:: WriteOp>(y6);
112
112
113
113
y6->setIndex (b.getInt32 (1 ));
114
114
115
- Value *p1 = b.create <xd::ReadOp>(b.getPtrTy (0 ));
115
+ Value *p1 = b.create <xd::cpp:: ReadOp>(b.getPtrTy (0 ));
116
116
p1->setName (" p1" );
117
- Value *p2 = b.create <xd::StreamAddOp>(p1, b.getInt64 (14 ), b.getInt8 (0 ));
117
+ Value *p2 = b.create <xd::cpp:: StreamAddOp>(p1, b.getInt64 (14 ), b.getInt8 (0 ));
118
118
p2->setName (" p2" );
119
- b.create <xd::WriteOp>(p2);
119
+ b.create <xd::cpp:: WriteOp>(p2);
120
120
121
- assert (xd::ExampleDialect::isDialectOp (*cast<CallInst>(p2)));
121
+ assert (xd::cpp:: ExampleDialect::isDialectOp (*cast<CallInst>(p2)));
122
122
123
123
SmallVector<Value *> varArgs;
124
124
varArgs.push_back (p1);
125
125
varArgs.push_back (p2);
126
- b.create <xd::WriteVarArgOp>(p2, varArgs);
127
- b.create <xd::HandleGetOp>();
126
+ b.create <xd::cpp:: WriteVarArgOp>(p2, varArgs);
127
+ b.create <xd::cpp:: HandleGetOp>();
128
128
129
- auto *replaceable = b.create <xd::WriteVarArgOp>(p2, varArgs);
129
+ auto *replaceable = b.create <xd::cpp:: WriteVarArgOp>(p2, varArgs);
130
130
SmallVector<Metadata *, 1 > MD;
131
131
MD.push_back (ConstantAsMetadata::get (
132
132
ConstantInt::get (Type::getInt32Ty (bb->getContext ()), 1 )));
@@ -136,25 +136,25 @@ void createFunctionExample(Module &module, const Twine &name) {
136
136
varArgs2.push_back (p2);
137
137
138
138
replaceable->replaceArgs (varArgs2);
139
- b.create <xd::SetReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
140
- b.create <xd::SetWriteOp>(y6);
139
+ b.create <xd::cpp:: SetReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
140
+ b.create <xd::cpp:: SetWriteOp>(y6);
141
141
142
142
useUnnamedStructTypes (b);
143
143
144
- b.create <xd::HandleGetOp>(" name.of.llvm.value" );
145
- b.create <xd::InstNameConflictOp>(b.getInt32 (1 ));
146
- b.create <xd::InstNameConflictOp>(b.getInt32 (1 ), " name.foo" );
147
- b.create <xd::InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ));
148
- b.create <xd::InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ), " bar" );
144
+ b.create <xd::cpp:: HandleGetOp>(" name.of.llvm.value" );
145
+ b.create <xd::cpp:: InstNameConflictOp>(b.getInt32 (1 ));
146
+ b.create <xd::cpp:: InstNameConflictOp>(b.getInt32 (1 ), " name.foo" );
147
+ b.create <xd::cpp:: InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ));
148
+ b.create <xd::cpp:: InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ), " bar" );
149
149
SmallVector<Value *> moreVarArgs = varArgs;
150
- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs);
151
- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs, " two.varargs" );
150
+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs);
151
+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs, " two.varargs" );
152
152
moreVarArgs.push_back (b.getInt32 (3 ));
153
- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs, " three.varargs" );
153
+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs, " three.varargs" );
154
154
moreVarArgs.push_back (b.getInt32 (4 ));
155
- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs, " four.varargs" );
155
+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs, " four.varargs" );
156
156
157
- b.create <xd::StringAttrOp>(" Hello world!" );
157
+ b.create <xd::cpp:: StringAttrOp>(" Hello world!" );
158
158
159
159
b.CreateRetVoid ();
160
160
}
@@ -210,20 +210,20 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
210
210
static const auto visitor =
211
211
VisitorBuilder<VisitorContainer>()
212
212
.nest <VisitorNest>([](VisitorBuilder<VisitorNest> &b) {
213
- b.add <xd::ReadOp>([](VisitorNest &self, xd::ReadOp &op) {
213
+ b.add <xd::cpp:: ReadOp>([](VisitorNest &self, xd::cpp ::ReadOp &op) {
214
214
*self.out << " visiting ReadOp: " << op << ' \n ' ;
215
215
});
216
216
b.add (&VisitorNest::visitUnaryInstruction);
217
- b.add <xd::SetReadOp>([](VisitorNest &self, xd::SetReadOp &op) {
217
+ b.add <xd::cpp:: SetReadOp>([](VisitorNest &self, xd::cpp ::SetReadOp &op) {
218
218
*self.out << " visiting SetReadOp: " << op << ' \n ' ;
219
219
return op.getType ()->isIntegerTy (1 ) ? VisitorResult::Stop
220
220
: VisitorResult::Continue;
221
221
});
222
- b.addSet <xd::SetReadOp, xd::SetWriteOp>(
222
+ b.addSet <xd::cpp:: SetReadOp, xd::cpp ::SetWriteOp>(
223
223
[](VisitorNest &self, llvm::Instruction &op) {
224
- if (isa<xd::SetReadOp>(op)) {
224
+ if (isa<xd::cpp:: SetReadOp>(op)) {
225
225
*self.out << " visiting SetReadOp (set): " << op << ' \n ' ;
226
- } else if (isa<xd::SetWriteOp>(op)) {
226
+ } else if (isa<xd::cpp:: SetWriteOp>(op)) {
227
227
*self.out << " visiting SetWriteOp (set): " << op << ' \n ' ;
228
228
}
229
229
});
@@ -248,17 +248,17 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
248
248
});
249
249
b.add (&VisitorNest::visitBinaryOperator);
250
250
b.nest <raw_ostream>([](VisitorBuilder<raw_ostream> &b) {
251
- b.add <xd::WriteOp>([](raw_ostream &out, xd::WriteOp &op) {
251
+ b.add <xd::cpp:: WriteOp>([](raw_ostream &out, xd::cpp ::WriteOp &op) {
252
252
out << " visiting WriteOp: " << op << ' \n ' ;
253
253
});
254
- b.add <xd::WriteVarArgOp>(
255
- [](raw_ostream &out, xd::WriteVarArgOp &op) {
254
+ b.add <xd::cpp:: WriteVarArgOp>(
255
+ [](raw_ostream &out, xd::cpp:: WriteVarArgOp &op) {
256
256
out << " visiting WriteVarArgOp: " << op << " :\n " ;
257
257
for (Value *arg : op.getArgs ())
258
258
out << " " << *arg << ' \n ' ;
259
259
});
260
- b.add <xd::StringAttrOp>(
261
- [](raw_ostream &out, xd::StringAttrOp &op) {
260
+ b.add <xd::cpp:: StringAttrOp>(
261
+ [](raw_ostream &out, xd::cpp:: StringAttrOp &op) {
262
262
out << " visiting StringAttrOp: " << op.getVal () << ' \n ' ;
263
263
});
264
264
b.add <ReturnInst>([](raw_ostream &out, ReturnInst &ret) {
@@ -270,8 +270,8 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
270
270
});
271
271
});
272
272
b.nest <VisitorInnermost>([](VisitorBuilder<VisitorInnermost> &b) {
273
- b.add <xd::ITruncOp>([](VisitorInnermost &inner,
274
- xd::ITruncOp &op) { inner.counter ++; });
273
+ b.add <xd::cpp:: ITruncOp>([](VisitorInnermost &inner,
274
+ xd::cpp:: ITruncOp &op) { inner.counter ++; });
275
275
});
276
276
})
277
277
.setStrategy (rpot ? VisitorStrategy::ReversePostOrder
@@ -295,7 +295,7 @@ int main(int argc, char **argv) {
295
295
llvm::cl::ParseCommandLineOptions (argc, argv);
296
296
297
297
LLVMContext context;
298
- auto dialectContext = DialectContext::make<xd::ExampleDialect>(context);
298
+ auto dialectContext = DialectContext::make<xd::cpp:: ExampleDialect>(context);
299
299
300
300
if (g_action == Action::Build) {
301
301
auto module = createModuleExample (context);
0 commit comments