diff --git a/example/ExampleMain.cpp b/example/ExampleMain.cpp index 57c02f0..bc20d42 100644 --- a/example/ExampleMain.cpp +++ b/example/ExampleMain.cpp @@ -117,6 +117,8 @@ void createFunctionExample(Module &module, const Twine &name) { p2->setName("p2"); b.create(p2); + assert(xd::ExampleDialect::isDialectOp(*cast(p2))); + SmallVector varArgs; varArgs.push_back(p1); varArgs.push_back(p2); diff --git a/lib/TableGen/GenDialect.cpp b/lib/TableGen/GenDialect.cpp index 1d35849..39047c9 100644 --- a/lib/TableGen/GenDialect.cpp +++ b/lib/TableGen/GenDialect.cpp @@ -107,6 +107,7 @@ class Builder; public: static Key& getKey(); + static bool isDialectOp(::llvm::CallInst& op); private: $Dialect(::llvm::LLVMContext& context); @@ -298,6 +299,10 @@ void llvm_dialects::genDialectDefs(raw_ostream& out, RecordKeeper& records) { return s_key; } + bool $Dialect::isDialectOp(::llvm::CallInst& op) { + return op.getCalledFunction()->getName().starts_with("$namespace."); + } + ::llvm_dialects::Dialect* $Dialect::make(::llvm::LLVMContext& context) { $0 return new $Dialect(context); diff --git a/test/example/generated/ExampleDialect.cpp.inc b/test/example/generated/ExampleDialect.cpp.inc index 3e37730..ea96fbc 100644 --- a/test/example/generated/ExampleDialect.cpp.inc +++ b/test/example/generated/ExampleDialect.cpp.inc @@ -30,6 +30,10 @@ namespace xd { return s_key; } + bool ExampleDialect::isDialectOp(::llvm::CallInst& op) { + return op.getCalledFunction()->getName().starts_with("xd."); + } + ::llvm_dialects::Dialect* ExampleDialect::make(::llvm::LLVMContext& context) { auto verifierBuild = [](::llvm_dialects::VisitorBuilder<::llvm_dialects::VerifierState> &builder) { diff --git a/test/example/generated/ExampleDialect.h.inc b/test/example/generated/ExampleDialect.h.inc index d6b2a5f..a9ea6bf 100644 --- a/test/example/generated/ExampleDialect.h.inc +++ b/test/example/generated/ExampleDialect.h.inc @@ -32,6 +32,7 @@ namespace xd { public: static Key& getKey(); + static bool isDialectOp(::llvm::CallInst& op); private: ExampleDialect(::llvm::LLVMContext& context);