@@ -90,12 +90,15 @@ void createFunctionExample(Module &module, const Twine &name) {
9090 cast<xd::cpp::SizeOfOp>(sizeOf)->setSizeofType (b.getDoubleTy ());
9191 cast<xd::cpp::Add32Op>(x2)->setExtra (7 );
9292
93- Value *q1 = b.create <xd::cpp::ReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
93+ Value *q1 =
94+ b.create <xd::cpp::ReadOp>(FixedVectorType::get (b.getInt32Ty (), 2 ));
9495 Value *q2 = b.create <xd::cpp::FromFixedVectorOp>(
95- xd::cpp::XdVectorType::get (xd::cpp::VectorKind::BigEndian, b.getInt32Ty (), 2 ), q1);
96+ xd::cpp::XdVectorType::get (xd::cpp::VectorKind::BigEndian, b.getInt32Ty (),
97+ 2 ),
98+ q1);
9699
97- Value *y1 = b.create <xd::cpp::ReadOp>(
98- xd::cpp::XdVectorType::get (xd::cpp:: VectorKind::BigEndian, b.getInt32Ty (), 4 ));
100+ Value *y1 = b.create <xd::cpp::ReadOp>(xd::cpp::XdVectorType::get (
101+ xd::cpp::VectorKind::BigEndian, b.getInt32Ty (), 4 ));
99102 Value *y2 = b.create <xd::cpp::ExtractElementOp>(y1, x1);
100103 Value *y3 = b.create <xd::cpp::ExtractElementOp>(y1, b.getInt32 (2 ));
101104 Value *y4 = b.CreateAdd (y2, y3);
@@ -138,7 +141,8 @@ void createFunctionExample(Module &module, const Twine &name) {
138141 b.create <xd::cpp::InstNameConflictOp>(b.getInt32 (1 ));
139142 b.create <xd::cpp::InstNameConflictOp>(b.getInt32 (1 ), " name.foo" );
140143 b.create <xd::cpp::InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ));
141- b.create <xd::cpp::InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ), " bar" );
144+ b.create <xd::cpp::InstNameConflictDoubleOp>(b.getInt32 (1 ), b.getInt32 (2 ),
145+ " bar" );
142146 SmallVector<Value *> moreVarArgs = varArgs;
143147 b.create <xd::cpp::InstNameConflictVarargsOp>(moreVarArgs);
144148 b.create <xd::cpp::InstNameConflictVarargsOp>(moreVarArgs, " two.varargs" );
@@ -149,9 +153,12 @@ void createFunctionExample(Module &module, const Twine &name) {
149153
150154 b.create <xd::cpp::StringAttrOp>(" Hello world!" );
151155
152- xd::cpp::StructBackedType *structBackedTy = xd::cpp::StructBackedType::get (bb->getContext (), 1 , 0 , xd::cpp::VectorKind::BigEndian);
153- auto *structBackedVal = b.create <xd::cpp::DummyStructBackedOutpOp>(structBackedTy, b.getInt32 (42 ), " gen.struct.backed.val" );
154- b.create <xd::cpp::DummyStructBackedInpOp>(structBackedVal, " consume.struct.backed.val" );
156+ xd::cpp::StructBackedType *structBackedTy = xd::cpp::StructBackedType::get (
157+ bb->getContext (), 1 , 0 , xd::cpp::VectorKind::BigEndian);
158+ auto *structBackedVal = b.create <xd::cpp::DummyStructBackedOutpOp>(
159+ structBackedTy, b.getInt32 (42 ), " gen.struct.backed.val" );
160+ b.create <xd::cpp::DummyStructBackedInpOp>(structBackedVal,
161+ " consume.struct.backed.val" );
155162
156163 b.CreateRetVoid ();
157164}
@@ -173,6 +180,10 @@ struct VisitorNest {
173180 void visitBinaryOperator (BinaryOperator &inst) {
174181 *out << " visiting BinaryOperator: " << inst << ' \n ' ;
175182 }
183+ void visitInst (Instruction &inst) {
184+ *out << " visiting llvm instruction: " << inst << ' \n ' ;
185+ }
186+
176187 VisitorResult visitUnaryInstruction (UnaryInstruction &inst) {
177188 *out << " visiting UnaryInstruction (pre): " << inst << ' \n ' ;
178189 return isa<LoadInst>(inst) ? VisitorResult::Stop : VisitorResult::Continue;
@@ -211,11 +222,12 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
211222 *self.out << " visiting ReadOp: " << op << ' \n ' ;
212223 });
213224 b.add (&VisitorNest::visitUnaryInstruction);
214- b.add <xd::cpp::SetReadOp>([](VisitorNest &self, xd::cpp::SetReadOp &op) {
215- *self.out << " visiting SetReadOp: " << op << ' \n ' ;
216- return op.getType ()->isIntegerTy (1 ) ? VisitorResult::Stop
217- : VisitorResult::Continue;
218- });
225+ b.add <xd::cpp::SetReadOp>(
226+ [](VisitorNest &self, xd::cpp::SetReadOp &op) {
227+ *self.out << " visiting SetReadOp: " << op << ' \n ' ;
228+ return op.getType ()->isIntegerTy (1 ) ? VisitorResult::Stop
229+ : VisitorResult::Continue;
230+ });
219231 b.addSet <xd::cpp::SetReadOp, xd::cpp::SetWriteOp>(
220232 [](VisitorNest &self, llvm::Instruction &op) {
221233 if (isa<xd::cpp::SetReadOp>(op)) {
@@ -224,11 +236,13 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
224236 *self.out << " visiting SetWriteOp (set): " << op << ' \n ' ;
225237 }
226238 });
239+ b.addSet <xd::cpp::SetReadOp, xd::cpp::SetWriteOp>(
240+ &VisitorNest::visitInst);
227241 b.addSet (complexSet, [](VisitorNest &self, llvm::Instruction &op) {
228242 assert ((op.getOpcode () == Instruction::Ret ||
229243 (isa<IntrinsicInst>(&op) &&
230- cast<IntrinsicInst>(&op)->getIntrinsicID () ==
231- Intrinsic::umin)) &&
244+ cast<IntrinsicInst>(&op)->getIntrinsicID () ==
245+ Intrinsic::umin)) &&
232246 " Unexpected operation detected while visiting OpSet!" );
233247
234248 if (op.getOpcode () == Instruction::Ret) {
@@ -245,9 +259,10 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
245259 });
246260 b.add (&VisitorNest::visitBinaryOperator);
247261 b.nest <raw_ostream>([](VisitorBuilder<raw_ostream> &b) {
248- b.add <xd::cpp::WriteOp>([](raw_ostream &out, xd::cpp::WriteOp &op) {
249- out << " visiting WriteOp: " << op << ' \n ' ;
250- });
262+ b.add <xd::cpp::WriteOp>(
263+ [](raw_ostream &out, xd::cpp::WriteOp &op) {
264+ out << " visiting WriteOp: " << op << ' \n ' ;
265+ });
251266 b.add <xd::cpp::WriteVarArgOp>(
252267 [](raw_ostream &out, xd::cpp::WriteVarArgOp &op) {
253268 out << " visiting WriteVarArgOp: " << op << " :\n " ;
@@ -273,8 +288,10 @@ template <bool rpot> const Visitor<VisitorContainer> &getExampleVisitor() {
273288 });
274289 });
275290 b.nest <VisitorInnermost>([](VisitorBuilder<VisitorInnermost> &b) {
276- b.add <xd::cpp::ITruncOp>([](VisitorInnermost &inner,
277- xd::cpp::ITruncOp &op) { inner.counter ++; });
291+ b.add <xd::cpp::ITruncOp>(
292+ [](VisitorInnermost &inner, xd::cpp::ITruncOp &op) {
293+ inner.counter ++;
294+ });
278295 });
279296 })
280297 .setStrategy (rpot ? VisitorStrategy::ReversePostOrder
0 commit comments