diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2d34721..b2b6877 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -23,9 +23,9 @@ set(EXAMPLE_TABLEGEN_EXE llvm-dialects-tblgen) set(EXAMPLE_TABLEGEN_TARGET llvm-dialects-tblgen) set(LLVM_TARGET_DEFINITIONS ExampleDialect.td) -tablegen(EXAMPLE ExampleDialect.h.inc -gen-dialect-decls --dialect xd +tablegen(EXAMPLE ExampleDialect.h.inc -gen-dialect-decls --dialect xd.ir EXTRA_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../include) -tablegen(EXAMPLE ExampleDialect.cpp.inc -gen-dialect-defs --dialect xd +tablegen(EXAMPLE ExampleDialect.cpp.inc -gen-dialect-defs --dialect xd.ir EXTRA_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../include) add_public_tablegen_target(ExampleDialectTableGen) diff --git a/example/ExampleDialect.cpp b/example/ExampleDialect.cpp index cf84460..e807dea 100644 --- a/example/ExampleDialect.cpp +++ b/example/ExampleDialect.cpp @@ -28,7 +28,7 @@ #define GET_INCLUDES #include "ExampleDialect.cpp.inc" -namespace xd { +namespace xd::cpp { const char *toString(VectorKind kind) { switch (kind) { @@ -48,7 +48,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &out, VectorKind x) { return out; } -} // namespace xd +} // namespace xd::cpp #define GET_DIALECT_DEFS #include "ExampleDialect.cpp.inc" diff --git a/example/ExampleDialect.h b/example/ExampleDialect.h index 9ab0907..41d78f8 100644 --- a/example/ExampleDialect.h +++ b/example/ExampleDialect.h @@ -28,7 +28,7 @@ #define GET_INCLUDES #include "ExampleDialect.h.inc" -namespace xd { +namespace xd::cpp { enum class VectorKind { LittleEndian = 0, @@ -38,7 +38,7 @@ enum class VectorKind { const char *toString(VectorKind kind); -} // namespace xd +} // namespace xd::cpp #define GET_DIALECT_DECLS #include "ExampleDialect.h.inc" diff --git a/example/ExampleDialect.td b/example/ExampleDialect.td index 3bc6761..c3710fc 100644 --- a/example/ExampleDialect.td +++ b/example/ExampleDialect.td @@ -26,15 +26,15 @@ include "llvm-dialects/Dialect/Dialect.td" def ExampleDialect : Dialect { - let name = "xd"; - let cppNamespace = "xd"; + let name = "xd.ir"; + let cppNamespace = "xd::cpp"; } defm AttrVectorKind : AttrEnum<"VectorKind">; -def VectorKindLittleEndian : CppConstant<"xd::VectorKind::LittleEndian">; -def VectorKindBigEndian : CppConstant<"xd::VectorKind::BigEndian">; -def VectorKindMiddleEndian : CppConstant<"xd::VectorKind::MiddleEndian">; +def VectorKindLittleEndian : CppConstant<"xd::cpp::VectorKind::LittleEndian">; +def VectorKindBigEndian : CppConstant<"xd::cpp::VectorKind::BigEndian">; +def VectorKindMiddleEndian : CppConstant<"xd::cpp::VectorKind::MiddleEndian">; def ImmutableAttrI1 : IntegerAttr<"bool"> { let isImmutable = true; diff --git a/example/ExampleMain.cpp b/example/ExampleMain.cpp index f6c8858..d6371b9 100644 --- a/example/ExampleMain.cpp +++ b/example/ExampleMain.cpp @@ -69,12 +69,12 @@ void useUnnamedStructTypes(Builder &b) { StructType *t2 = StructType::create({b.getInt32Ty(), b.getInt32Ty()}, ""); StructType *t3 = StructType::create({b.getInt64Ty()}, ""); - Value *z1 = b.create(t1); - Value *z2 = b.create(t2); - Value *z3 = b.create(t3); - b.create(z1); - b.create(z2); - b.create(z3); + Value *z1 = b.create(t1); + Value *z2 = b.create(t2); + Value *z3 = b.create(t3); + b.create(z1); + b.create(z2); + b.create(z3); } void createFunctionExample(Module &module, const Twine &name) { @@ -86,47 +86,47 @@ void createFunctionExample(Module &module, const Twine &name) { BasicBlock *bb = BasicBlock::Create(module.getContext(), "entry", fn); b.SetInsertPoint(bb); - Value *x1 = b.create(b.getInt32Ty()); - Value *sizeOf = b.create(b.getHalfTy()); - Value *sizeOf32 = b.create(b.getInt32Ty(), sizeOf); - Value *x2 = b.create(x1, sizeOf32, 11); - Value *x3 = b.create(x2, x1); - Value *x4 = b.create(b.getInt64Ty(), x3); - b.create(x4); - - cast(sizeOf)->setSizeofType(b.getDoubleTy()); - cast(x2)->setExtra(7); - - Value *q1 = b.create(FixedVectorType::get(b.getInt32Ty(), 2)); - Value *q2 = b.create( - xd::XdVectorType::get(xd::VectorKind::BigEndian, b.getInt32Ty(), 2), q1); - - Value *y1 = b.create( - xd::XdVectorType::get(xd::VectorKind::BigEndian, b.getInt32Ty(), 4)); - Value *y2 = b.create(y1, x1); - Value *y3 = b.create(y1, b.getInt32(2)); + Value *x1 = b.create(b.getInt32Ty()); + Value *sizeOf = b.create(b.getHalfTy()); + Value *sizeOf32 = b.create(b.getInt32Ty(), sizeOf); + Value *x2 = b.create(x1, sizeOf32, 11); + Value *x3 = b.create(x2, x1); + Value *x4 = b.create(b.getInt64Ty(), x3); + b.create(x4); + + cast(sizeOf)->setSizeofType(b.getDoubleTy()); + cast(x2)->setExtra(7); + + Value *q1 = b.create(FixedVectorType::get(b.getInt32Ty(), 2)); + Value *q2 = b.create( + xd::cpp::XdVectorType::get(xd::cpp::VectorKind::BigEndian, b.getInt32Ty(), 2), q1); + + Value *y1 = b.create( + xd::cpp::XdVectorType::get(xd::cpp::VectorKind::BigEndian, b.getInt32Ty(), 4)); + Value *y2 = b.create(y1, x1); + Value *y3 = b.create(y1, b.getInt32(2)); Value *y4 = b.CreateAdd(y2, y3); - Value *y5 = b.create(q2, y4, x1); - auto *y6 = b.create(y5, y2, b.getInt32(5)); - b.create(y6); + Value *y5 = b.create(q2, y4, x1); + auto *y6 = b.create(y5, y2, b.getInt32(5)); + b.create(y6); y6->setIndex(b.getInt32(1)); - Value *p1 = b.create(b.getPtrTy(0)); + Value *p1 = b.create(b.getPtrTy(0)); p1->setName("p1"); - Value *p2 = b.create(p1, b.getInt64(14), b.getInt8(0)); + Value *p2 = b.create(p1, b.getInt64(14), b.getInt8(0)); p2->setName("p2"); - b.create(p2); + b.create(p2); - assert(xd::ExampleDialect::isDialectOp(*cast(p2))); + assert(xd::cpp::ExampleDialect::isDialectOp(*cast(p2))); SmallVector varArgs; varArgs.push_back(p1); varArgs.push_back(p2); - b.create(p2, varArgs); - b.create(); + b.create(p2, varArgs); + b.create(); - auto *replaceable = b.create(p2, varArgs); + auto *replaceable = b.create(p2, varArgs); SmallVector MD; MD.push_back(ConstantAsMetadata::get( ConstantInt::get(Type::getInt32Ty(bb->getContext()), 1))); @@ -136,25 +136,25 @@ void createFunctionExample(Module &module, const Twine &name) { varArgs2.push_back(p2); replaceable->replaceArgs(varArgs2); - b.create(FixedVectorType::get(b.getInt32Ty(), 2)); - b.create(y6); + b.create(FixedVectorType::get(b.getInt32Ty(), 2)); + b.create(y6); useUnnamedStructTypes(b); - b.create("name.of.llvm.value"); - b.create(b.getInt32(1)); - b.create(b.getInt32(1), "name.foo"); - b.create(b.getInt32(1), b.getInt32(2)); - b.create(b.getInt32(1), b.getInt32(2), "bar"); + b.create("name.of.llvm.value"); + b.create(b.getInt32(1)); + b.create(b.getInt32(1), "name.foo"); + b.create(b.getInt32(1), b.getInt32(2)); + b.create(b.getInt32(1), b.getInt32(2), "bar"); SmallVector moreVarArgs = varArgs; - b.create(moreVarArgs); - b.create(moreVarArgs, "two.varargs"); + b.create(moreVarArgs); + b.create(moreVarArgs, "two.varargs"); moreVarArgs.push_back(b.getInt32(3)); - b.create(moreVarArgs, "three.varargs"); + b.create(moreVarArgs, "three.varargs"); moreVarArgs.push_back(b.getInt32(4)); - b.create(moreVarArgs, "four.varargs"); + b.create(moreVarArgs, "four.varargs"); - b.create("Hello world!"); + b.create("Hello world!"); b.CreateRetVoid(); } @@ -210,20 +210,20 @@ template const Visitor &getExampleVisitor() { static const auto visitor = VisitorBuilder() .nest([](VisitorBuilder &b) { - b.add([](VisitorNest &self, xd::ReadOp &op) { + b.add([](VisitorNest &self, xd::cpp::ReadOp &op) { *self.out << "visiting ReadOp: " << op << '\n'; }); b.add(&VisitorNest::visitUnaryInstruction); - b.add([](VisitorNest &self, xd::SetReadOp &op) { + b.add([](VisitorNest &self, xd::cpp::SetReadOp &op) { *self.out << "visiting SetReadOp: " << op << '\n'; return op.getType()->isIntegerTy(1) ? VisitorResult::Stop : VisitorResult::Continue; }); - b.addSet( + b.addSet( [](VisitorNest &self, llvm::Instruction &op) { - if (isa(op)) { + if (isa(op)) { *self.out << "visiting SetReadOp (set): " << op << '\n'; - } else if (isa(op)) { + } else if (isa(op)) { *self.out << "visiting SetWriteOp (set): " << op << '\n'; } }); @@ -248,17 +248,17 @@ template const Visitor &getExampleVisitor() { }); b.add(&VisitorNest::visitBinaryOperator); b.nest([](VisitorBuilder &b) { - b.add([](raw_ostream &out, xd::WriteOp &op) { + b.add([](raw_ostream &out, xd::cpp::WriteOp &op) { out << "visiting WriteOp: " << op << '\n'; }); - b.add( - [](raw_ostream &out, xd::WriteVarArgOp &op) { + b.add( + [](raw_ostream &out, xd::cpp::WriteVarArgOp &op) { out << "visiting WriteVarArgOp: " << op << ":\n"; for (Value *arg : op.getArgs()) out << " " << *arg << '\n'; }); - b.add( - [](raw_ostream &out, xd::StringAttrOp &op) { + b.add( + [](raw_ostream &out, xd::cpp::StringAttrOp &op) { out << "visiting StringAttrOp: " << op.getVal() << '\n'; }); b.add([](raw_ostream &out, ReturnInst &ret) { @@ -270,8 +270,8 @@ template const Visitor &getExampleVisitor() { }); }); b.nest([](VisitorBuilder &b) { - b.add([](VisitorInnermost &inner, - xd::ITruncOp &op) { inner.counter++; }); + b.add([](VisitorInnermost &inner, + xd::cpp::ITruncOp &op) { inner.counter++; }); }); }) .setStrategy(rpot ? VisitorStrategy::ReversePostOrder @@ -295,7 +295,7 @@ int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv); LLVMContext context; - auto dialectContext = DialectContext::make(context); + auto dialectContext = DialectContext::make(context); if (g_action == Action::Build) { auto module = createModuleExample(context); diff --git a/lib/TableGen/GenDialect.cpp b/lib/TableGen/GenDialect.cpp index 262ba78..6e50cad 100644 --- a/lib/TableGen/GenDialect.cpp +++ b/lib/TableGen/GenDialect.cpp @@ -316,7 +316,7 @@ void llvm_dialects::genDialectDefs(raw_ostream& out, RecordKeeper& records) { } bool $Dialect::isDialectOp(::llvm::StringRef funcName) { - return funcName.starts_with("$namespace."); + return funcName.starts_with("$dialect."); } ::llvm_dialects::Dialect* $Dialect::make(::llvm::LLVMContext& context) { diff --git a/test/example/generated/ExampleDialect.cpp.inc b/test/example/generated/ExampleDialect.cpp.inc index 90cfbff..db08dec 100644 --- a/test/example/generated/ExampleDialect.cpp.inc +++ b/test/example/generated/ExampleDialect.cpp.inc @@ -23,7 +23,7 @@ #ifdef GET_DIALECT_DEFS #undef GET_DIALECT_DEFS -namespace xd { +namespace xd::cpp { void ExampleDialect::anchor() {} @@ -45,7 +45,7 @@ namespace xd { } bool ExampleDialect::isDialectOp(::llvm::StringRef funcName) { - return funcName.starts_with("xd."); + return funcName.starts_with("xd.ir."); } ::llvm_dialects::Dialect* ExampleDialect::make(::llvm::LLVMContext& context) { @@ -343,7 +343,7 @@ return true; setArgOperand(2, initial); } - const ::llvm::StringLiteral Add32Op::s_name{"xd.add32"}; + const ::llvm::StringLiteral Add32Op::s_name{"xd.ir.add32"}; Add32Op* Add32Op::create(llvm_dialects::Builder& b, ::llvm::Value * lhs, ::llvm::Value * rhs, uint32_t extra, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -465,7 +465,7 @@ uint32_t const extra = getExtra(); - const ::llvm::StringLiteral CombineOp::s_name{"xd.combine"}; + const ::llvm::StringLiteral CombineOp::s_name{"xd.ir.combine"}; CombineOp* CombineOp::create(llvm_dialects::Builder& b, ::llvm::Value * lhs, ::llvm::Value * rhs, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -560,7 +560,7 @@ rhs - const ::llvm::StringLiteral ExtractElementOp::s_name{"xd.extractelement"}; + const ::llvm::StringLiteral ExtractElementOp::s_name{"xd.ir.extractelement"}; ExtractElementOp* ExtractElementOp::create(llvm_dialects::Builder& b, ::llvm::Value * vector, ::llvm::Value * index, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -664,7 +664,7 @@ index - const ::llvm::StringLiteral FromFixedVectorOp::s_name{"xd.fromfixedvector"}; + const ::llvm::StringLiteral FromFixedVectorOp::s_name{"xd.ir.fromfixedvector"}; FromFixedVectorOp* FromFixedVectorOp::create(llvm_dialects::Builder& b, ::llvm::Type* resultType, ::llvm::Value * source, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -759,7 +759,7 @@ source && !([&]() { - if (xd::VectorKind::LittleEndian != ::llvm::cast(resultType)->getKind()) { + if (xd::cpp::VectorKind::LittleEndian != ::llvm::cast(resultType)->getKind()) { return false; } return true; @@ -767,7 +767,7 @@ source && !([&]() { - if (xd::VectorKind::BigEndian != ::llvm::cast(resultType)->getKind()) { + if (xd::cpp::VectorKind::BigEndian != ::llvm::cast(resultType)->getKind()) { return false; } return true; @@ -780,10 +780,10 @@ source errs << " failed option 0 (VectorKindLittleEndian):\n"; ([&]() { - if (xd::VectorKind::LittleEndian != ::llvm::cast(resultType)->getKind()) { + if (xd::cpp::VectorKind::LittleEndian != ::llvm::cast(resultType)->getKind()) { errs << " inconsistent value of eq:$rhs found\n"; errs << " while checking VectorKindLittleEndian:\n"; - errs << " here: " << printable(xd::VectorKind::LittleEndian) << '\n'; + errs << " here: " << printable(xd::cpp::VectorKind::LittleEndian) << '\n'; errs << " previously: " << printable(::llvm::cast(resultType)->getKind()) << '\n'; return false; @@ -795,10 +795,10 @@ source errs << " failed option 1 (VectorKindBigEndian):\n"; ([&]() { - if (xd::VectorKind::BigEndian != ::llvm::cast(resultType)->getKind()) { + if (xd::cpp::VectorKind::BigEndian != ::llvm::cast(resultType)->getKind()) { errs << " inconsistent value of eq:$rhs found\n"; errs << " while checking VectorKindBigEndian:\n"; - errs << " here: " << printable(xd::VectorKind::BigEndian) << '\n'; + errs << " here: " << printable(xd::cpp::VectorKind::BigEndian) << '\n'; errs << " previously: " << printable(::llvm::cast(resultType)->getKind()) << '\n'; return false; @@ -834,7 +834,7 @@ source - const ::llvm::StringLiteral HandleGetOp::s_name{"xd.handle.get"}; + const ::llvm::StringLiteral HandleGetOp::s_name{"xd.ir.handle.get"}; HandleGetOp* HandleGetOp::create(llvm_dialects::Builder& b, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -896,7 +896,7 @@ source - const ::llvm::StringLiteral IExtOp::s_name{"xd.iext"}; + const ::llvm::StringLiteral IExtOp::s_name{"xd.ir.iext"}; IExtOp* IExtOp::create(llvm_dialects::Builder& b, ::llvm::Type* resultType, ::llvm::Value * source, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -994,7 +994,7 @@ source - const ::llvm::StringLiteral ITruncOp::s_name{"xd.itrunc"}; + const ::llvm::StringLiteral ITruncOp::s_name{"xd.ir.itrunc"}; ITruncOp* ITruncOp::create(llvm_dialects::Builder& b, ::llvm::Type* resultType, ::llvm::Value * source, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1092,7 +1092,7 @@ source - const ::llvm::StringLiteral ImmutableOp::s_name{"xd.immutable.op"}; + const ::llvm::StringLiteral ImmutableOp::s_name{"xd.ir.immutable.op"}; ImmutableOp* ImmutableOp::create(llvm_dialects::Builder& b, bool val, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1161,7 +1161,7 @@ source - const ::llvm::StringLiteral InsertElementOp::s_name{"xd.insertelement"}; + const ::llvm::StringLiteral InsertElementOp::s_name{"xd.ir.insertelement"}; InsertElementOp* InsertElementOp::create(llvm_dialects::Builder& b, ::llvm::Value * vector, ::llvm::Value * value, ::llvm::Value * index, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1283,7 +1283,7 @@ index - const ::llvm::StringLiteral InstNameConflictDoubleOp::s_name{"xd.inst.name.conflict.double"}; + const ::llvm::StringLiteral InstNameConflictDoubleOp::s_name{"xd.ir.inst.name.conflict.double"}; InstNameConflictDoubleOp* InstNameConflictDoubleOp::create(llvm_dialects::Builder& b, ::llvm::Value * instName, ::llvm::Value * instName_0, const llvm::Twine &instName_1) { ::llvm::LLVMContext& context = b.getContext(); @@ -1367,7 +1367,7 @@ instName_0 - const ::llvm::StringLiteral InstNameConflictOp::s_name{"xd.inst.name.conflict"}; + const ::llvm::StringLiteral InstNameConflictOp::s_name{"xd.ir.inst.name.conflict"}; InstNameConflictOp* InstNameConflictOp::create(llvm_dialects::Builder& b, ::llvm::Value * instName, const llvm::Twine &instName_0) { ::llvm::LLVMContext& context = b.getContext(); @@ -1441,7 +1441,7 @@ instName - const ::llvm::StringLiteral InstNameConflictVarargsOp::s_name{"xd.inst.name.conflict.varargs"}; + const ::llvm::StringLiteral InstNameConflictVarargsOp::s_name{"xd.ir.inst.name.conflict.varargs"}; InstNameConflictVarargsOp* InstNameConflictVarargsOp::create(llvm_dialects::Builder& b, ::llvm::ArrayRef<::llvm::Value *> instName_0, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1519,7 +1519,7 @@ instName - const ::llvm::StringLiteral ReadOp::s_name{"xd.read"}; + const ::llvm::StringLiteral ReadOp::s_name{"xd.ir.read"}; ReadOp* ReadOp::create(llvm_dialects::Builder& b, ::llvm::Type* dataType, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1576,7 +1576,7 @@ instName - const ::llvm::StringLiteral SetReadOp::s_name{"xd.set.read"}; + const ::llvm::StringLiteral SetReadOp::s_name{"xd.ir.set.read"}; SetReadOp* SetReadOp::create(llvm_dialects::Builder& b, ::llvm::Type* dataType, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1633,7 +1633,7 @@ instName - const ::llvm::StringLiteral SetWriteOp::s_name{"xd.set.write"}; + const ::llvm::StringLiteral SetWriteOp::s_name{"xd.ir.set.write"}; SetWriteOp* SetWriteOp::create(llvm_dialects::Builder& b, ::llvm::Value * data, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1696,7 +1696,7 @@ data - const ::llvm::StringLiteral SizeOfOp::s_name{"xd.sizeof"}; + const ::llvm::StringLiteral SizeOfOp::s_name{"xd.ir.sizeof"}; SizeOfOp* SizeOfOp::create(llvm_dialects::Builder& b, ::llvm::Type * sizeofType, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1770,7 +1770,7 @@ data - const ::llvm::StringLiteral StreamAddOp::s_name{"xd.stream.add"}; + const ::llvm::StringLiteral StreamAddOp::s_name{"xd.ir.stream.add"}; StreamAddOp* StreamAddOp::create(llvm_dialects::Builder& b, ::llvm::Value * ptr, ::llvm::Value * count, ::llvm::Value * initial, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1862,7 +1862,7 @@ initial - const ::llvm::StringLiteral StreamMaxOp::s_name{"xd.stream.max"}; + const ::llvm::StringLiteral StreamMaxOp::s_name{"xd.ir.stream.max"}; StreamMaxOp* StreamMaxOp::create(llvm_dialects::Builder& b, ::llvm::Value * ptr, ::llvm::Value * count, ::llvm::Value * initial, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -1954,7 +1954,7 @@ initial - const ::llvm::StringLiteral StreamMinOp::s_name{"xd.stream.min"}; + const ::llvm::StringLiteral StreamMinOp::s_name{"xd.ir.stream.min"}; StreamMinOp* StreamMinOp::create(llvm_dialects::Builder& b, ::llvm::Value * ptr, ::llvm::Value * count, ::llvm::Value * initial, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -2046,7 +2046,7 @@ initial - const ::llvm::StringLiteral StringAttrOp::s_name{"xd.string.attr.op"}; + const ::llvm::StringLiteral StringAttrOp::s_name{"xd.ir.string.attr.op"}; StringAttrOp* StringAttrOp::create(llvm_dialects::Builder& b, ::llvm::StringRef val, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -2115,7 +2115,7 @@ initial - const ::llvm::StringLiteral WriteOp::s_name{"xd.write"}; + const ::llvm::StringLiteral WriteOp::s_name{"xd.ir.write"}; WriteOp* WriteOp::create(llvm_dialects::Builder& b, ::llvm::Value * data, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -2178,7 +2178,7 @@ data - const ::llvm::StringLiteral WriteVarArgOp::s_name{"xd.write.vararg"}; + const ::llvm::StringLiteral WriteVarArgOp::s_name{"xd.ir.write.vararg"}; WriteVarArgOp* WriteVarArgOp::create(llvm_dialects::Builder& b, ::llvm::Value * data, ::llvm::ArrayRef<::llvm::Value *> args, const llvm::Twine &instName) { ::llvm::LLVMContext& context = b.getContext(); @@ -2259,180 +2259,180 @@ data } -} // namespace xd +} // namespace xd::cpp template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.add32"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.add32"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.combine"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.combine"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.extractelement"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.extractelement"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.fromfixedvector"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.fromfixedvector"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.handle.get"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.handle.get"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.iext"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.iext"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.itrunc"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.itrunc"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.immutable.op"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.immutable.op"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.insertelement"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.insertelement"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.inst.name.conflict.double"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.inst.name.conflict.double"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.inst.name.conflict"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.inst.name.conflict"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.inst.name.conflict.varargs"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.inst.name.conflict.varargs"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.read"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.read"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.set.read"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.set.read"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.set.write"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.set.write"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.sizeof"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.sizeof"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.stream.add"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.stream.add"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.stream.max"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.stream.max"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{true, "xd.stream.min"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{true, "xd.ir.stream.min"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.string.attr.op"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.string.attr.op"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.write"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.write"}; return desc; } template <> const ::llvm_dialects::OpDescription & - ::llvm_dialects::OpDescription::get() { - static const ::llvm_dialects::OpDescription desc{false, "xd.write.vararg"}; + ::llvm_dialects::OpDescription::get() { + static const ::llvm_dialects::OpDescription desc{false, "xd.ir.write.vararg"}; return desc; } diff --git a/test/example/generated/ExampleDialect.h.inc b/test/example/generated/ExampleDialect.h.inc index 3198f89..0e3e59b 100644 --- a/test/example/generated/ExampleDialect.h.inc +++ b/test/example/generated/ExampleDialect.h.inc @@ -21,7 +21,7 @@ class Builder; #ifdef GET_DIALECT_DECLS #undef GET_DIALECT_DECLS -namespace xd { +namespace xd::cpp { class ExampleDialect : public ::llvm_dialects::DialectImpl { @@ -51,7 +51,7 @@ namespace xd { }; class XdHandleType : public ::llvm::TargetExtType { - static constexpr ::llvm::StringLiteral s_name{"xd.handle"}; + static constexpr ::llvm::StringLiteral s_name{"xd.ir.handle"}; public: static bool classof(const ::llvm::TargetExtType *t) { @@ -70,7 +70,7 @@ namespace xd { class XdVectorType : public ::llvm::TargetExtType { - static constexpr ::llvm::StringLiteral s_name{"xd.vector"}; + static constexpr ::llvm::StringLiteral s_name{"xd.ir.vector"}; public: static bool classof(const ::llvm::TargetExtType *t) { @@ -108,7 +108,7 @@ uint32_t getNumElements() const; }; class Add32Op : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.add32"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.add32"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -135,7 +135,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class CombineOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.combine"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.combine"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -160,7 +160,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class ExtractElementOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.extractelement"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.extractelement"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -185,7 +185,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class FromFixedVectorOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.fromfixedvector"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.fromfixedvector"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -208,7 +208,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class HandleGetOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.handle.get"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.handle.get"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -229,7 +229,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class IExtOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.iext"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.iext"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -252,7 +252,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class ITruncOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.itrunc"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.itrunc"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -275,7 +275,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class ImmutableOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.immutable.op"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.immutable.op"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -295,7 +295,7 @@ bool getVal() const; }; class InsertElementOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.insertelement"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.insertelement"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -322,7 +322,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class InstNameConflictDoubleOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.inst.name.conflict.double"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.inst.name.conflict.double"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -347,7 +347,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class InstNameConflictOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.inst.name.conflict"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.inst.name.conflict"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -370,7 +370,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class InstNameConflictVarargsOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.inst.name.conflict.varargs"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.inst.name.conflict.varargs"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -395,7 +395,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class ReadOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.read"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.read"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -416,7 +416,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class SetReadOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.set.read"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.set.read"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -437,7 +437,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class SetWriteOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.set.write"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.set.write"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -459,7 +459,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class SizeOfOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.sizeof"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.sizeof"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -482,7 +482,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class StreamAddOp : public StreamReduceOp { - static const ::llvm::StringLiteral s_name; //{"xd.stream.add"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.add"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -503,7 +503,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class StreamMaxOp : public StreamReduceOp { - static const ::llvm::StringLiteral s_name; //{"xd.stream.max"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.max"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -524,7 +524,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class StreamMinOp : public StreamReduceOp { - static const ::llvm::StringLiteral s_name; //{"xd.stream.min"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.min"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -545,7 +545,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class StringAttrOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.string.attr.op"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.string.attr.op"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -565,7 +565,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class WriteOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.write"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.write"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -587,7 +587,7 @@ bool verifier(::llvm::raw_ostream &errs); }; class WriteVarArgOp : public ::llvm::CallInst { - static const ::llvm::StringLiteral s_name; //{"xd.write.vararg"}; + static const ::llvm::StringLiteral s_name; //{"xd.ir.write.vararg"}; public: static bool classof(const ::llvm::CallInst* i) { @@ -611,6 +611,6 @@ bool verifier(::llvm::raw_ostream &errs); }; - } // namespace xd + } // namespace xd::cpp #endif // GET_DIALECT_DECLS diff --git a/test/example/test-builder.test b/test/example/test-builder.test index 96603b4..df4c6c4 100644 --- a/test/example/test-builder.test +++ b/test/example/test-builder.test @@ -7,46 +7,46 @@ ;. ; CHECK-LABEL: @example( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[TMP0:%.*]] = call i32 @xd.read__i32() -; CHECK-NEXT: [[TMP1:%.*]] = call i64 (...) @xd.sizeof(double poison) -; CHECK-NEXT: [[TMP2:%.*]] = call i32 (...) @xd.itrunc__i32(i64 [[TMP1]]) -; CHECK-NEXT: [[TMP3:%.*]] = call i32 @xd.add32(i32 [[TMP0]], i32 [[TMP2]], i32 7) -; CHECK-NEXT: [[TMP4:%.*]] = call i32 (...) @xd.combine__i32(i32 [[TMP3]], i32 [[TMP0]]) -; CHECK-NEXT: [[TMP5:%.*]] = call i64 (...) @xd.iext__i64(i32 [[TMP4]]) -; CHECK-NEXT: call void (...) @xd.write(i64 [[TMP5]]) -; CHECK-NEXT: [[TMP6:%.*]] = call <2 x i32> @xd.read__v2i32() -; CHECK-NEXT: [[TMP7:%.*]] = call target("xd.vector", i32, 1, 2) (...) @xd.fromfixedvector__txd.vector_i32_1_2t(<2 x i32> [[TMP6]]) -; CHECK-NEXT: [[TMP8:%.*]] = call target("xd.vector", i32, 1, 4) @xd.read__txd.vector_i32_1_4t() -; CHECK-NEXT: [[TMP9:%.*]] = call i32 (...) @xd.extractelement__i32(target("xd.vector", i32, 1, 4) [[TMP8]], i32 [[TMP0]]) -; CHECK-NEXT: [[TMP10:%.*]] = call i32 (...) @xd.extractelement__i32(target("xd.vector", i32, 1, 4) [[TMP8]], i32 2) +; CHECK-NEXT: [[TMP0:%.*]] = call i32 @xd.ir.read__i32() +; CHECK-NEXT: [[TMP1:%.*]] = call i64 (...) @xd.ir.sizeof(double poison) +; CHECK-NEXT: [[TMP2:%.*]] = call i32 (...) @xd.ir.itrunc__i32(i64 [[TMP1]]) +; CHECK-NEXT: [[TMP3:%.*]] = call i32 @xd.ir.add32(i32 [[TMP0]], i32 [[TMP2]], i32 7) +; CHECK-NEXT: [[TMP4:%.*]] = call i32 (...) @xd.ir.combine__i32(i32 [[TMP3]], i32 [[TMP0]]) +; CHECK-NEXT: [[TMP5:%.*]] = call i64 (...) @xd.ir.iext__i64(i32 [[TMP4]]) +; CHECK-NEXT: call void (...) @xd.ir.write(i64 [[TMP5]]) +; CHECK-NEXT: [[TMP6:%.*]] = call <2 x i32> @xd.ir.read__v2i32() +; CHECK-NEXT: [[TMP7:%.*]] = call target("xd.ir.vector", i32, 1, 2) (...) @xd.ir.fromfixedvector__txd.ir.vector_i32_1_2t(<2 x i32> [[TMP6]]) +; CHECK-NEXT: [[TMP8:%.*]] = call target("xd.ir.vector", i32, 1, 4) @xd.ir.read__txd.ir.vector_i32_1_4t() +; CHECK-NEXT: [[TMP9:%.*]] = call i32 (...) @xd.ir.extractelement__i32(target("xd.ir.vector", i32, 1, 4) [[TMP8]], i32 [[TMP0]]) +; CHECK-NEXT: [[TMP10:%.*]] = call i32 (...) @xd.ir.extractelement__i32(target("xd.ir.vector", i32, 1, 4) [[TMP8]], i32 2) ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP9]], [[TMP10]] -; CHECK-NEXT: [[TMP12:%.*]] = call target("xd.vector", i32, 1, 2) (...) @xd.insertelement__txd.vector_i32_1_2t(target("xd.vector", i32, 1, 2) [[TMP7]], i32 [[TMP11]], i32 [[TMP0]]) -; CHECK-NEXT: [[TMP13:%.*]] = call target("xd.vector", i32, 1, 2) (...) @xd.insertelement__txd.vector_i32_1_2t(target("xd.vector", i32, 1, 2) [[TMP12]], i32 [[TMP9]], i32 1) -; CHECK-NEXT: call void (...) @xd.write(target("xd.vector", i32, 1, 2) [[TMP13]]) -; CHECK-NEXT: [[P1:%.*]] = call ptr @xd.read__p0() -; CHECK-NEXT: [[P2:%.*]] = call i8 (...) @xd.stream.add__i8(ptr [[P1]], i64 14, i8 0) -; CHECK-NEXT: call void (...) @xd.write(i8 [[P2]]) -; CHECK-NEXT: call void (...) @xd.write.vararg(i8 [[P2]], ptr [[P1]], i8 [[P2]]) -; CHECK-NEXT: [[TMP14:%.*]] = call target("xd.handle") @xd.handle.get() -; CHECK-NEXT: call void (...) @xd.write.vararg(i8 [[P2]], ptr [[P1]], i8 [[P2]], i8 [[P2]]), !testMd !{{.*}} -; CHECK-NEXT: [[TMP15:%.*]] = call <2 x i32> @xd.set.read__v2i32() -; CHECK-NEXT: call void (...) @xd.set.write(target("xd.vector", i32, 1, 2) [[TMP13]]) -; CHECK-NEXT: [[TMP16:%.*]] = call [[TMP0]] @xd.read__s_s() -; CHECK-NEXT: [[TMP17:%.*]] = call [[TMP1]] @xd.read__s_s_0() -; CHECK-NEXT: [[TMP18:%.*]] = call [[TMP2]] @xd.read__s_s_1() -; CHECK-NEXT: call void (...) @xd.write([[TMP0]] [[TMP16]]) -; CHECK-NEXT: call void (...) @xd.write([[TMP1]] [[TMP17]]) -; CHECK-NEXT: call void (...) @xd.write([[TMP2]] [[TMP18]]) -; CHECK-NEXT: [[NAME_OF_LLVM_VALUE:%.*]] = call target("xd.handle") @xd.handle.get() -; CHECK-NEXT: [[TMP19:%.*]] = call i32 (...) @xd.inst.name.conflict(i32 1) -; CHECK-NEXT: [[NAME_FOO:%.*]] = call i32 (...) @xd.inst.name.conflict(i32 1) -; CHECK-NEXT: [[TMP20:%.*]] = call i32 (...) @xd.inst.name.conflict.double(i32 1, i32 2) -; CHECK-NEXT: [[BAR:%.*]] = call i32 (...) @xd.inst.name.conflict.double(i32 1, i32 2) -; CHECK-NEXT: [[TMP21:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]]) -; CHECK-NEXT: [[TWO_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]]) -; CHECK-NEXT: [[THREE_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3) -; CHECK-NEXT: [[FOUR_VARARGS:%.*]] = call i32 (...) @xd.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3, i32 4) -; CHECK-NEXT: call void @xd.string.attr.op(ptr @str) +; CHECK-NEXT: [[TMP12:%.*]] = call target("xd.ir.vector", i32, 1, 2) (...) @xd.ir.insertelement__txd.ir.vector_i32_1_2t(target("xd.ir.vector", i32, 1, 2) [[TMP7]], i32 [[TMP11]], i32 [[TMP0]]) +; CHECK-NEXT: [[TMP13:%.*]] = call target("xd.ir.vector", i32, 1, 2) (...) @xd.ir.insertelement__txd.ir.vector_i32_1_2t(target("xd.ir.vector", i32, 1, 2) [[TMP12]], i32 [[TMP9]], i32 1) +; CHECK-NEXT: call void (...) @xd.ir.write(target("xd.ir.vector", i32, 1, 2) [[TMP13]]) +; CHECK-NEXT: [[P1:%.*]] = call ptr @xd.ir.read__p0() +; CHECK-NEXT: [[P2:%.*]] = call i8 (...) @xd.ir.stream.add__i8(ptr [[P1]], i64 14, i8 0) +; CHECK-NEXT: call void (...) @xd.ir.write(i8 [[P2]]) +; CHECK-NEXT: call void (...) @xd.ir.write.vararg(i8 [[P2]], ptr [[P1]], i8 [[P2]]) +; CHECK-NEXT: [[TMP14:%.*]] = call target("xd.ir.handle") @xd.ir.handle.get() +; CHECK-NEXT: call void (...) @xd.ir.write.vararg(i8 [[P2]], ptr [[P1]], i8 [[P2]], i8 [[P2]]), !testMd [[META0:![0-9]+]] +; CHECK-NEXT: [[TMP15:%.*]] = call <2 x i32> @xd.ir.set.read__v2i32() +; CHECK-NEXT: call void (...) @xd.ir.set.write(target("xd.ir.vector", i32, 1, 2) [[TMP13]]) +; CHECK-NEXT: [[TMP16:%.*]] = call [[TMP0]] @[[XD_IR_READ__S_S:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]]() +; CHECK-NEXT: [[TMP17:%.*]] = call [[TMP1]] @[[XD_IR_READ__S_S_0:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]]() +; CHECK-NEXT: [[TMP18:%.*]] = call [[TMP2]] @[[XD_IR_READ__S_S_1:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]]() +; CHECK-NEXT: call void (...) @xd.ir.write([[TMP0]] [[TMP16]]) +; CHECK-NEXT: call void (...) @xd.ir.write([[TMP1]] [[TMP17]]) +; CHECK-NEXT: call void (...) @xd.ir.write([[TMP2]] [[TMP18]]) +; CHECK-NEXT: [[NAME_OF_LLVM_VALUE:%.*]] = call target("xd.ir.handle") @xd.ir.handle.get() +; CHECK-NEXT: [[TMP19:%.*]] = call i32 (...) @xd.ir.inst.name.conflict(i32 1) +; CHECK-NEXT: [[NAME_FOO:%.*]] = call i32 (...) @xd.ir.inst.name.conflict(i32 1) +; CHECK-NEXT: [[TMP20:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.double(i32 1, i32 2) +; CHECK-NEXT: [[BAR:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.double(i32 1, i32 2) +; CHECK-NEXT: [[TMP21:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]]) +; CHECK-NEXT: [[TWO_VARARGS:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]]) +; CHECK-NEXT: [[THREE_VARARGS:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3) +; CHECK-NEXT: [[FOUR_VARARGS:%.*]] = call i32 (...) @xd.ir.inst.name.conflict.varargs(ptr [[P1]], i8 [[P2]], i32 3, i32 4) +; CHECK-NEXT: call void @xd.ir.string.attr.op(ptr @str) ; CHECK-NEXT: ret void ; ;. @@ -56,3 +56,5 @@ ; CHECK: attributes #[[ATTR3:[0-9]+]] = { nounwind willreturn memory(read) } ; CHECK: attributes #[[ATTR4:[0-9]+]] = { willreturn } ;. +; CHECK: [[META0]] = !{i32 1} +;. diff --git a/test/example/verifier-basic.ll b/test/example/verifier-basic.ll index d5407fc..261cdbd 100644 --- a/test/example/verifier-basic.ll +++ b/test/example/verifier-basic.ll @@ -6,35 +6,35 @@ entry: ; CHECK: unexpected value of $result: ; CHECK: expected: i64 ; CHECK: actual: i32 - %sizeof1 = call i32 (...) @xd.sizeof(<10 x i32> poison) + %sizeof1 = call i32 (...) @xd.ir.sizeof(<10 x i32> poison) ; CHECK-LABEL: Verifier error in: %trunc1 = ; CHECK: failed check for (le ?:$result_width, ?:$source_width) ; CHECK: with $result_width = 64 ; CHECK: with $source_width = 32 - %trunc1 = call i64 (...) @xd.itrunc__i64(i32 %sizeof1) + %trunc1 = call i64 (...) @xd.ir.itrunc__i64(i32 %sizeof1) ; CHECK-LABEL: Verifier error in: %fromfixedvector1 = ; CHECK: unexpected value of $scalar_type: ; CHECK: expected: i32 ; CHECK: actual: i64 - %fromfixedvector1 = call target("xd.vector", i32, 0, 2) (...) @xd.fromfixedvector__txd.vector_i32_0_2t(<2 x i64> poison) + %fromfixedvector1 = call target("xd.ir.vector", i32, 0, 2) (...) @xd.ir.fromfixedvector__txd.vector_i32_0_2t(<2 x i64> poison) ; CHECK-LABEL: Verifier error in: %fromfixedvector2 = ; CHECK: unexpected value of $num_elements: ; CHECK: expected: 2 ; CHECK: actual: 4 - %fromfixedvector2 = call target("xd.vector", i32, 0, 2) (...) @xd.fromfixedvector__txd.vector_i32_0_2t(<4 x i32> poison) + %fromfixedvector2 = call target("xd.ir.vector", i32, 0, 2) (...) @xd.ir.fromfixedvector__txd.vector_i32_0_2t(<4 x i32> poison) ; CHECK-LABEL: Verifier error in: %stream.max1 = ; CHECK: unexpected value of $result: ; CHECK: expected: i16 ; CHECK: actual: <2 x i16> - %stream.max1 = call <2 x i16> (...) @xd.stream.max__v2i16(ptr %p, i64 %trunc1, i16 0) + %stream.max1 = call <2 x i16> (...) @xd.ir.stream.max__v2i16(ptr %p, i64 %trunc1, i16 0) ; CHECK-LABEL: Verifier error in: %stream.min1 = ; CHECK: wrong number of arguments: 2, expected 3 - %stream.min1 = call i8 (...) @xd.stream.min__i8(ptr %p, i64 14) + %stream.min1 = call i8 (...) @xd.ir.stream.min__i8(ptr %p, i64 14) ; CHECK-LABEL: Verifier error in: %fromfixedvector3 = ; CHECK: eq:$rhs (MiddleEndian) does not match any available option @@ -50,14 +50,14 @@ entry: ; CHECK: previously: MiddleEndian ; CHECK: while checking (isReasonableVectorKind ?:$kind) ; CHECK: with $kind = MiddleEndian - %fromfixedvector3 = call target("xd.vector", i32, 2, 2) (...) @xd.fromfixedvector__txd.vector_i32_2_2t(<2 x i32> poison) + %fromfixedvector3 = call target("xd.ir.vector", i32, 2, 2) (...) @xd.ir.fromfixedvector__txd.vector_i32_2_2t(<2 x i32> poison) ret void } -declare i32 @xd.sizeof(...) -declare i64 @xd.itrunc__i64(...) -declare target("xd.vector", i32, 0, 2) @xd.fromfixedvector__txd.vector_i32_0_2t(...) -declare target("xd.vector", i32, 2, 2) @xd.fromfixedvector__txd.vector_i32_2_2t(...) -declare <2 x i16> @xd.stream.max__v2i16(...) -declare i8 @xd.stream.min__i8(...) +declare i32 @xd.ir.sizeof(...) +declare i64 @xd.ir.itrunc__i64(...) +declare target("xd.ir.vector", i32, 0, 2) @xd.ir.fromfixedvector__txd.vector_i32_0_2t(...) +declare target("xd.ir.vector", i32, 2, 2) @xd.ir.fromfixedvector__txd.vector_i32_2_2t(...) +declare <2 x i16> @xd.ir.stream.max__v2i16(...) +declare i8 @xd.ir.stream.min__i8(...) diff --git a/test/example/visitor-basic.ll b/test/example/visitor-basic.ll index eaeea9b..919a429 100644 --- a/test/example/visitor-basic.ll +++ b/test/example/visitor-basic.ll @@ -1,18 +1,18 @@ ; RUN: llvm-dialects-example -visit %s | FileCheck --check-prefixes=DEFAULT %s -; DEFAULT: visiting ReadOp: %v = call i32 @xd.read__i32() +; DEFAULT: visiting ReadOp: %v = call i32 @xd.ir.read__i32() ; DEFAULT-NEXT: visiting UnaryInstruction (pre): %w = load i32, ptr %p ; DEFAULT-NEXT: visiting UnaryInstruction (pre): %q = load i32, ptr %p1 ; DEFAULT-NEXT: visiting BinaryOperator: %v1 = add i32 %v, %w ; DEFAULT-NEXT: visiting umax intrinsic: %v2 = call i32 @llvm.umax.i32(i32 %v1, i32 %q) -; DEFAULT-NEXT: visiting WriteOp: call void (...) @xd.write(i8 %t) -; DEFAULT-NEXT: visiting SetReadOp: %v.0 = call i1 @xd.set.read__i1() -; DEFAULT-NEXT: visiting SetReadOp: %v.1 = call i32 @xd.set.read__i32() -; DEFAULT-NEXT: visiting SetReadOp (set): %v.1 = call i32 @xd.set.read__i32() +; DEFAULT-NEXT: visiting WriteOp: call void (...) @xd.ir.write(i8 %t) +; DEFAULT-NEXT: visiting SetReadOp: %v.0 = call i1 @xd.ir.set.read__i1() +; DEFAULT-NEXT: visiting SetReadOp: %v.1 = call i32 @xd.ir.set.read__i32() +; DEFAULT-NEXT: visiting SetReadOp (set): %v.1 = call i32 @xd.ir.set.read__i32() ; DEFAULT-NEXT: visiting UnaryInstruction (pre): %v.2 = trunc i32 %v.1 to i8 ; DEFAULT-NEXT: visiting UnaryInstruction: %v.2 = trunc i32 %v.1 to i8 -; DEFAULT-NEXT: visiting SetWriteOp (set): call void (...) @xd.set.write(i8 %v.2) -; DEFAULT-NEXT: visiting WriteVarArgOp: call void (...) @xd.write.vararg(i8 %t, i32 %v2, i32 %q) +; DEFAULT-NEXT: visiting SetWriteOp (set): call void (...) @xd.ir.set.write(i8 %v.2) +; DEFAULT-NEXT: visiting WriteVarArgOp: call void (...) @xd.ir.write.vararg(i8 %t, i32 %v2, i32 %q) ; DEFAULT-NEXT: %v2 = ; DEFAULT-NEXT: %q = ; DEFAULT-NEXT: visiting umin (set): %vm = call i32 @llvm.umin.i32(i32 %v1, i32 %q) @@ -25,31 +25,31 @@ define void @test1(ptr %p) { entry: - %v = call i32 @xd.read__i32() + %v = call i32 @xd.ir.read__i32() %w = load i32, ptr %p %p1 = getelementptr i32, ptr %p, i32 1 %q = load i32, ptr %p1 %v1 = add i32 %v, %w %v2 = call i32 @llvm.umax.i32(i32 %v1, i32 %q) - %t = call i8 (...) @xd.itrunc__i8(i32 %v2) - call void (...) @xd.write(i8 %t) - %v.0 = call i1 @xd.set.read__i1() - %v.1 = call i32 @xd.set.read__i32() + %t = call i8 (...) @xd.ir.itrunc__i8(i32 %v2) + call void (...) @xd.ir.write(i8 %t) + %v.0 = call i1 @xd.ir.set.read__i1() + %v.1 = call i32 @xd.ir.set.read__i32() %v.2 = trunc i32 %v.1 to i8 - call void (...) @xd.set.write(i8 %v.2) - call void (...) @xd.write.vararg(i8 %t, i32 %v2, i32 %q) + call void (...) @xd.ir.set.write(i8 %v.2) + call void (...) @xd.ir.write.vararg(i8 %t, i32 %v2, i32 %q) %vm = call i32 @llvm.umin.i32(i32 %v1, i32 %q) - call void @xd.string.attr.op(ptr @0) + call void @xd.ir.string.attr.op(ptr @0) ret void } -declare i32 @xd.read__i32() -declare i1 @xd.set.read__i1() -declare i32 @xd.set.read__i32() -declare void @xd.write(...) -declare void @xd.set.write(...) -declare void @xd.write.vararg(...) -declare i8 @xd.itrunc__i8(...) -declare void @xd.string.attr.op(ptr) +declare i32 @xd.ir.read__i32() +declare i1 @xd.ir.set.read__i1() +declare i32 @xd.ir.set.read__i32() +declare void @xd.ir.write(...) +declare void @xd.ir.set.write(...) +declare void @xd.ir.write.vararg(...) +declare i8 @xd.ir.itrunc__i8(...) +declare void @xd.ir.string.attr.op(ptr) declare i32 @llvm.umax.i32(i32, i32) declare i32 @llvm.umin.i32(i32, i32) diff --git a/test/example/visitor-rpot.ll b/test/example/visitor-rpot.ll index e04ea4e..70ca557 100644 --- a/test/example/visitor-rpot.ll +++ b/test/example/visitor-rpot.ll @@ -1,26 +1,26 @@ ; RUN: llvm-dialects-example -visit %s | FileCheck --check-prefixes=DEFAULT %s ; RUN: llvm-dialects-example -visit -rpot %s | FileCheck --check-prefixes=RPOT %s -; DEFAULT: visiting WriteOp: call void (...) @xd.write(i32 0) -; DEFAULT: visiting WriteOp: call void (...) @xd.write(i32 2) -; DEFAULT: visiting WriteOp: call void (...) @xd.write(i32 1) +; DEFAULT: visiting WriteOp: call void (...) @xd.ir.write(i32 0) +; DEFAULT: visiting WriteOp: call void (...) @xd.ir.write(i32 2) +; DEFAULT: visiting WriteOp: call void (...) @xd.ir.write(i32 1) -; RPOT: visiting WriteOp: call void (...) @xd.write(i32 0) -; RPOT: visiting WriteOp: call void (...) @xd.write(i32 1) -; RPOT: visiting WriteOp: call void (...) @xd.write(i32 2) +; RPOT: visiting WriteOp: call void (...) @xd.ir.write(i32 0) +; RPOT: visiting WriteOp: call void (...) @xd.ir.write(i32 1) +; RPOT: visiting WriteOp: call void (...) @xd.ir.write(i32 2) define void @test1(ptr %p) { entry: - call void (...) @xd.write(i32 0) + call void (...) @xd.ir.write(i32 0) br label %a b: - call void (...) @xd.write(i32 2) + call void (...) @xd.ir.write(i32 2) ret void a: - call void (...) @xd.write(i32 1) + call void (...) @xd.ir.write(i32 1) br label %b } -declare void @xd.write(...) +declare void @xd.ir.write(...)