@@ -69,12 +69,12 @@ void useUnnamedStructTypes(Builder &b) {
6969 StructType *t2 = StructType::create ({b.getInt32Ty (), b.getInt32Ty ()}, " " );
7070 StructType *t3 = StructType::create ({b.getInt64Ty ()}, " " );
7171
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);
7878}
7979
8080void createFunctionExample (Module &module , const Twine &name) {
@@ -86,47 +86,47 @@ void createFunctionExample(Module &module, const Twine &name) {
8686 BasicBlock *bb = BasicBlock::Create (module .getContext (), " entry" , fn);
8787 b.SetInsertPoint (bb);
8888
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 ));
108108 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);
112112
113113 y6->setIndex (b.getInt32 (1 ));
114114
115- Value *p1 = b.create <xd::ReadOp>(b.getPtrTy (0 ));
115+ Value *p1 = b.create <xd::cpp:: ReadOp>(b.getPtrTy (0 ));
116116 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 ));
118118 p2->setName (" p2" );
119- b.create <xd::WriteOp>(p2);
119+ b.create <xd::cpp:: WriteOp>(p2);
120120
121- assert (xd::ExampleDialect::isDialectOp (*cast<CallInst>(p2)));
121+ assert (xd::cpp:: ExampleDialect::isDialectOp (*cast<CallInst>(p2)));
122122
123123 SmallVector<Value *> varArgs;
124124 varArgs.push_back (p1);
125125 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>();
128128
129- auto *replaceable = b.create <xd::WriteVarArgOp>(p2, varArgs);
129+ auto *replaceable = b.create <xd::cpp:: WriteVarArgOp>(p2, varArgs);
130130 SmallVector<Metadata *, 1 > MD;
131131 MD.push_back (ConstantAsMetadata::get (
132132 ConstantInt::get (Type::getInt32Ty (bb->getContext ()), 1 )));
@@ -136,25 +136,25 @@ void createFunctionExample(Module &module, const Twine &name) {
136136 varArgs2.push_back (p2);
137137
138138 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);
141141
142142 useUnnamedStructTypes (b);
143143
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" );
149149 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" );
152152 moreVarArgs.push_back (b.getInt32 (3 ));
153- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs, " three.varargs" );
153+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs, " three.varargs" );
154154 moreVarArgs.push_back (b.getInt32 (4 ));
155- b.create <xd::InstNameConflictVarargsOp>(moreVarArgs, " four.varargs" );
155+ b.create <xd::cpp:: InstNameConflictVarargsOp>(moreVarArgs, " four.varargs" );
156156
157- b.create <xd::StringAttrOp>(" Hello world!" );
157+ b.create <xd::cpp:: StringAttrOp>(" Hello world!" );
158158
159159 b.CreateRetVoid ();
160160}
@@ -210,20 +210,20 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
210210 static const auto visitor =
211211 VisitorBuilder<VisitorContainer>()
212212 .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) {
214214 *self.out << " visiting ReadOp: " << op << ' \n ' ;
215215 });
216216 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) {
218218 *self.out << " visiting SetReadOp: " << op << ' \n ' ;
219219 return op.getType ()->isIntegerTy (1 ) ? VisitorResult::Stop
220220 : VisitorResult::Continue;
221221 });
222- b.addSet <xd::SetReadOp, xd::SetWriteOp>(
222+ b.addSet <xd::cpp:: SetReadOp, xd::cpp ::SetWriteOp>(
223223 [](VisitorNest &self, llvm::Instruction &op) {
224- if (isa<xd::SetReadOp>(op)) {
224+ if (isa<xd::cpp:: SetReadOp>(op)) {
225225 *self.out << " visiting SetReadOp (set): " << op << ' \n ' ;
226- } else if (isa<xd::SetWriteOp>(op)) {
226+ } else if (isa<xd::cpp:: SetWriteOp>(op)) {
227227 *self.out << " visiting SetWriteOp (set): " << op << ' \n ' ;
228228 }
229229 });
@@ -248,17 +248,17 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
248248 });
249249 b.add (&VisitorNest::visitBinaryOperator);
250250 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) {
252252 out << " visiting WriteOp: " << op << ' \n ' ;
253253 });
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) {
256256 out << " visiting WriteVarArgOp: " << op << " :\n " ;
257257 for (Value *arg : op.getArgs ())
258258 out << " " << *arg << ' \n ' ;
259259 });
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) {
262262 out << " visiting StringAttrOp: " << op.getVal () << ' \n ' ;
263263 });
264264 b.add <ReturnInst>([](raw_ostream &out, ReturnInst &ret) {
@@ -270,8 +270,8 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
270270 });
271271 });
272272 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 ++; });
275275 });
276276 })
277277 .setStrategy (rpot ? VisitorStrategy::ReversePostOrder
@@ -295,7 +295,7 @@ int main(int argc, char **argv) {
295295 llvm::cl::ParseCommandLineOptions (argc, argv);
296296
297297 LLVMContext context;
298- auto dialectContext = DialectContext::make<xd::ExampleDialect>(context);
298+ auto dialectContext = DialectContext::make<xd::cpp:: ExampleDialect>(context);
299299
300300 if (g_action == Action::Build) {
301301 auto module = createModuleExample (context);
0 commit comments