diff --git a/mlir/test/mlir-tblgen/llvm-intrinsics.td b/mlir/test/mlir-tblgen/llvm-intrinsics.td --- a/mlir/test/mlir-tblgen/llvm-intrinsics.td +++ b/mlir/test/mlir-tblgen/llvm-intrinsics.td @@ -36,3 +36,11 @@ // RUN: | FileCheck --check-prefix=ODS %s // ODS-LABEL: class vastart + +// RUN: cat %S/../../../llvm/include/llvm/IR/Intrinsics.td \ +// RUN: | grep -v "llvm/IR/Intrinsics" \ +// RUN: | mlir-tblgen -gen-llvmir-intrinsics -I %S/../../../llvm/include/ --llvmir-intrinsics-filter=is_constant -dialect-opclass-base My_OpBase \ +// RUN: | FileCheck %s --check-prefix=DIALECT-OPBASE + +// DIALECT-OPBASE-LABEL: def LLVM_is_constant +// DIALECT-OPBASE: My_OpBase<"intr diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp --- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp @@ -32,6 +32,12 @@ "substring in their record name"), llvm::cl::cat(IntrinsicGenCat)); +static llvm::cl::opt + opBaseClass("dialect-opclass-base", + llvm::cl::desc("The base class for the ops in the dialect we " + "are planning to emit"), + llvm::cl::init("LLVM_Op"), llvm::cl::cat(IntrinsicGenCat)); + // Used to represent the indices of overloadable operands/results. using IndicesTy = llvm::SmallBitVector; @@ -205,8 +211,8 @@ "LLVM_Type"); // Emit the definition. - os << "def LLVM_" << intr.getProperRecordName() << " : LLVM_Op<\"intr." - << intr.getOperationName() << "\", ["; + os << "def LLVM_" << intr.getProperRecordName() << " : " << opBaseClass + << "<\"intr." << intr.getOperationName() << "\", ["; mlir::interleaveComma(traits, os); os << "]>, Arguments<(ins" << (operands.empty() ? "" : " "); mlir::interleaveComma(operands, os);