diff --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp index e7d037743f6788..be3fa9a5628b4e 100644 --- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp @@ -47,6 +47,8 @@ struct StrCatCheckResult { }; void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) { + if (Call->getNumArgs() == 0) + return; // Remove 'Foo(' CheckResult->Hints.push_back( FixItHint::CreateRemoval(CharSourceRange::getCharRange( diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp index 2d723797143992..dad8ef857e2a19 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp @@ -121,6 +121,7 @@ struct AlphaNum { AlphaNum &operator=(const AlphaNum &); }; +string StrCat(); string StrCat(const AlphaNum &A); string StrCat(const AlphaNum &A, const AlphaNum &B); string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C); @@ -154,9 +155,11 @@ using absl::StrCat; void Positives() { string S = StrCat(1, StrCat("A", StrCat(1.1))); // CHECK-MESSAGES: [[@LINE-1]]:14: warning: multiple calls to 'absl::StrCat' can be flattened into a single call + // CHECK-FIXES: string S = StrCat(1, "A", 1.1); S = StrCat(StrCat(StrCat(StrCat(StrCat(1))))); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: multiple calls to 'absl::StrCat' can be flattened into a single call + // CHECK-FIXES: S = StrCat(1); // TODO: should trigger. The issue here is that in the current // implementation we ignore any StrCat with StrCat ancestors. Therefore @@ -166,9 +169,11 @@ void Positives() { StrAppend(&S, 001, StrCat(1, 2, "3"), StrCat("FOO")); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call + // CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO"); StrAppend(&S, 001, StrCat(StrCat(1, 2), "3"), StrCat("FOO")); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call + // CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO"); // Too many args. Ignore for now. S = StrCat(1, 2, StrCat(3, 4, 5, 6, 7), 8, 9, 10, @@ -177,6 +182,10 @@ void Positives() { // CHECK-MESSAGES: :[[@LINE-3]]:7: warning: multiple calls to 'absl::StrCat' can be flattened into a single call StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call + // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + + StrCat(1, StrCat()); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call } void Negatives() { diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h index 190e69230c8e15..defc9c7ae482c2 100644 --- a/flang/include/flang/Lower/AbstractConverter.h +++ b/flang/include/flang/Lower/AbstractConverter.h @@ -10,7 +10,7 @@ #define FORTRAN_LOWER_ABSTRACTCONVERTER_H #include "flang/Common/Fortran.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" namespace Fortran { namespace common { diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h index ebaffaa4a6e0ed..3e9e7328044c56 100644 --- a/flang/include/flang/Lower/Bridge.h +++ b/flang/include/flang/Lower/Bridge.h @@ -20,7 +20,7 @@ #include "flang/Common/Fortran.h" #include "flang/Lower/AbstractConverter.h" #include "flang/Optimizer/Support/KindMapping.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" namespace fir { struct NameUniquer; diff --git a/flang/include/flang/Lower/FIRBuilder.h b/flang/include/flang/Lower/FIRBuilder.h index fa9efe267b54a1..f6a1307d06b7da 100644 --- a/flang/include/flang/Lower/FIRBuilder.h +++ b/flang/include/flang/Lower/FIRBuilder.h @@ -21,8 +21,7 @@ #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Support/KindMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp index 079d16d74181ac..272c3c52b7798b 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -12,10 +12,9 @@ #include "flang/Optimizer/Dialect/FIRType.h" #include "mlir/Dialect/CommonFolders.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" -#include "mlir/IR/Function.h" #include "mlir/IR/Matchers.h" -#include "mlir/IR/Module.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/flang/tools/tco/tco.cpp b/flang/tools/tco/tco.cpp index 63a6122b632425..020cb94509c73b 100644 --- a/flang/tools/tco/tco.cpp +++ b/flang/tools/tco/tco.cpp @@ -13,8 +13,8 @@ #include "flang/Optimizer/Dialect/FIRDialect.h" #include "flang/Optimizer/Support/KindMapping.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/Parser.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td index a326de53a4b21a..e69e9e944d5bd5 100644 --- a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td +++ b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td @@ -88,3 +88,19 @@ let TargetPrefix = "ve" in def int_ve_vl_lvm_mmss : GCCBuiltin<"__builtin_ve_vl_ let TargetPrefix = "ve" in def int_ve_vl_lvm_MMss : GCCBuiltin<"__builtin_ve_vl_lvm_MMss">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; let TargetPrefix = "ve" in def int_ve_vl_svm_sms : GCCBuiltin<"__builtin_ve_vl_svm_sms">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; let TargetPrefix = "ve" in def int_ve_vl_svm_sMs : GCCBuiltin<"__builtin_ve_vl_svm_sMs">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdd_vsl : GCCBuiltin<"__builtin_ve_vl_vbrdd_vsl">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdd_vsvl : GCCBuiltin<"__builtin_ve_vl_vbrdd_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdd_vsmvl : GCCBuiltin<"__builtin_ve_vl_vbrdd_vsmvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdl_vsl : GCCBuiltin<"__builtin_ve_vl_vbrdl_vsl">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdl_vsvl : GCCBuiltin<"__builtin_ve_vl_vbrdl_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdl_vsmvl : GCCBuiltin<"__builtin_ve_vl_vbrdl_vsmvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrds_vsl : GCCBuiltin<"__builtin_ve_vl_vbrds_vsl">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrds_vsvl : GCCBuiltin<"__builtin_ve_vl_vbrds_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrds_vsmvl : GCCBuiltin<"__builtin_ve_vl_vbrds_vsmvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdw_vsl : GCCBuiltin<"__builtin_ve_vl_vbrdw_vsl">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdw_vsvl : GCCBuiltin<"__builtin_ve_vl_vbrdw_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vbrdw_vsmvl : GCCBuiltin<"__builtin_ve_vl_vbrdw_vsmvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_pvbrd_vsl : GCCBuiltin<"__builtin_ve_vl_pvbrd_vsl">, Intrinsic<[LLVMType], [LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_pvbrd_vsvl : GCCBuiltin<"__builtin_ve_vl_pvbrd_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_pvbrd_vsMvl : GCCBuiltin<"__builtin_ve_vl_pvbrd_vsMvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType, LLVMType], [IntrNoMem]>; +let TargetPrefix = "ve" in def int_ve_vl_vmv_vsvl : GCCBuiltin<"__builtin_ve_vl_vmv_vsvl">, Intrinsic<[LLVMType], [LLVMType, LLVMType, LLVMType], [IntrNoMem]>; diff --git a/llvm/include/llvm/MC/MCInstPrinter.h b/llvm/include/llvm/MC/MCInstPrinter.h index 751c2bdbf80b3c..8b9ef178e33c1b 100644 --- a/llvm/include/llvm/MC/MCInstPrinter.h +++ b/llvm/include/llvm/MC/MCInstPrinter.h @@ -88,6 +88,10 @@ class MCInstPrinter { /// Specify a stream to emit comments to. void setCommentStream(raw_ostream &OS) { CommentStream = &OS; } + /// Returns a pair containing the mnemonic for \p MI and the number of bits + /// left for further processing by printInstruction (generated by tablegen). + virtual std::pair getMnemonic(const MCInst *MI) = 0; + /// Print the specified MCInst to the specified raw_ostream. /// /// \p Address the address of current instruction on most targets, used to diff --git a/llvm/lib/ExecutionEngine/CMakeLists.txt b/llvm/lib/ExecutionEngine/CMakeLists.txt index 22203da90f7aa3..49a597acb37b24 100644 --- a/llvm/lib/ExecutionEngine/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/CMakeLists.txt @@ -22,10 +22,6 @@ add_llvm_component_library(LLVMExecutionEngine Target ) -if(BUILD_SHARED_LIBS) - target_link_libraries(LLVMExecutionEngine PUBLIC LLVMRuntimeDyld) -endif() - add_subdirectory(Interpreter) add_subdirectory(JITLink) add_subdirectory(MCJIT) diff --git a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt index 512e3523a1eacd..d8088b4fe5a2be 100644 --- a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt @@ -24,10 +24,3 @@ add_llvm_component_library(LLVMJITLink OrcTargetProcess Support ) - -target_link_libraries(LLVMJITLink - PRIVATE - LLVMObject - LLVMOrcTargetProcess - LLVMSupport -) diff --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt index 791b037323f267..cba92a24ebcb26 100644 --- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt @@ -32,6 +32,9 @@ add_llvm_component_library(LLVMOrcJIT intrinsics_gen LINK_COMPONENTS + Analysis + BitReader + BitWriter Core ExecutionEngine JITLink @@ -48,11 +51,3 @@ add_llvm_component_library(LLVMOrcJIT add_subdirectory(Shared) add_subdirectory(TargetProcess) - -target_link_libraries(LLVMOrcJIT - PRIVATE - LLVMAnalysis - LLVMBitReader - LLVMBitWriter - LLVMPasses - ) diff --git a/llvm/lib/FileCheck/CMakeLists.txt b/llvm/lib/FileCheck/CMakeLists.txt index 91c80e1482f198..1e3456279ea010 100644 --- a/llvm/lib/FileCheck/CMakeLists.txt +++ b/llvm/lib/FileCheck/CMakeLists.txt @@ -3,6 +3,7 @@ add_llvm_component_library(LLVMFileCheck ADDITIONAL_HEADER_DIRS "${LLVM_MAIN_INCLUDE_DIR}/llvm/FileCheck" -) -target_link_libraries(LLVMFileCheck LLVMSupport) + LINK_COMPONENTS + Support +) diff --git a/llvm/lib/Frontend/OpenACC/CMakeLists.txt b/llvm/lib/Frontend/OpenACC/CMakeLists.txt index ba340ab9c5619a..3667f46e8e31a8 100644 --- a/llvm/lib/Frontend/OpenACC/CMakeLists.txt +++ b/llvm/lib/Frontend/OpenACC/CMakeLists.txt @@ -12,7 +12,7 @@ add_llvm_component_library(LLVMFrontendOpenACC DEPENDS acc_gen acc_cpp -) - -target_link_libraries(LLVMFrontendOpenACC LLVMSupport) + LINK_COMPONENTS + Support +) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h index 6da5f0e81c803e..20c4e4c750ec6b 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h @@ -30,6 +30,7 @@ class AArch64InstPrinter : public MCInstPrinter { void printRegName(raw_ostream &OS, unsigned RegNo) const override; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; virtual void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O); virtual bool printAliasInstr(const MCInst *MI, uint64_t Address, @@ -203,6 +204,7 @@ class AArch64AppleInstPrinter : public AArch64InstPrinter { void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override; + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O) override; bool printAliasInstr(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h index ed45c5309ea256..64ccb9092ec49a 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h @@ -24,6 +24,7 @@ class AMDGPUInstPrinter : public MCInstPrinter { //Autogenerated by tblgen void printRegName(raw_ostream &OS, unsigned RegNo) const override; + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); @@ -253,6 +254,7 @@ class R600InstPrinter : public MCInstPrinter { void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override; + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/ARC/MCTargetDesc/ARCInstPrinter.h b/llvm/lib/Target/ARC/MCTargetDesc/ARCInstPrinter.h index 266f2de087727d..bcb790c2fa5762 100644 --- a/llvm/lib/Target/ARC/MCTargetDesc/ARCInstPrinter.h +++ b/llvm/lib/Target/ARC/MCTargetDesc/ARCInstPrinter.h @@ -26,6 +26,7 @@ class ARCInstPrinter : public MCInstPrinter { : MCInstPrinter(MAI, MII, MRI) {} // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h index 37cb731ff0014d..d975d799e07916 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h @@ -30,6 +30,7 @@ class ARMInstPrinter : public MCInstPrinter { void printRegName(raw_ostream &OS, unsigned RegNo) const override; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O); virtual bool printAliasInstr(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp index 8ee69201e9324f..d10f0148cb5875 100644 --- a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp +++ b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp @@ -415,6 +415,44 @@ bool AVRExpandPseudo::expand(Block &MBB, BlockIt MBBI) { return true; } +template <> +bool AVRExpandPseudo::expand(Block &MBB, BlockIt MBBI) { + MachineInstr &MI = *MBBI; + Register DstLoReg, DstHiReg; + Register DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + bool DstIsKill = MI.getOperand(1).isKill(); + bool ImpIsDead = MI.getOperand(2).isDead(); + TRI->splitReg(DstReg, DstLoReg, DstHiReg); + + // Do NEG on the upper byte. + auto MIBHI = + buildMI(MBB, MBBI, AVR::NEGRd) + .addReg(DstHiReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstHiReg, getKillRegState(DstIsKill)); + // SREG is always implicitly dead + MIBHI->getOperand(2).setIsDead(); + + // Do NEG on the lower byte. + buildMI(MBB, MBBI, AVR::NEGRd) + .addReg(DstLoReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstLoReg, getKillRegState(DstIsKill)); + + // Do an extra SBCI. + auto MISBCI = + buildMI(MBB, MBBI, AVR::SBCIRdK) + .addReg(DstHiReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstHiReg, getKillRegState(DstIsKill)) + .addImm(0); + if (ImpIsDead) + MISBCI->getOperand(3).setIsDead(); + // SREG is always implicitly killed + MISBCI->getOperand(4).setIsKill(); + + MI.eraseFromParent(); + return true; +} + template <> bool AVRExpandPseudo::expand(Block &MBB, BlockIt MBBI) { MachineInstr &MI = *MBBI; @@ -1616,6 +1654,7 @@ bool AVRExpandPseudo::expandMI(Block &MBB, BlockIt MBBI) { EXPAND(AVR::ORIWRdK); EXPAND(AVR::EORWRdRr); EXPAND(AVR::COMWRd); + EXPAND(AVR::NEGWRd); EXPAND(AVR::CPWRdRr); EXPAND(AVR::CPCWRdRr); EXPAND(AVR::LDIWRdK); diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.td b/llvm/lib/Target/AVR/AVRInstrInfo.td index f03c254382b4f4..8de85f6b36c521 100644 --- a/llvm/lib/Target/AVR/AVRInstrInfo.td +++ b/llvm/lib/Target/AVR/AVRInstrInfo.td @@ -732,13 +732,23 @@ Defs = [SREG] in "comw\t$rd", [(set i16:$rd, (not i16:$src)), (implicit SREG)]>; - //:TODO: optimize NEG for wider types def NEGRd : FRd<0b1001, 0b0100001, (outs GPR8:$rd), (ins GPR8:$src), "neg\t$rd", [(set i8:$rd, (ineg i8:$src)), (implicit SREG)]>; + + // NEGW Rd+1:Rd + // + // Expands to: + // neg Rd+1 + // neg Rd + // sbci Rd+1, 0 + def NEGWRd : Pseudo<(outs DREGS:$rd), + (ins DREGS:$src), + "negw\t$rd", + [(set i16:$rd, (ineg i16:$src)), (implicit SREG)]>; } // TST Rd diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h index 910fd3455dee33..8976ef28f3dcac 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h @@ -45,6 +45,7 @@ class AVRInstPrinter : public MCInstPrinter { void printMemri(const MCInst *MI, unsigned OpNo, raw_ostream &O); // Autogenerated by TableGen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O); void printCustomAliasOperand(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.h b/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.h index 2181bb575cdda0..e76067ea41aed2 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.h +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.h @@ -32,6 +32,7 @@ class BPFInstPrinter : public MCInstPrinter { void printBrTargetOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); }; diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h index cd96a23e1b94c6..76658378c0cd6d 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h @@ -34,6 +34,7 @@ class HexagonInstPrinter : public MCInstPrinter { static char const *getRegisterName(unsigned RegNo); + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); void printOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; void printBrtarget(MCInst const *MI, unsigned OpNo, raw_ostream &O) const; diff --git a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiInstPrinter.h b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiInstPrinter.h index ce6df2969d734e..f0d287c858d864 100644 --- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiInstPrinter.h +++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiInstPrinter.h @@ -43,6 +43,7 @@ class LanaiInstPrinter : public MCInstPrinter { void printMemImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS); void printCustomAliasOperand(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.h b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.h index 6a6b07f2eba01e..08c466377ee3d3 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.h +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.h @@ -26,6 +26,7 @@ namespace llvm { const MCSubtargetInfo &STI, raw_ostream &O) override; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O); void printCustomAliasOperand(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h index 3f534a2f184354..68b13bf1fcc35c 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h @@ -79,6 +79,7 @@ class MipsInstPrinter : public MCInstPrinter { : MCInstPrinter(MAI, MII, MRI) {} // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h index cee0e7eec54afa..503f0497b6f05c 100644 --- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h +++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h @@ -29,6 +29,7 @@ class NVPTXInstPrinter : public MCInstPrinter { const MCSubtargetInfo &STI, raw_ostream &OS) override; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); // End diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h index 9763aeceef941b..2b5414458ce6b4 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h @@ -36,6 +36,7 @@ class PPCInstPrinter : public MCInstPrinter { const MCSubtargetInfo &STI, raw_ostream &O) override; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h index fdaa00c5f8ebc0..70ec0fe2a0cc71 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h @@ -48,6 +48,7 @@ class RISCVInstPrinter : public MCInstPrinter { const MCSubtargetInfo &STI, raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.h b/llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.h index 11587f165ef297..91b78bd03fc389 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.h +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.h @@ -31,6 +31,7 @@ class SparcInstPrinter : public MCInstPrinter { bool isV9(const MCSubtargetInfo &STI) const; // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h index cfe1bd89c3eb2a..0db7279a06c13c 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h @@ -27,6 +27,7 @@ class SystemZInstPrinter : public MCInstPrinter { : MCInstPrinter(MAI, MII, MRI) {} // Automatically generated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td b/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td index e0a25d37100355..a556194dfe6b5a 100644 --- a/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td +++ b/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td @@ -166,3 +166,24 @@ def : Pat<(int_ve_vl_lvm_mmss v256i1:$ptm, uimm6:$N, i64:$sz), (LVMir_m (ULO7 $N def : Pat<(int_ve_vl_lvm_MMss v512i1:$ptm, uimm6:$N, i64:$sz), (LVMyir_y (ULO7 $N), i64:$sz, v512i1:$ptm)>; def : Pat<(int_ve_vl_svm_sms v256i1:$vmz, uimm6:$N), (SVMmi v256i1:$vmz, (ULO7 $N))>; def : Pat<(int_ve_vl_svm_sMs v512i1:$vmz, uimm6:$N), (SVMyi v512i1:$vmz, (ULO7 $N))>; +def : Pat<(int_ve_vl_vbrdd_vsl f64:$sy, i32:$vl), (VBRDrl f64:$sy, i32:$vl)>; +def : Pat<(int_ve_vl_vbrdd_vsvl f64:$sy, v256f64:$pt, i32:$vl), (VBRDrl_v f64:$sy, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdd_vsmvl f64:$sy, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDrml_v f64:$sy, v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdl_vsl i64:$sy, i32:$vl), (VBRDrl i64:$sy, i32:$vl)>; +def : Pat<(int_ve_vl_vbrdl_vsvl i64:$sy, v256f64:$pt, i32:$vl), (VBRDrl_v i64:$sy, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdl_vsmvl i64:$sy, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDrml_v i64:$sy, v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdl_vsl simm7:$I, i32:$vl), (VBRDil (LO7 $I), i32:$vl)>; +def : Pat<(int_ve_vl_vbrdl_vsvl simm7:$I, v256f64:$pt, i32:$vl), (VBRDil_v (LO7 $I), i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdl_vsmvl simm7:$I, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDiml_v (LO7 $I), v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrds_vsl f32:$sy, i32:$vl), (VBRDUrl f32:$sy, i32:$vl)>; +def : Pat<(int_ve_vl_vbrds_vsvl f32:$sy, v256f64:$pt, i32:$vl), (VBRDUrl_v f32:$sy, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrds_vsmvl f32:$sy, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDUrml_v f32:$sy, v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdw_vsl i32:$sy, i32:$vl), (VBRDLrl i32:$sy, i32:$vl)>; +def : Pat<(int_ve_vl_vbrdw_vsvl i32:$sy, v256f64:$pt, i32:$vl), (VBRDLrl_v i32:$sy, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdw_vsmvl i32:$sy, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDLrml_v i32:$sy, v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdw_vsl simm7:$I, i32:$vl), (VBRDLil (LO7 $I), i32:$vl)>; +def : Pat<(int_ve_vl_vbrdw_vsvl simm7:$I, v256f64:$pt, i32:$vl), (VBRDLil_v (LO7 $I), i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_vbrdw_vsmvl simm7:$I, v256i1:$vm, v256f64:$pt, i32:$vl), (VBRDLiml_v (LO7 $I), v256i1:$vm, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_pvbrd_vsl i64:$sy, i32:$vl), (PVBRDrl i64:$sy, i32:$vl)>; +def : Pat<(int_ve_vl_pvbrd_vsvl i64:$sy, v256f64:$pt, i32:$vl), (PVBRDrl_v i64:$sy, i32:$vl, v256f64:$pt)>; +def : Pat<(int_ve_vl_pvbrd_vsMvl i64:$sy, v512i1:$vm, v256f64:$pt, i32:$vl), (PVBRDrml_v i64:$sy, v512i1:$vm, i32:$vl, v256f64:$pt)>; diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.h index f40cef233ac51b..c46411b10b09e2 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.h @@ -52,6 +52,7 @@ class WebAssemblyInstPrinter final : public MCInstPrinter { raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); }; diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h b/llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h index 51ddae61d25102..f7a850571260a3 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h @@ -36,6 +36,7 @@ class X86ATTInstPrinter final : public X86InstPrinterCommon { raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &OS); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86IntelInstPrinter.h b/llvm/lib/Target/X86/MCTargetDesc/X86IntelInstPrinter.h index 82baf611df0383..aa4d0545ea4686 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86IntelInstPrinter.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86IntelInstPrinter.h @@ -37,6 +37,7 @@ class X86IntelInstPrinter final : public X86InstPrinterCommon { raw_ostream &O); // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.h b/llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.h index c7868bf4cf8e04..0ea47106434c9e 100644 --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.h +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.h @@ -27,6 +27,7 @@ class XCoreInstPrinter : public MCInstPrinter { : MCInstPrinter(MAI, MII, MRI) {} // Autogenerated by tblgen. + std::pair getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); static const char *getRegisterName(unsigned RegNo); diff --git a/llvm/test/CodeGen/AVR/neg.ll b/llvm/test/CodeGen/AVR/neg.ll index edcce3409c279b..355e9ab765a96d 100644 --- a/llvm/test/CodeGen/AVR/neg.ll +++ b/llvm/test/CodeGen/AVR/neg.ll @@ -6,3 +6,13 @@ define i8 @neg8(i8 %x) { %sub = sub i8 0, %x ret i8 %sub } + +define i16 @neg16(i16 %x) { +; CHECK-LABEL: neg16: +; CHECK: neg r25 +; CHECK-next: neg r24 +; CHECK-next: sbci r25, 0 +; CHECK-next: ret + %sub = sub i16 0, %x + ret i16 %sub +} diff --git a/llvm/test/CodeGen/AVR/pseudo/NEGWRd.mir b/llvm/test/CodeGen/AVR/pseudo/NEGWRd.mir new file mode 100644 index 00000000000000..0a534ad0c3f212 --- /dev/null +++ b/llvm/test/CodeGen/AVR/pseudo/NEGWRd.mir @@ -0,0 +1,25 @@ +# RUN: llc -O0 -run-pass=avr-expand-pseudo %s -o - | FileCheck %s + +# This test checks the expansion of the 16-bit NEG pseudo instruction. + +--- | + target triple = "avr--" + define void @test_negwrd() { + entry: + ret void + } +... + +--- +name: test_negwrd +body: | + bb.0.entry: + + ; CHECK-LABEL: test_negwrd + + ; CHECK: $r15 = NEGRd $r15, implicit-def dead $sreg + ; CHECK-NEXT: $r14 = NEGRd $r14 + ; CHECK-NEXT: $r15 = SBCIRdK $r15, 0, implicit-def $sreg, implicit killed $sreg + + $r15r14 = NEGWRd $r15r14, implicit-def $sreg +... diff --git a/llvm/test/CodeGen/PowerPC/neg-abs.ll b/llvm/test/CodeGen/PowerPC/neg-abs.ll new file mode 100644 index 00000000000000..b870bd3ce19556 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/neg-abs.ll @@ -0,0 +1,19 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs \ +; RUN: -mtriple=powerpc64le-linux-gnu < %s | FileCheck \ +; RUN: -check-prefix=CHECK-LE %s + +declare i64 @llvm.abs.i64(i64, i1 immarg) + +define i64@neg_abs(i64 %x) { +; CHECK-LE-LABEL: neg_abs: +; CHECK-LE: # %bb.0: +; CHECK-LE-NEXT: sradi r4, r3, 63 +; CHECK-LE-NEXT: add r3, r3, r4 +; CHECK-LE-NEXT: xor r3, r3, r4 +; CHECK-LE-NEXT: neg r3, r3 +; CHECK-LE-NEXT: blr + %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true) + %neg = sub nsw i64 0, %abs + ret i64 %neg +} diff --git a/llvm/test/CodeGen/VE/VELIntrinsics/vbrd.ll b/llvm/test/CodeGen/VE/VELIntrinsics/vbrd.ll new file mode 100644 index 00000000000000..21dc9b6c849885 --- /dev/null +++ b/llvm/test/CodeGen/VE/VELIntrinsics/vbrd.ll @@ -0,0 +1,438 @@ +; RUN: llc < %s -mtriple=ve -mattr=+vpu | FileCheck %s + +;;; Test vector broadcast intrinsic instructions +;;; +;;; Note: +;;; We test VLD*rrl, VLD*irl, VLD*rrl_v, and VLD*irl_v instructions. + +; Function Attrs: nounwind +define void @vbrdd_vsl(double %0, i8* %1) { +; CHECK-LABEL: vbrdd_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vbrd %v0, %s0 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrdd.vsl(double %0, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdd.vsl(double, i32) + +; Function Attrs: nounwind +define void @vbrdd_vsvl(double %0, i8* %1) { +; CHECK-LABEL: vbrdd_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: vbrd %v0, %s0 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrdd.vsvl(double %0, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readonly +declare <256 x double> @llvm.ve.vl.vld.vssl(i64, i8*, i32) + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdd.vsvl(double, <256 x double>, i32) + +; Function Attrs: nounwind writeonly +declare void @llvm.ve.vl.vst.vssl(<256 x double>, i64, i8*, i32) + +; Function Attrs: nounwind +define void @vbrdd_vsmvl(double %0, i8* %1) { +; CHECK-LABEL: vbrdd_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lea.sl %s3, 1138753536 +; CHECK-NEXT: fcmp.d %s4, %s0, %s3 +; CHECK-NEXT: fsub.d %s3, %s0, %s3 +; CHECK-NEXT: cvt.l.d.rz %s3, %s3 +; CHECK-NEXT: xor %s3, %s3, (1)1 +; CHECK-NEXT: cvt.l.d.rz %s5, %s0 +; CHECK-NEXT: cmov.d.lt %s3, %s5, %s4 +; CHECK-NEXT: lvm %vm1, 3, %s3 +; CHECK-NEXT: vbrd %v0, %s0, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = fptoui double %0 to i64 + %5 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %4) + %6 = tail call fast <256 x double> @llvm.ve.vl.vbrdd.vsmvl(double %0, <256 x i1> %5, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %6, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1>, i64, i64) + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdd.vsmvl(double, <256 x i1>, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdl_vsl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vbrd %v0, %s0 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsl(i64 %0, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdl.vsl(i64, i32) + +; Function Attrs: nounwind +define void @vbrdl_vsvl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: vbrd %v0, %s0 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsvl(i64 %0, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdl.vsvl(i64, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdl_vsmvl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lvm %vm1, 3, %s0 +; CHECK-NEXT: vbrd %v0, %s0, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %0) + %5 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsmvl(i64 %0, <256 x i1> %4, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %5, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdl.vsmvl(i64, <256 x i1>, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdl_imm_vsl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_imm_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s0, 256 +; CHECK-NEXT: lvl %s0 +; CHECK-NEXT: vbrd %v0, 31 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsl(i64 31, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind +define void @vbrdl_imm_vsvl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_imm_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s0, 256 +; CHECK-NEXT: lvl %s0 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: vbrd %v0, 31 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsvl(i64 31, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind +define void @vbrdl_imm_vsmvl(i64 %0, i8* %1) { +; CHECK-LABEL: vbrdl_imm_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lvm %vm1, 3, %s0 +; CHECK-NEXT: vbrd %v0, 31, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %0) + %5 = tail call fast <256 x double> @llvm.ve.vl.vbrdl.vsmvl(i64 31, <256 x i1> %4, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %5, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind +define void @vbrds_vsl(float %0, i8* %1) { +; CHECK-LABEL: vbrds_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vbrdu %v0, %s0 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrds.vsl(float %0, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrds.vsl(float, i32) + +; Function Attrs: nounwind +define void @vbrds_vsvl(float %0, i8* %1) { +; CHECK-LABEL: vbrds_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: vbrdu %v0, %s0 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrds.vsvl(float %0, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrds.vsvl(float, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrds_vsmvl(float %0, i8* %1) { +; CHECK-LABEL: vbrds_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lea.sl %s3, 1593835520 +; CHECK-NEXT: fcmp.s %s4, %s0, %s3 +; CHECK-NEXT: fsub.s %s3, %s0, %s3 +; CHECK-NEXT: cvt.d.s %s3, %s3 +; CHECK-NEXT: cvt.l.d.rz %s3, %s3 +; CHECK-NEXT: xor %s3, %s3, (1)1 +; CHECK-NEXT: cvt.d.s %s5, %s0 +; CHECK-NEXT: cvt.l.d.rz %s5, %s5 +; CHECK-NEXT: cmov.s.lt %s3, %s5, %s4 +; CHECK-NEXT: lvm %vm1, 3, %s3 +; CHECK-NEXT: vbrdu %v0, %s0, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = fptoui float %0 to i64 + %5 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %4) + %6 = tail call fast <256 x double> @llvm.ve.vl.vbrds.vsmvl(float %0, <256 x i1> %5, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %6, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrds.vsmvl(float, <256 x i1>, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdw_vsl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1 +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vbrdl %v0, %s0 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsl(i32 %0, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdw.vsl(i32, i32) + +; Function Attrs: nounwind +define void @vbrdw_vsvl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1 +; CHECK-NEXT: vbrdl %v0, %s0 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsvl(i32 %0, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdw.vsvl(i32, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdw_vsmvl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: adds.w.sx %s3, %s0, (0)1 +; CHECK-NEXT: lvm %vm1, 3, %s0 +; CHECK-NEXT: vbrdl %v0, %s3, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = sext i32 %0 to i64 + %5 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %4) + %6 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsmvl(i32 %0, <256 x i1> %5, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %6, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.vbrdw.vsmvl(i32, <256 x i1>, <256 x double>, i32) + +; Function Attrs: nounwind +define void @vbrdw_imm_vsl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_imm_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s0, 256 +; CHECK-NEXT: lvl %s0 +; CHECK-NEXT: vbrdl %v0, 31 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsl(i32 31, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind +define void @vbrdw_imm_vsvl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_imm_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s0, 256 +; CHECK-NEXT: lvl %s0 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: vbrdl %v0, 31 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsvl(i32 31, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind +define void @vbrdw_imm_vsmvl(i32 signext %0, i8* %1) { +; CHECK-LABEL: vbrdw_imm_vsmvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lvm %vm1, 3, %s0 +; CHECK-NEXT: vbrdl %v0, 31, %vm1 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = sext i32 %0 to i64 + %5 = tail call <256 x i1> @llvm.ve.vl.lvm.mmss(<256 x i1> undef, i64 3, i64 %4) + %6 = tail call fast <256 x double> @llvm.ve.vl.vbrdw.vsmvl(i32 31, <256 x i1> %5, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %6, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind +define void @pvbrd_vsl(i64 %0, i8* %1) { +; CHECK-LABEL: pvbrd_vsl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: pvbrd %v0, %s0 +; CHECK-NEXT: #APP +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.pvbrd.vsl(i64 %0, i32 256) + tail call void asm sideeffect "vst ${0:v}, 8, $1", "v,r"(<256 x double> %3, i8* %1) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.pvbrd.vsl(i64, i32) + +; Function Attrs: nounwind +define void @pvbrd_vsvl(i64 %0, i8* %1) { +; CHECK-LABEL: pvbrd_vsvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: pvbrd %v0, %s0 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call fast <256 x double> @llvm.ve.vl.pvbrd.vsvl(i64 %0, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %4, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.pvbrd.vsvl(i64, <256 x double>, i32) + +; Function Attrs: nounwind +define void @pvbrd_vsMvl(i64 %0, i8* %1) { +; CHECK-LABEL: pvbrd_vsMvl: +; CHECK: # %bb.0: +; CHECK-NEXT: lea %s2, 256 +; CHECK-NEXT: lvl %s2 +; CHECK-NEXT: vld %v0, 8, %s1 +; CHECK-NEXT: lvm %vm3, 1, %s0 +; CHECK-NEXT: lvm %vm2, 2, %s0 +; CHECK-NEXT: pvbrd %v0, %s0, %vm2 +; CHECK-NEXT: vst %v0, 8, %s1 +; CHECK-NEXT: b.l.t (, %s10) + %3 = tail call fast <256 x double> @llvm.ve.vl.vld.vssl(i64 8, i8* %1, i32 256) + %4 = tail call <512 x i1> @llvm.ve.vl.lvm.MMss(<512 x i1> undef, i64 1, i64 %0) + %5 = tail call <512 x i1> @llvm.ve.vl.lvm.MMss(<512 x i1> %4, i64 6, i64 %0) + %6 = tail call fast <256 x double> @llvm.ve.vl.pvbrd.vsMvl(i64 %0, <512 x i1> %5, <256 x double> %3, i32 256) + tail call void @llvm.ve.vl.vst.vssl(<256 x double> %6, i64 8, i8* %1, i32 256) + ret void +} + +; Function Attrs: nounwind readnone +declare <512 x i1> @llvm.ve.vl.lvm.MMss(<512 x i1>, i64, i64) + +; Function Attrs: nounwind readnone +declare <256 x double> @llvm.ve.vl.pvbrd.vsMvl(i64, <512 x i1>, <256 x double>, i32) diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp index dfbe8716411d6f..f903be16947604 100644 --- a/llvm/utils/TableGen/AsmWriterEmitter.cpp +++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp @@ -64,9 +64,15 @@ class AsmWriterEmitter { AsmWriterEmitter(RecordKeeper &R); void run(raw_ostream &o); - private: - void EmitPrintInstruction(raw_ostream &o); + void EmitGetMnemonic( + raw_ostream &o, + std::vector> &TableDrivenOperandPrinters, + unsigned &BitsLeft, unsigned &AsmStrBits); + void EmitPrintInstruction( + raw_ostream &o, + std::vector> &TableDrivenOperandPrinters, + unsigned &BitsLeft, unsigned &AsmStrBits); void EmitGetRegisterName(raw_ostream &o); void EmitPrintAliasInstruction(raw_ostream &O); @@ -288,22 +294,19 @@ static void UnescapeAliasString(std::string &Str) { } } -/// EmitPrintInstruction - Generate the code for the "printInstruction" method -/// implementation. Destroys all instances of AsmWriterInst information, by -/// clearing the Instructions vector. -void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) { +void AsmWriterEmitter::EmitGetMnemonic( + raw_ostream &O, + std::vector> &TableDrivenOperandPrinters, + unsigned &BitsLeft, unsigned &AsmStrBits) { Record *AsmWriter = Target.getAsmWriter(); StringRef ClassName = AsmWriter->getValueAsString("AsmWriterClassName"); bool PassSubtarget = AsmWriter->getValueAsInt("PassSubtarget"); - O << "/// printInstruction - This method is automatically generated by " + O << "/// getMnemonic - This method is automatically generated by " "tablegen\n" "/// from the instruction set description.\n" - "void " - << Target.getName() << ClassName - << "::printInstruction(const MCInst *MI, uint64_t Address, " - << (PassSubtarget ? "const MCSubtargetInfo &STI, " : "") - << "raw_ostream &O) {\n"; + "std::pair " + << Target.getName() << ClassName << "::getMnemonic(const MCInst *MI) {\n"; // Build an aggregate string, and build a table of offsets into it. SequenceToOffsetTable StringTable; @@ -349,13 +352,11 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) { } // Figure out how many bits we used for the string index. - unsigned AsmStrBits = Log2_32_Ceil(MaxStringIdx+2); + AsmStrBits = Log2_32_Ceil(MaxStringIdx + 2); // To reduce code size, we compactify common instructions into a few bits // in the opcode-indexed table. - unsigned BitsLeft = OpcodeInfoBits-AsmStrBits; - - std::vector> TableDrivenOperandPrinters; + BitsLeft = OpcodeInfoBits - AsmStrBits; while (true) { std::vector UniqueOperandCommands; @@ -435,15 +436,47 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) { ++Table; } - // Emit the initial tab character. - O << " O << \"\\t\";\n\n"; - O << " // Emit the opcode for the instruction.\n"; O << BitsString; + // Return mnemonic string and bits. + O << " return {AsmStrs+(Bits & " << (1 << AsmStrBits) - 1 + << ")-1, Bits};\n\n"; + + O << "}\n"; +} + +/// EmitPrintInstruction - Generate the code for the "printInstruction" method +/// implementation. Destroys all instances of AsmWriterInst information, by +/// clearing the Instructions vector. +void AsmWriterEmitter::EmitPrintInstruction( + raw_ostream &O, + std::vector> &TableDrivenOperandPrinters, + unsigned &BitsLeft, unsigned &AsmStrBits) { + const unsigned OpcodeInfoBits = 64; + Record *AsmWriter = Target.getAsmWriter(); + StringRef ClassName = AsmWriter->getValueAsString("AsmWriterClassName"); + bool PassSubtarget = AsmWriter->getValueAsInt("PassSubtarget"); + + O << "/// printInstruction - This method is automatically generated by " + "tablegen\n" + "/// from the instruction set description.\n" + "void " + << Target.getName() << ClassName + << "::printInstruction(const MCInst *MI, uint64_t Address, " + << (PassSubtarget ? "const MCSubtargetInfo &STI, " : "") + << "raw_ostream &O) {\n"; + + // Emit the initial tab character. + O << " O << \"\\t\";\n\n"; + // Emit the starting string. - O << " assert(Bits != 0 && \"Cannot print this instruction.\");\n" - << " O << AsmStrs + (Bits & " << (1 << AsmStrBits)-1 << ") - 1;\n\n"; + O << " auto MnemonicInfo = getMnemonic(MI);\n\n"; + O << " O << MnemonicInfo.first;\n\n"; + + O << " uint" << ((BitsLeft < (OpcodeInfoBits - 32)) ? 64 : 32) + << "_t Bits = MnemonicInfo.second;\n" + << " assert(Bits != 0 && \"Cannot print this instruction.\");\n"; // Output the table driven operand information. BitsLeft = OpcodeInfoBits-AsmStrBits; @@ -1262,7 +1295,11 @@ AsmWriterEmitter::AsmWriterEmitter(RecordKeeper &R) : Records(R), Target(R) { } void AsmWriterEmitter::run(raw_ostream &O) { - EmitPrintInstruction(O); + std::vector> TableDrivenOperandPrinters; + unsigned BitsLeft = 0; + unsigned AsmStrBits = 0; + EmitGetMnemonic(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits); + EmitPrintInstruction(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits); EmitGetRegisterName(O); EmitPrintAliasInstruction(O); } diff --git a/mlir/examples/toy/Ch2/include/toy/Dialect.h b/mlir/examples/toy/Ch2/include/toy/Dialect.h index 8bcad903c53870..f33d12928f331e 100644 --- a/mlir/examples/toy/Ch2/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch2/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/Interfaces/SideEffectInterfaces.h" namespace mlir { diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 2541faef4cf502..19e1bf3bec99d7 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp index 1a3e5ddefacf43..53e0ef3fe8f82e 100644 --- a/mlir/examples/toy/Ch2/toyc.cpp +++ b/mlir/examples/toy/Ch2/toyc.cpp @@ -16,8 +16,8 @@ #include #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/Parser.h" diff --git a/mlir/examples/toy/Ch3/include/toy/Dialect.h b/mlir/examples/toy/Ch3/include/toy/Dialect.h index 8bcad903c53870..f33d12928f331e 100644 --- a/mlir/examples/toy/Ch3/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch3/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/Interfaces/SideEffectInterfaces.h" namespace mlir { diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 2541faef4cf502..19e1bf3bec99d7 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp index baef6d47b037a7..46fb98547a5487 100644 --- a/mlir/examples/toy/Ch3/toyc.cpp +++ b/mlir/examples/toy/Ch3/toyc.cpp @@ -15,8 +15,8 @@ #include "toy/Parser.h" #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/Parser.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/examples/toy/Ch4/include/toy/Dialect.h b/mlir/examples/toy/Ch4/include/toy/Dialect.h index 0853347408925e..6d3b1d8aed0cdd 100644 --- a/mlir/examples/toy/Ch4/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch4/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 4a8115b815bb74..2e473495068ebc 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp index af3ae8748d2466..3c49e6724ce51f 100644 --- a/mlir/examples/toy/Ch4/toyc.cpp +++ b/mlir/examples/toy/Ch4/toyc.cpp @@ -16,8 +16,8 @@ #include "toy/Passes.h" #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/Parser.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/examples/toy/Ch5/include/toy/Dialect.h b/mlir/examples/toy/Ch5/include/toy/Dialect.h index 0853347408925e..6d3b1d8aed0cdd 100644 --- a/mlir/examples/toy/Ch5/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch5/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 4a8115b815bb74..2e473495068ebc 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp index fd5fdc1abb63a0..12d7c1052d3937 100644 --- a/mlir/examples/toy/Ch5/toyc.cpp +++ b/mlir/examples/toy/Ch5/toyc.cpp @@ -16,8 +16,8 @@ #include "toy/Passes.h" #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/InitAllDialects.h" #include "mlir/Parser.h" diff --git a/mlir/examples/toy/Ch6/include/toy/Dialect.h b/mlir/examples/toy/Ch6/include/toy/Dialect.h index 0853347408925e..6d3b1d8aed0cdd 100644 --- a/mlir/examples/toy/Ch6/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch6/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index 4a8115b815bb74..2e473495068ebc 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp index c52478ed524425..a9ca0ba8115eed 100644 --- a/mlir/examples/toy/Ch6/toyc.cpp +++ b/mlir/examples/toy/Ch6/toyc.cpp @@ -18,8 +18,8 @@ #include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/ExecutionEngine/OptUtils.h" #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/InitAllDialects.h" #include "mlir/Parser.h" diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h index fb2927834779b4..6bb893557da7d6 100644 --- a/mlir/examples/toy/Ch7/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h @@ -14,8 +14,8 @@ #ifndef MLIR_TUTORIAL_TOY_DIALECT_H_ #define MLIR_TUTORIAL_TOY_DIALECT_H_ +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index a6690b7f8af108..8dec151cc9ea4d 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Verifier.h" diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp index 5928f800cd953b..ced82a5eeebfa9 100644 --- a/mlir/examples/toy/Ch7/toyc.cpp +++ b/mlir/examples/toy/Ch7/toyc.cpp @@ -18,8 +18,8 @@ #include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/ExecutionEngine/OptUtils.h" #include "mlir/IR/AsmState.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/InitAllDialects.h" #include "mlir/Parser.h" diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index 594ea47e99e985..c41b3d08ace00e 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -9,7 +9,7 @@ #ifndef MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ #define MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "llvm/Support/Allocator.h" diff --git a/mlir/include/mlir/CAPI/IR.h b/mlir/include/mlir/CAPI/IR.h index 5baeea3b7edf90..38fd6a9b64fef2 100644 --- a/mlir/include/mlir/CAPI/IR.h +++ b/mlir/include/mlir/CAPI/IR.h @@ -16,9 +16,9 @@ #define MLIR_CAPI_IR_H #include "mlir/CAPI/Wrap.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Identifier.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" DEFINE_C_API_PTR_METHODS(MlirContext, mlir::MLIRContext) diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h index f321659b8d87e6..5eb399a38d28ee 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -15,8 +15,8 @@ #define MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_ #include "mlir/Dialect/LLVMIR/LLVMTypes.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/TypeSupport.h" diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h index 389e5cc6d1fb90..0171c2c4e58205 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h @@ -16,8 +16,7 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/TypeUtilities.h" diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index 5f1c756ca446f7..dec672bde06064 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -12,7 +12,7 @@ #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/IR/AffineMap.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h index 61568df03dcd85..6638a6724bee4b 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h @@ -14,7 +14,7 @@ #define MLIR_DIALECT_SPIRV_SPIRVOPS_H_ #include "mlir/Dialect/SPIRV/SPIRVTypes.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "llvm/Support/PointerLikeTypeTraits.h" diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h index 22f580642a2f60..7feaec85cfab67 100644 --- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h @@ -11,7 +11,7 @@ #include "mlir/Dialect/Vector/VectorOps.h" #include "mlir/Dialect/Vector/VectorUtils.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/PatternMatch.h" namespace mlir { diff --git a/mlir/include/mlir/IR/BuiltinDialect.h b/mlir/include/mlir/IR/BuiltinDialect.h new file mode 100644 index 00000000000000..06d20cbda39985 --- /dev/null +++ b/mlir/include/mlir/IR/BuiltinDialect.h @@ -0,0 +1,93 @@ +//===- BuiltinDialect.h - MLIR Builtin Dialect ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the Builtin dialect and its operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_BUILTINDIALECT_H_ +#define MLIR_IR_BUILTINDIALECT_H_ + +#include "mlir/IR/Dialect.h" +#include "mlir/IR/FunctionSupport.h" +#include "mlir/IR/OwningOpRefBase.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/CallInterfaces.h" +#include "llvm/Support/PointerLikeTypeTraits.h" + +//===----------------------------------------------------------------------===// +// Dialect +//===----------------------------------------------------------------------===// + +#include "mlir/IR/BuiltinDialect.h.inc" + +//===----------------------------------------------------------------------===// +// Dialect Operations +//===----------------------------------------------------------------------===// + +#define GET_OP_CLASSES +#include "mlir/IR/BuiltinOps.h.inc" + +//===----------------------------------------------------------------------===// +// Dialect Utilities +//===----------------------------------------------------------------------===// + +namespace mlir { +/// This class acts as an owning reference to a module, and will automatically +/// destroy the held module on destruction if the held module is valid. +class OwningModuleRef : public OwningOpRefBase { +public: + using OwningOpRefBase::OwningOpRefBase; +}; +} // end namespace mlir + +namespace llvm { +// Functions hash just like pointers. +template <> +struct DenseMapInfo { + static mlir::FuncOp getEmptyKey() { + auto *pointer = llvm::DenseMapInfo::getEmptyKey(); + return mlir::FuncOp::getFromOpaquePointer(pointer); + } + static mlir::FuncOp getTombstoneKey() { + auto *pointer = llvm::DenseMapInfo::getTombstoneKey(); + return mlir::FuncOp::getFromOpaquePointer(pointer); + } + static unsigned getHashValue(mlir::FuncOp val) { + return hash_value(val.getAsOpaquePointer()); + } + static bool isEqual(mlir::FuncOp lhs, mlir::FuncOp rhs) { return lhs == rhs; } +}; + +/// Allow stealing the low bits of FuncOp. +template <> +struct PointerLikeTypeTraits { + static inline void *getAsVoidPointer(mlir::FuncOp val) { + return const_cast(val.getAsOpaquePointer()); + } + static inline mlir::FuncOp getFromVoidPointer(void *p) { + return mlir::FuncOp::getFromOpaquePointer(p); + } + static constexpr int NumLowBitsAvailable = 3; +}; + +/// Allow stealing the low bits of ModuleOp. +template <> +struct PointerLikeTypeTraits { +public: + static inline void *getAsVoidPointer(mlir::ModuleOp val) { + return const_cast(val.getAsOpaquePointer()); + } + static inline mlir::ModuleOp getFromVoidPointer(void *p) { + return mlir::ModuleOp::getFromOpaquePointer(p); + } + static constexpr int NumLowBitsAvailable = 3; +}; +} // end namespace llvm + +#endif // MLIR_IR_BUILTINDIALECT_H_ diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td new file mode 100644 index 00000000000000..bc573e0423d397 --- /dev/null +++ b/mlir/include/mlir/IR/BuiltinOps.td @@ -0,0 +1,235 @@ +//===- BuiltinOps.td - Builtin operation definitions -------*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines the set of builtin MLIR operations. +// +//===----------------------------------------------------------------------===// + +#ifndef BUILTIN_OPS +#define BUILTIN_OPS + +include "mlir/IR/SymbolInterfaces.td" +include "mlir/Interfaces/CallInterfaces.td" + +def Builtin_Dialect : Dialect { + let summary = + "A dialect containing the builtin Attributes, Operations, and Types"; + + let name = ""; + let cppNamespace = "::mlir"; +} + +// Base class for Builtin dialect ops. +class Builtin_Op traits = []> : + Op; + +//===----------------------------------------------------------------------===// +// FuncOp +//===----------------------------------------------------------------------===// + +def FuncOp : Builtin_Op<"func", [ + AffineScope, AutomaticAllocationScope, CallableOpInterface, FunctionLike, + IsolatedFromAbove, Symbol +]> { + let summary = "An operation with a name containing a single `SSACFG` region"; + let description = [{ + Operations within the function cannot implicitly capture values defined + outside of the function, i.e. Functions are `IsolatedFromAbove`. All + external references must use function arguments or attributes that establish + a symbolic connection (e.g. symbols referenced by name via a string + attribute like SymbolRefAttr). An external function declaration (used when + referring to a function declared in some other module) has no body. While + the MLIR textual form provides a nice inline syntax for function arguments, + they are internally represented as “block arguments” to the first block in + the region. + + Only dialect attribute names may be specified in the attribute dictionaries + for function arguments, results, or the function itself. + + Example: + + ```mlir + // External function definitions. + func @abort() + func @scribble(i32, i64, memref) -> f64 + + // A function that returns its argument twice: + func @count(%x: i64) -> (i64, i64) + attributes {fruit: "banana"} { + return %x, %x: i64, i64 + } + + // A function with an argument attribute + func @example_fn_arg(%x: i32 {swift.self = unit}) + + // A function with a result attribute + func @example_fn_result() -> (f64 {dialectName.attrName = 0 : i64}) + + // A function with an attribute + func @example_fn_attr() attributes {dialectName.attrName = false} + ``` + }]; + + let arguments = (ins SymbolNameAttr:$sym_name, + TypeAttr:$type, + OptionalAttr:$sym_visibility); + let regions = (region AnyRegion:$body); + + let builders = [OpBuilderDAG<(ins + "StringRef":$name, "FunctionType":$type, + CArg<"ArrayRef", "{}">:$attrs, + CArg<"ArrayRef", "{}">:$argAttrs) + >]; + let extraClassDeclaration = [{ + static FuncOp create(Location location, StringRef name, FunctionType type, + ArrayRef attrs = {}); + static FuncOp create(Location location, StringRef name, FunctionType type, + iterator_range attrs); + static FuncOp create(Location location, StringRef name, FunctionType type, + ArrayRef attrs, + ArrayRef argAttrs); + + /// Create a deep copy of this function and all of its blocks, remapping any + /// operands that use values outside of the function using the map that is + /// provided (leaving them alone if no entry is present). If the mapper + /// contains entries for function arguments, these arguments are not + /// included in the new function. Replaces references to cloned sub-values + /// with the corresponding value that is copied, and adds those mappings to + /// the mapper. + FuncOp clone(BlockAndValueMapping &mapper); + FuncOp clone(); + + /// Clone the internal blocks and attributes from this function into dest. + /// Any cloned blocks are appended to the back of dest. This function + /// asserts that the attributes of the current function and dest are + /// compatible. + void cloneInto(FuncOp dest, BlockAndValueMapping &mapper); + + //===------------------------------------------------------------------===// + // CallableOpInterface + //===------------------------------------------------------------------===// + + /// Returns the region on the current operation that is callable. This may + /// return null in the case of an external callable object, e.g. an external + /// function. + Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } + + /// Returns the results types that the callable region produces when + /// executed. + ArrayRef getCallableResults() { return getType().getResults(); } + + //===------------------------------------------------------------------===// + // SymbolOpInterface Methods + //===------------------------------------------------------------------===// + + bool isDeclaration() { return isExternal(); } + + private: + // This trait needs access to the hooks defined below. + friend class OpTrait::FunctionLike; + + /// Returns the number of arguments. This is a hook for + /// OpTrait::FunctionLike. + unsigned getNumFuncArguments() { return getType().getInputs().size(); } + + /// Returns the number of results. This is a hook for OpTrait::FunctionLike. + unsigned getNumFuncResults() { return getType().getResults().size(); } + + /// Hook for OpTrait::FunctionLike, called after verifying that the 'type' + /// attribute is present and checks if it holds a function type. Ensures + /// getType, getNumFuncArguments, and getNumFuncResults can be called + /// safely. + LogicalResult verifyType() { + auto type = getTypeAttr().getValue(); + if (!type.isa()) + return emitOpError("requires '" + getTypeAttrName() + + "' attribute of function type"); + return success(); + } + }]; + let parser = [{ return ::parseFuncOp(parser, result); }]; + let printer = [{ return ::print(*this, p); }]; + let verifier = [{ return ::verify(*this); }]; +} + +//===----------------------------------------------------------------------===// +// ModuleOp +//===----------------------------------------------------------------------===// + +def ModuleOp : Builtin_Op<"module", [ + AffineScope, IsolatedFromAbove, NoRegionArguments, SymbolTable, Symbol, + SingleBlockImplicitTerminator<"ModuleTerminatorOp"> +]> { + let summary = "A top level container operation"; + let description = [{ + A `module` represents a top-level container operation. It contains a single + SSACFG region containing a single block which can contain any + operations. Operations within this region cannot implicitly capture values + defined outside the module, i.e. Modules are `IsolatedFromAbove`. Modules + have an optional symbol name which can be used to refer to them in + operations. + + Example: + + ```mlir + module { + func @foo() + } + ``` + }]; + + let arguments = (ins OptionalAttr:$sym_name, + OptionalAttr:$sym_visibility); + let regions = (region SizedRegion<1>:$body); + + let assemblyFormat = "($sym_name^)? attr-dict-with-keyword $body"; + let builders = [OpBuilderDAG<(ins CArg<"Optional", "{}">:$name)>]; + let extraClassDeclaration = [{ + /// Construct a module from the given location with an optional name. + static ModuleOp create(Location loc, Optional name = llvm::None); + + /// Return the name of this module if present. + Optional getName() { return sym_name(); } + + /// Print the this module in the custom top-level form. + void print(raw_ostream &os, OpPrintingFlags flags = llvm::None); + void print(raw_ostream &os, AsmState &state, + OpPrintingFlags flags = llvm::None); + void dump(); + + //===------------------------------------------------------------------===// + // SymbolOpInterface Methods + //===------------------------------------------------------------------===// + + /// A ModuleOp may optionally define a symbol. + bool isOptionalSymbol() { return true; } + }]; + let verifier = [{ return ::verify(*this); }]; + + // We need to ensure the block inside the region is properly terminated; + // the auto-generated builders do not guarantee that. + let skipDefaultBuilders = 1; +} + +//===----------------------------------------------------------------------===// +// ModuleTerminatorOp +//===----------------------------------------------------------------------===// + +def ModuleTerminatorOp : Builtin_Op<"module_terminator", [ + Terminator, HasParent<"ModuleOp"> +]> { + let summary = "A pseudo op that marks the end of a module"; + let description = [{ + `module_terminator` is a special terminator operation for the body of a + `module`, it has no semantic meaning beyond keeping the body of a `module` + well-formed. + }]; + let assemblyFormat = "attr-dict"; +} + +#endif // BUILTIN_OPS diff --git a/mlir/include/mlir/IR/CMakeLists.txt b/mlir/include/mlir/IR/CMakeLists.txt index c65616ff8eca6b..45649b3e759860 100644 --- a/mlir/include/mlir/IR/CMakeLists.txt +++ b/mlir/include/mlir/IR/CMakeLists.txt @@ -1,3 +1,11 @@ add_mlir_interface(OpAsmInterface) add_mlir_interface(SymbolInterfaces) add_mlir_interface(RegionKindInterface) + +set(LLVM_TARGET_DEFINITIONS BuiltinOps.td) +mlir_tablegen(BuiltinOps.h.inc -gen-op-decls) +mlir_tablegen(BuiltinOps.cpp.inc -gen-op-defs) +mlir_tablegen(BuiltinDialect.h.inc -gen-dialect-decls) +add_public_tablegen_target(MLIRBuiltinOpsIncGen) + +add_mlir_doc(BuiltinOps -gen-op-doc Builtin Dialects/) diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 3ff2700a33805b..e8d19de677c435 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -13,137 +13,7 @@ #ifndef MLIR_IR_FUNCTION_H #define MLIR_IR_FUNCTION_H -#include "mlir/IR/Block.h" -#include "mlir/IR/FunctionSupport.h" -#include "mlir/IR/OpDefinition.h" -#include "mlir/IR/SymbolTable.h" -#include "mlir/Interfaces/CallInterfaces.h" -#include "llvm/Support/PointerLikeTypeTraits.h" - -namespace mlir { -//===--------------------------------------------------------------------===// -// Function Operation. -//===--------------------------------------------------------------------===// - -/// FuncOp represents a function, or an operation containing one region that -/// forms a CFG(Control Flow Graph). The region of a function is not allowed to -/// implicitly capture global values, and all external references must use -/// Function arguments or attributes that establish a symbolic connection(e.g. -/// symbols referenced by name via a string attribute). -class FuncOp - : public Op { -public: - using Op::Op; - using Op::print; - - static StringRef getOperationName() { return "func"; } - - static FuncOp create(Location location, StringRef name, FunctionType type, - ArrayRef attrs = {}); - static FuncOp create(Location location, StringRef name, FunctionType type, - iterator_range attrs); - static FuncOp create(Location location, StringRef name, FunctionType type, - ArrayRef attrs, - ArrayRef argAttrs); - - static void build(OpBuilder &builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef attrs = {}, - ArrayRef argAttrs = {}); - - /// Operation hooks. - static ParseResult parse(OpAsmParser &parser, OperationState &result); - void print(OpAsmPrinter &p); - LogicalResult verify(); - - /// Create a deep copy of this function and all of its blocks, remapping - /// any operands that use values outside of the function using the map that is - /// provided (leaving them alone if no entry is present). If the mapper - /// contains entries for function arguments, these arguments are not included - /// in the new function. Replaces references to cloned sub-values with the - /// corresponding value that is copied, and adds those mappings to the mapper. - FuncOp clone(BlockAndValueMapping &mapper); - FuncOp clone(); - - /// Clone the internal blocks and attributes from this function into dest. Any - /// cloned blocks are appended to the back of dest. This function asserts that - /// the attributes of the current function and dest are compatible. - void cloneInto(FuncOp dest, BlockAndValueMapping &mapper); - - //===--------------------------------------------------------------------===// - // CallableOpInterface - //===--------------------------------------------------------------------===// - - /// Returns the region on the current operation that is callable. This may - /// return null in the case of an external callable object, e.g. an external - /// function. - Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } - - /// Returns the results types that the callable region produces when executed. - ArrayRef getCallableResults() { return getType().getResults(); } - - //===--------------------------------------------------------------------===// - // SymbolOpInterface Methods - //===--------------------------------------------------------------------===// - - bool isDeclaration() { return isExternal(); } - -private: - // This trait needs access to the hooks defined below. - friend class OpTrait::FunctionLike; - - /// Returns the number of arguments. This is a hook for OpTrait::FunctionLike. - unsigned getNumFuncArguments() { return getType().getInputs().size(); } - - /// Returns the number of results. This is a hook for OpTrait::FunctionLike. - unsigned getNumFuncResults() { return getType().getResults().size(); } - - /// Hook for OpTrait::FunctionLike, called after verifying that the 'type' - /// attribute is present and checks if it holds a function type. Ensures - /// getType, getNumFuncArguments, and getNumFuncResults can be called safely. - LogicalResult verifyType() { - auto type = getTypeAttr().getValue(); - if (!type.isa()) - return emitOpError("requires '" + getTypeAttrName() + - "' attribute of function type"); - return success(); - } -}; -} // end namespace mlir - -namespace llvm { - -// Functions hash just like pointers. -template <> struct DenseMapInfo { - static mlir::FuncOp getEmptyKey() { - auto pointer = llvm::DenseMapInfo::getEmptyKey(); - return mlir::FuncOp::getFromOpaquePointer(pointer); - } - static mlir::FuncOp getTombstoneKey() { - auto pointer = llvm::DenseMapInfo::getTombstoneKey(); - return mlir::FuncOp::getFromOpaquePointer(pointer); - } - static unsigned getHashValue(mlir::FuncOp val) { - return hash_value(val.getAsOpaquePointer()); - } - static bool isEqual(mlir::FuncOp LHS, mlir::FuncOp RHS) { return LHS == RHS; } -}; - -/// Allow stealing the low bits of FuncOp. -template <> struct PointerLikeTypeTraits { -public: - static inline void *getAsVoidPointer(mlir::FuncOp I) { - return const_cast(I.getAsOpaquePointer()); - } - static inline mlir::FuncOp getFromVoidPointer(void *P) { - return mlir::FuncOp::getFromOpaquePointer(P); - } - static constexpr int NumLowBitsAvailable = 3; -}; - -} // namespace llvm +// TODO: This is a temporary forward until Function.h is removed. +#include "mlir/IR/BuiltinDialect.h" #endif // MLIR_IR_FUNCTION_H diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 8a5101337586db..facbaff5a033c1 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -13,138 +13,7 @@ #ifndef MLIR_IR_MODULE_H #define MLIR_IR_MODULE_H -#include "mlir/IR/OwningOpRefBase.h" -#include "mlir/IR/SymbolTable.h" -#include "llvm/Support/PointerLikeTypeTraits.h" - -namespace mlir { -class ModuleTerminatorOp; - -//===----------------------------------------------------------------------===// -// Module Operation. -//===----------------------------------------------------------------------===// - -/// ModuleOp represents a module, or an operation containing one region with a -/// single block containing opaque operations. The region of a module is not -/// allowed to implicitly capture global values, and all external references -/// must use symbolic references via attributes(e.g. via a string name). -class ModuleOp - : public Op< - ModuleOp, OpTrait::ZeroOperands, OpTrait::ZeroResult, - OpTrait::IsIsolatedFromAbove, OpTrait::AffineScope, - OpTrait::SymbolTable, - OpTrait::SingleBlockImplicitTerminator::Impl, - SymbolOpInterface::Trait, OpTrait::NoRegionArguments> { -public: - using Op::Op; - using Op::print; - - static StringRef getOperationName() { return "module"; } - - static void build(OpBuilder &builder, OperationState &result, - Optional name = llvm::None); - - /// Construct a module from the given location with an optional name. - static ModuleOp create(Location loc, Optional name = llvm::None); - - /// Operation hooks. - static ParseResult parse(OpAsmParser &parser, OperationState &result); - void print(OpAsmPrinter &p); - LogicalResult verify(); - - /// Return body of this module. - Region &getBodyRegion(); - Block *getBody(); - - /// Return the name of this module if present. - Optional getName(); - - /// Print the this module in the custom top-level form. - void print(raw_ostream &os, OpPrintingFlags flags = llvm::None); - void print(raw_ostream &os, AsmState &state, - OpPrintingFlags flags = llvm::None); - void dump(); - - //===--------------------------------------------------------------------===// - // Body Management. - //===--------------------------------------------------------------------===// - - /// Iteration over the operations in the module. - using iterator = Block::iterator; - - iterator begin() { return getBody()->begin(); } - iterator end() { return getBody()->end(); } - Operation &front() { return *begin(); } - - /// This returns a range of operations of the given type 'T' held within the - /// module. - template iterator_range> getOps() { - return getBody()->getOps(); - } - - /// Insert the operation into the back of the body, before the terminator. - void push_back(Operation *op) { - insert(Block::iterator(getBody()->getTerminator()), op); - } - - /// Insert the operation at the given insertion point. Note: The operation is - /// never inserted after the terminator, even if the insertion point is end(). - void insert(Operation *insertPt, Operation *op) { - insert(Block::iterator(insertPt), op); - } - void insert(Block::iterator insertPt, Operation *op) { - auto *body = getBody(); - if (insertPt == body->end()) - insertPt = Block::iterator(body->getTerminator()); - body->getOperations().insert(insertPt, op); - } - - //===--------------------------------------------------------------------===// - // SymbolOpInterface Methods - //===--------------------------------------------------------------------===// - - /// A ModuleOp may optionally define a symbol. - bool isOptionalSymbol() { return true; } -}; - -/// The ModuleTerminatorOp is a special terminator operation for the body of a -/// ModuleOp, it has no semantic meaning beyond keeping the body of a ModuleOp -/// well-formed. -/// -/// This operation does _not_ have a custom syntax. However, ModuleOp will omit -/// the terminator in their custom syntax for brevity. -class ModuleTerminatorOp - : public Op::Impl, OpTrait::IsTerminator> { -public: - using Op::Op; - static StringRef getOperationName() { return "module_terminator"; } - static void build(OpBuilder &, OperationState &) {} -}; - -/// This class acts as an owning reference to a module, and will automatically -/// destroy the held module on destruction if the held module is valid. -class OwningModuleRef : public OwningOpRefBase { -public: - using OwningOpRefBase::OwningOpRefBase; -}; - -} // end namespace mlir - -namespace llvm { - -/// Allow stealing the low bits of ModuleOp. -template <> struct PointerLikeTypeTraits { -public: - static inline void *getAsVoidPointer(mlir::ModuleOp I) { - return const_cast(I.getAsOpaquePointer()); - } - static inline mlir::ModuleOp getFromVoidPointer(void *P) { - return mlir::ModuleOp::getFromOpaquePointer(P); - } - static constexpr int NumLowBitsAvailable = 3; -}; - -} // end namespace llvm +// TODO: This is a temporary forward until Module.h is removed. +#include "mlir/IR/BuiltinDialect.h" #endif // MLIR_IR_MODULE_H diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index d673b2b8161ae8..e594c7ff1d20cd 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -786,6 +786,132 @@ class VariadicSuccessors : public detail::MultiSuccessorTraitBase { }; +//===----------------------------------------------------------------------===// +// SingleBlockImplicitTerminator + +/// This class provides APIs and verifiers for ops with regions having a single +/// block that must terminate with `TerminatorOpType`. +template +struct SingleBlockImplicitTerminator { + template + class Impl : public TraitBase { + private: + /// Builds a terminator operation without relying on OpBuilder APIs to avoid + /// cyclic header inclusion. + static Operation *buildTerminator(OpBuilder &builder, Location loc) { + OperationState state(loc, TerminatorOpType::getOperationName()); + TerminatorOpType::build(builder, state); + return Operation::create(state); + } + + public: + static LogicalResult verifyTrait(Operation *op) { + for (unsigned i = 0, e = op->getNumRegions(); i < e; ++i) { + Region ®ion = op->getRegion(i); + + // Empty regions are fine. + if (region.empty()) + continue; + + // Non-empty regions must contain a single basic block. + if (std::next(region.begin()) != region.end()) + return op->emitOpError("expects region #") + << i << " to have 0 or 1 blocks"; + + Block &block = region.front(); + if (block.empty()) + return op->emitOpError() << "expects a non-empty block"; + Operation &terminator = block.back(); + if (isa(terminator)) + continue; + + return op->emitOpError("expects regions to end with '" + + TerminatorOpType::getOperationName() + + "', found '" + + terminator.getName().getStringRef() + "'") + .attachNote() + << "in custom textual format, the absence of terminator implies " + "'" + << TerminatorOpType::getOperationName() << '\''; + } + + return success(); + } + + /// Ensure that the given region has the terminator required by this trait. + /// If OpBuilder is provided, use it to build the terminator and notify the + /// OpBuilder litsteners accordingly. If only a Builder is provided, locally + /// construct an OpBuilder with no listeners; this should only be used if no + /// OpBuilder is available at the call site, e.g., in the parser. + static void ensureTerminator(Region ®ion, Builder &builder, + Location loc) { + ::mlir::impl::ensureRegionTerminator(region, builder, loc, + buildTerminator); + } + static void ensureTerminator(Region ®ion, OpBuilder &builder, + Location loc) { + ::mlir::impl::ensureRegionTerminator(region, builder, loc, + buildTerminator); + } + + Block *getBody(unsigned idx = 0) { + Region ®ion = this->getOperation()->getRegion(idx); + assert(!region.empty() && "unexpected empty region"); + return ®ion.front(); + } + Region &getBodyRegion(unsigned idx = 0) { + return this->getOperation()->getRegion(idx); + } + + //===------------------------------------------------------------------===// + // Single Region Utilities + //===------------------------------------------------------------------===// + + /// The following are a set of methods only enabled when the parent + /// operation has a single region. Each of these methods take an additional + /// template parameter that represents the concrete operation so that we + /// can use SFINAE to disable the methods for non-single region operations. + template + using enable_if_single_region = + typename std::enable_if_t(), T>; + + template + enable_if_single_region begin() { + return getBody()->begin(); + } + template + enable_if_single_region end() { + return getBody()->end(); + } + template + enable_if_single_region front() { + return *begin(); + } + + /// Insert the operation into the back of the body, before the terminator. + template + enable_if_single_region push_back(Operation *op) { + insert(Block::iterator(getBody()->getTerminator()), op); + } + + /// Insert the operation at the given insertion point. Note: The operation + /// is never inserted after the terminator, even if the insertion point is + /// end(). + template + enable_if_single_region insert(Operation *insertPt, Operation *op) { + insert(Block::iterator(insertPt), op); + } + template + enable_if_single_region insert(Block::iterator insertPt, + Operation *op) { + auto *body = getBody(); + if (insertPt == body->end()) + insertPt = Block::iterator(body->getTerminator()); + body->getOperations().insert(insertPt, op); + } + }; +}; + //===----------------------------------------------------------------------===// // Misc Traits @@ -1036,78 +1162,6 @@ class AutomaticAllocationScope } }; -/// This class provides APIs and verifiers for ops with regions having a single -/// block that must terminate with `TerminatorOpType`. -template struct SingleBlockImplicitTerminator { - template - class Impl : public TraitBase { - private: - /// Builds a terminator operation without relying on OpBuilder APIs to avoid - /// cyclic header inclusion. - static Operation *buildTerminator(OpBuilder &builder, Location loc) { - OperationState state(loc, TerminatorOpType::getOperationName()); - TerminatorOpType::build(builder, state); - return Operation::create(state); - } - - public: - static LogicalResult verifyTrait(Operation *op) { - for (unsigned i = 0, e = op->getNumRegions(); i < e; ++i) { - Region ®ion = op->getRegion(i); - - // Empty regions are fine. - if (region.empty()) - continue; - - // Non-empty regions must contain a single basic block. - if (std::next(region.begin()) != region.end()) - return op->emitOpError("expects region #") - << i << " to have 0 or 1 blocks"; - - Block &block = region.front(); - if (block.empty()) - return op->emitOpError() << "expects a non-empty block"; - Operation &terminator = block.back(); - if (isa(terminator)) - continue; - - return op->emitOpError("expects regions to end with '" + - TerminatorOpType::getOperationName() + - "', found '" + - terminator.getName().getStringRef() + "'") - .attachNote() - << "in custom textual format, the absence of terminator implies " - "'" - << TerminatorOpType::getOperationName() << '\''; - } - - return success(); - } - - /// Ensure that the given region has the terminator required by this trait. - /// If OpBuilder is provided, use it to build the terminator and notify the - /// OpBuilder litsteners accordingly. If only a Builder is provided, locally - /// construct an OpBuilder with no listeners; this should only be used if no - /// OpBuilder is available at the call site, e.g., in the parser. - static void ensureTerminator(Region ®ion, Builder &builder, - Location loc) { - ::mlir::impl::ensureRegionTerminator(region, builder, loc, - buildTerminator); - } - static void ensureTerminator(Region ®ion, OpBuilder &builder, - Location loc) { - ::mlir::impl::ensureRegionTerminator(region, builder, loc, - buildTerminator); - } - - Block *getBody(unsigned idx = 0) { - Region ®ion = this->getOperation()->getRegion(idx); - assert(!region.empty() && "unexpected empty region"); - return ®ion.front(); - } - }; -}; - /// This class provides a verifier for ops that are expecting their parent /// to be one of the given parent ops template diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index fa54cb608cf5dc..5b3c44868db231 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -147,9 +147,9 @@ class Operation final void replaceUsesOfWith(Value from, Value to); /// Replace all uses of results of this operation with the provided 'values'. - template ().begin())> - void replaceAllUsesWith(ValuesT &&values) { + template + std::enable_if_t::value> + replaceAllUsesWith(ValuesT &&values) { assert(std::distance(values.begin(), values.end()) == getNumResults() && "expected 'values' to correspond 1-1 with the number of results"); diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index 6036bf839c646e..89c5fd674554e2 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -9,7 +9,7 @@ #ifndef MLIR_PASS_ANALYSISMANAGER_H #define MLIR_PASS_ANALYSISMANAGER_H -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/PassInstrumentation.h" #include "mlir/Support/LLVM.h" #include "llvm/ADT/DenseMap.h" diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index e21e3e750270cd..164d463c751e70 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -9,8 +9,8 @@ #ifndef MLIR_PASS_PASS_H #define MLIR_PASS_PASS_H +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/Pass/AnalysisManager.h" #include "mlir/Pass/PassRegistry.h" #include "mlir/Support/LogicalResult.h" diff --git a/mlir/include/mlir/Reducer/Tester.h b/mlir/include/mlir/Reducer/Tester.h index 2d173f90953a44..7e27e39bf2d110 100644 --- a/mlir/include/mlir/Reducer/Tester.h +++ b/mlir/include/mlir/Reducer/Tester.h @@ -19,7 +19,7 @@ #include -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 7fc66f18d53c94..0261f734626a8c 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -17,7 +17,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/Transforms/LegalizeForExport.h" #include "mlir/IR/Block.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Value.h" #include "mlir/Target/LLVMIR/TypeTranslation.h" diff --git a/mlir/include/mlir/Transforms/Bufferize.h b/mlir/include/mlir/Transforms/Bufferize.h index 1fde1d2ebce1bd..0d551455c17f76 100644 --- a/mlir/include/mlir/Transforms/Bufferize.h +++ b/mlir/include/mlir/Transforms/Bufferize.h @@ -27,8 +27,8 @@ #include "mlir/Analysis/Liveness.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dominance.h" -#include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index aeaa5cb482ee20..8bebd342a19bb1 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExprVisitor.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Support/MathExtras.h" #include "llvm/ADT/DenseMap.h" diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index 120d4e4a91372b..e8a2d58efbfa83 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "mlir/Support/LLVM.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp index d8ff10f04b7ad3..2c0bc85958a4e4 100644 --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -13,8 +13,8 @@ #include "mlir/CAPI/Support.h" #include "mlir/CAPI/Utils.h" #include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" #include "mlir/IR/Types.h" #include "mlir/Parser.h" diff --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp index ecda71cfb5e52c..d6628a3739232b 100644 --- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp +++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/VectorOps.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp b/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp index a42df092b1565d..6852c6ed4a4f76 100644 --- a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp +++ b/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp @@ -18,8 +18,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassRegistry.h" #include "mlir/Support/LogicalResult.h" diff --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp index ac58b7a7d7f145..ef16e5cdc68f12 100644 --- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp +++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp @@ -21,8 +21,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/StandardTypes.h" #include "llvm/ADT/STLExtras.h" diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 3724879d9329e3..3c9e7f7048973b 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -15,7 +15,7 @@ #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/SPIRV/TargetAndABI.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" using namespace mlir; diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp index f0fff751c91ba6..34408a4467fbff 100644 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -22,8 +22,7 @@ #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/StandardTypes.h" using namespace mlir; diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp index 1b6f0194a55daa..6bc0a87d510063 100644 --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -19,8 +19,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FormatVariadic.h" diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 50d176418600c4..1df19f38dfb7d4 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -25,8 +25,8 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp index ffc88e2054aaf5..2a91037923afd2 100644 --- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp @@ -10,7 +10,7 @@ #include "mlir/Dialect/PDL/IR/PDL.h" #include "mlir/Dialect/PDL/IR/PDLTypes.h" #include "mlir/Dialect/PDLInterp/IR/PDLInterp.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Interfaces/InferTypeOpInterface.h" using namespace mlir; diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp index 9c5f8393e8fdfd..5f452f728dc72f 100644 --- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp +++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" using namespace mlir; diff --git a/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp index 425131f91a28ff..0abffa5d7d8479 100644 --- a/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp +++ b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp @@ -17,8 +17,8 @@ #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp index bb5580ac37ff2d..79e5c4532e6a7b 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -19,7 +19,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp index f27bd640d67c44..5315899d9ff9cb 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp index d70a61261cb2d3..3f75793a6383af 100644 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -19,8 +19,8 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Support/LogicalResult.h" diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index 5e4272e4ea3f50..6fe801fd0d9494 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -16,7 +16,7 @@ #include "mlir/Dialect/Vector/VectorOps.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Target/LLVMIR/TypeTranslation.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index 4c2196ff176f92..122996c727e075 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -9,7 +9,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/OpImplementation.h" diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp index 3b1be4dd5eac44..9d74f4b3818283 100644 --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Affine/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 8b0f7a3829d2b8..6606d971067f3b 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -16,9 +16,9 @@ #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/DialectImplementation.h" #include "mlir/IR/FunctionImplementation.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 5cdb8f326d41d1..b05328eaee93ec 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -13,10 +13,10 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/LLVMTypes.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/DialectImplementation.h" #include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "llvm/ADT/StringSwitch.h" diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp index 3dec1d16987f3f..7134cfc7217f4f 100644 --- a/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp +++ b/mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp @@ -11,7 +11,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" using namespace mlir; diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 2cd52029832db7..004643ab176f72 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -17,9 +17,8 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Matchers.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp index ec2d1d9de5c886..3dcbac3e06b9c7 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/Dialect/Vector/VectorOps.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp index ba25eba95234b7..591a932f56b420 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp @@ -18,8 +18,8 @@ #include "mlir/Dialect/SCF/Utils.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/VectorOps.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dominance.h" -#include "mlir/IR/Function.h" #include "mlir/Transforms/LoopUtils.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/Utils.cpp b/mlir/lib/Dialect/SCF/Transforms/Utils.cpp index baa4608f1f9f60..96386a5d7b88d7 100644 --- a/mlir/lib/Dialect/SCF/Transforms/Utils.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Utils.cpp @@ -15,7 +15,7 @@ #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Transforms/RegionUtils.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 470a4359627093..27af6fc6b7e5be 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/SPIRV/SPIRVTypes.h" #include "mlir/Dialect/SPIRV/TargetAndABI.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp index de148713315eaa..1c417285da2ecc 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp @@ -16,9 +16,8 @@ #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Serialization.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" #include "mlir/Parser.h" #include "mlir/Support/FileUtilities.h" #include "mlir/Translation.h" diff --git a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp index 56fc4a9b60a6c9..e48ed686eba0bd 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp @@ -16,7 +16,7 @@ #include "mlir/Dialect/SPIRV/Passes.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" using namespace mlir; diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index bc584bd628fbaf..629c8e4e6a5fc9 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -13,9 +13,8 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Matchers.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp index 0cc1e7c07aba6a..739ba0e4739066 100644 --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -18,7 +18,7 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp index e488db677fe5f5..ed518b7cf629e6 100644 --- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp @@ -28,10 +28,9 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Location.h" #include "mlir/IR/Matchers.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OperationSupport.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 9a9336e69f6346..e8639bd38707a5 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -12,8 +12,7 @@ //===----------------------------------------------------------------------===// #include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Support/FileUtilities.h" #include "mlir/Target/LLVMIR.h" diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 5644abf29d93e2..15e54c6e47d885 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -15,12 +15,11 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/AsmState.h" #include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/Function.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/Operation.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index 37c4edb7322fb8..2dafc161453a1f 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -9,9 +9,9 @@ #include "mlir/IR/Attributes.h" #include "AttributeDetail.h" #include "mlir/IR/AffineMap.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Types.h" #include "mlir/Interfaces/DecodeAttributesInterfaces.h" diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 6833221f1672fb..22e97e8475d50f 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -10,10 +10,10 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Matchers.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "llvm/Support/raw_ostream.h" using namespace mlir; diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/BuiltinDialect.cpp similarity index 54% rename from mlir/lib/IR/Function.cpp rename to mlir/lib/IR/BuiltinDialect.cpp index 03378f21f638e9..ca080eb17e6763 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/BuiltinDialect.cpp @@ -1,4 +1,4 @@ -//===- Function.cpp - MLIR Function Classes -------------------------------===// +//===- BuiltinDialect.cpp - MLIR Builtin Dialect --------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,19 +6,65 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/FunctionImplementation.h" -#include "llvm/ADT/BitVector.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/StandardTypes.h" #include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/Twine.h" using namespace mlir; //===----------------------------------------------------------------------===// -// Function Operation. +// Builtin Dialect +//===----------------------------------------------------------------------===// + +namespace { +struct BuiltinOpAsmDialectInterface : public OpAsmDialectInterface { + using OpAsmDialectInterface::OpAsmDialectInterface; + + LogicalResult getAlias(Attribute attr, raw_ostream &os) const override { + if (attr.isa()) { + os << "map"; + return success(); + } + if (attr.isa()) { + os << "set"; + return success(); + } + if (attr.isa()) { + os << "loc"; + return success(); + } + return failure(); + } +}; +} // end anonymous namespace. + +/// A builtin dialect to define types/etc that are necessary for the validity of +/// the IR. +void BuiltinDialect::initialize() { + addTypes(); + addAttributes(); + addAttributes(); + addOperations< +#define GET_OP_LIST +#include "mlir/IR/BuiltinOps.cpp.inc" + >(); + addInterfaces(); +} + +//===----------------------------------------------------------------------===// +// FuncOp //===----------------------------------------------------------------------===// FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, @@ -41,14 +87,14 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, return func; } -void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, +void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, FunctionType type, ArrayRef attrs, ArrayRef argAttrs) { - result.addAttribute(SymbolTable::getSymbolAttrName(), - builder.getStringAttr(name)); - result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); - result.attributes.append(attrs.begin(), attrs.end()); - result.addRegion(); + state.addAttribute(SymbolTable::getSymbolAttrName(), + builder.getStringAttr(name)); + state.addAttribute(getTypeAttrName(), TypeAttr::get(type)); + state.attributes.append(attrs.begin(), attrs.end()); + state.addRegion(); if (argAttrs.empty()) return; @@ -56,12 +102,10 @@ void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, SmallString<8> argAttrName; for (unsigned i = 0, e = type.getNumInputs(); i != e; ++i) if (auto argDict = argAttrs[i].getDictionary(builder.getContext())) - result.addAttribute(getArgAttrName(i, argAttrName), argDict); + state.addAttribute(getArgAttrName(i, argAttrName), argDict); } -/// Parsing/Printing methods. - -ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { +static ParseResult parseFuncOp(OpAsmParser &parser, OperationState &result) { auto buildFuncType = [](Builder &builder, ArrayRef argTypes, ArrayRef results, impl::VariadicFlag, std::string &) { @@ -72,25 +116,25 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { buildFuncType); } -void FuncOp::print(OpAsmPrinter &p) { - FunctionType fnType = getType(); - impl::printFunctionLikeOp(p, *this, fnType.getInputs(), /*isVariadic=*/false, +static void print(FuncOp op, OpAsmPrinter &p) { + FunctionType fnType = op.getType(); + impl::printFunctionLikeOp(p, op, fnType.getInputs(), /*isVariadic=*/false, fnType.getResults()); } -LogicalResult FuncOp::verify() { +static LogicalResult verify(FuncOp op) { // If this function is external there is nothing to do. - if (isExternal()) + if (op.isExternal()) return success(); // Verify that the argument list of the function and the arg list of the entry // block line up. The trait already verified that the number of arguments is // the same between the signature and the block. - auto fnInputTypes = getType().getInputs(); - Block &entryBlock = front(); + auto fnInputTypes = op.getType().getInputs(); + Block &entryBlock = op.front(); for (unsigned i = 0, e = entryBlock.getNumArguments(); i != e; ++i) if (fnInputTypes[i] != entryBlock.getArgument(i).getType()) - return emitOpError("type of entry block argument #") + return op.emitOpError("type of entry block argument #") << i << '(' << entryBlock.getArgument(i).getType() << ") must match the type of the corresponding argument in " << "function signature(" << fnInputTypes[i] << ')'; @@ -152,3 +196,46 @@ FuncOp FuncOp::clone() { BlockAndValueMapping mapper; return clone(mapper); } + +//===----------------------------------------------------------------------===// +// ModuleOp +//===----------------------------------------------------------------------===// + +void ModuleOp::build(OpBuilder &builder, OperationState &state, + Optional name) { + ensureTerminator(*state.addRegion(), builder, state.location); + if (name) { + state.attributes.push_back(builder.getNamedAttr( + mlir::SymbolTable::getSymbolAttrName(), builder.getStringAttr(*name))); + } +} + +/// Construct a module from the given context. +ModuleOp ModuleOp::create(Location loc, Optional name) { + OpBuilder builder(loc->getContext()); + return builder.create(loc, name); +} + +static LogicalResult verify(ModuleOp op) { + // Check that none of the attributes are non-dialect attributes, except for + // the symbol related attributes. + for (auto attr : op.getAttrs()) { + if (!attr.first.strref().contains('.') && + !llvm::is_contained( + ArrayRef{mlir::SymbolTable::getSymbolAttrName(), + mlir::SymbolTable::getVisibilityAttrName()}, + attr.first.strref())) + return op.emitOpError() + << "can only contain dialect-specific attributes, found: '" + << attr.first << "'"; + } + + return success(); +} + +//===----------------------------------------------------------------------===// +// TableGen'd op method definitions +//===----------------------------------------------------------------------===// + +#define GET_OP_CLASSES +#include "mlir/IR/BuiltinOps.cpp.inc" diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt index 1305e115649015..5a8d3e20df6a46 100644 --- a/mlir/lib/IR/CMakeLists.txt +++ b/mlir/lib/IR/CMakeLists.txt @@ -5,16 +5,15 @@ add_mlir_library(MLIRIR Attributes.cpp Block.cpp Builders.cpp + BuiltinDialect.cpp Diagnostics.cpp Dialect.cpp Dominance.cpp - Function.cpp FunctionImplementation.cpp FunctionSupport.cpp IntegerSet.cpp Location.cpp MLIRContext.cpp - Module.cpp Operation.cpp OperationSupport.cpp PatternMatch.cpp @@ -33,10 +32,11 @@ add_mlir_library(MLIRIR ${MLIR_MAIN_INCLUDE_DIR}/mlir/IR DEPENDS + MLIRBuiltinOpsIncGen MLIRCallInterfacesIncGen MLIROpAsmInterfaceIncGen - MLIRSymbolInterfacesIncGen MLIRRegionKindInterfaceIncGen + MLIRSymbolInterfacesIncGen LINK_LIBS PUBLIC MLIRSupport diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index cdebb2a5a8d0ae..a714d83c642668 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -16,13 +16,12 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/Identifier.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Location.h" -#include "mlir/IR/Module.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/Types.h" #include "mlir/Support/ThreadLocalCache.h" @@ -82,57 +81,6 @@ void mlir::registerMLIRContextCLOptions() { *clOptions; } -//===----------------------------------------------------------------------===// -// Builtin Dialect -//===----------------------------------------------------------------------===// - -namespace { -struct BuiltinOpAsmDialectInterface : public OpAsmDialectInterface { - using OpAsmDialectInterface::OpAsmDialectInterface; - - LogicalResult getAlias(Attribute attr, raw_ostream &os) const override { - if (attr.isa()) { - os << "map"; - return success(); - } - if (attr.isa()) { - os << "set"; - return success(); - } - if (attr.isa()) { - os << "loc"; - return success(); - } - return failure(); - } -}; - -/// A builtin dialect to define types/etc that are necessary for the validity of -/// the IR. -struct BuiltinDialect : public Dialect { - BuiltinDialect(MLIRContext *context) - : Dialect(/*name=*/"", context, TypeID::get()) { - addTypes(); - addAttributes(); - addAttributes(); - addInterfaces(); - - // TODO: These operations should be moved to a different dialect when they - // have been fully decoupled from the core. - addOperations(); - } - static StringRef getDialectNamespace() { return ""; } -}; -} // end anonymous namespace. - //===----------------------------------------------------------------------===// // Locking Utilities //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp deleted file mode 100644 index 1f1e3aa2d56eee..00000000000000 --- a/mlir/lib/IR/Module.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===- Module.cpp - MLIR Module Operation ---------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "mlir/IR/Module.h" -#include "mlir/IR/Builders.h" -#include "mlir/IR/OpImplementation.h" - -using namespace mlir; - -//===----------------------------------------------------------------------===// -// Module Operation. -//===----------------------------------------------------------------------===// - -void ModuleOp::build(OpBuilder &builder, OperationState &result, - Optional name) { - ensureTerminator(*result.addRegion(), builder, result.location); - if (name) - result.attributes.push_back(builder.getNamedAttr( - mlir::SymbolTable::getSymbolAttrName(), builder.getStringAttr(*name))); -} - -/// Construct a module from the given context. -ModuleOp ModuleOp::create(Location loc, Optional name) { - OperationState state(loc, "module"); - OpBuilder builder(loc->getContext()); - ModuleOp::build(builder, state, name); - return cast(Operation::create(state)); -} - -ParseResult ModuleOp::parse(OpAsmParser &parser, OperationState &result) { - // If the name is present, parse it. - StringAttr nameAttr; - (void)parser.parseOptionalSymbolName( - nameAttr, mlir::SymbolTable::getSymbolAttrName(), result.attributes); - - // If module attributes are present, parse them. - if (parser.parseOptionalAttrDictWithKeyword(result.attributes)) - return failure(); - - // Parse the module body. - auto *body = result.addRegion(); - if (parser.parseRegion(*body, llvm::None, llvm::None)) - return failure(); - - // Ensure that this module has a valid terminator. - ensureTerminator(*body, parser.getBuilder(), result.location); - return success(); -} - -void ModuleOp::print(OpAsmPrinter &p) { - p << "module"; - - if (Optional name = getName()) { - p << ' '; - p.printSymbolName(*name); - } - - // Print the module attributes. - p.printOptionalAttrDictWithKeyword(getAttrs(), - {mlir::SymbolTable::getSymbolAttrName()}); - - // Print the region. - p.printRegion(getOperation()->getRegion(0), /*printEntryBlockArgs=*/false, - /*printBlockTerminators=*/false); -} - -LogicalResult ModuleOp::verify() { - auto &bodyRegion = getOperation()->getRegion(0); - - // The body must contain a single basic block. - if (!llvm::hasSingleElement(bodyRegion)) - return emitOpError("expected body region to have a single block"); - - // Check that none of the attributes are non-dialect attributes, except for - // the symbol related attributes. - for (auto attr : getOperation()->getMutableAttrDict().getAttrs()) { - if (!attr.first.strref().contains('.') && - !llvm::is_contained( - ArrayRef{mlir::SymbolTable::getSymbolAttrName(), - mlir::SymbolTable::getVisibilityAttrName()}, - attr.first.strref())) - return emitOpError( - "can only contain dialect-specific attributes, found: '") - << attr.first << "'"; - } - - return success(); -} - -/// Return body of this module. -Region &ModuleOp::getBodyRegion() { return getOperation()->getRegion(0); } -Block *ModuleOp::getBody() { return &getBodyRegion().front(); } - -Optional ModuleOp::getName() { - if (auto nameAttr = - getAttrOfType(mlir::SymbolTable::getSymbolAttrName())) - return nameAttr.getValue(); - return llvm::None; -} diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 03768b50d0272f..fbb2ec0ac18dbc 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -12,8 +12,8 @@ #include "Parser.h" #include "mlir/IR/AffineMap.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/Parser.h" #include "llvm/ADT/DenseMap.h" diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index 49b3abedc7a2d2..c0a1feb73acac1 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/PassManager.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index f79e618a6f5793..ae10d1059d838b 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -12,9 +12,9 @@ #include "mlir/Pass/Pass.h" #include "PassDetail.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Module.h" #include "mlir/IR/Verifier.h" #include "mlir/Support/FileUtilities.h" #include "llvm/ADT/STLExtras.h" diff --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp index 18d17de92531f8..2a0d6290e820b9 100644 --- a/mlir/lib/Support/MlirOptMain.cpp +++ b/mlir/lib/Support/MlirOptMain.cpp @@ -14,11 +14,11 @@ #include "mlir/Support/MlirOptMain.h" #include "mlir/IR/AsmState.h" #include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/Location.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/Parser.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/TableGen/OpClass.cpp b/mlir/lib/TableGen/OpClass.cpp index ceb4f5ae82a397..2fad62ea81c273 100644 --- a/mlir/lib/TableGen/OpClass.cpp +++ b/mlir/lib/TableGen/OpClass.cpp @@ -303,9 +303,10 @@ void OpClass::writeDeclTo(raw_ostream &os) const { os << "class " << className << " : public ::mlir::Op<" << className; for (const auto &trait : traitsVec) os << ", " << trait; - os << "> {\npublic:\n"; - os << " using Op::Op;\n"; - os << " using Adaptor = " << className << "Adaptor;\n"; + os << "> {\npublic:\n" + << " using Op::Op;\n" + << " using Op::print;\n" + << " using Adaptor = " << className << "Adaptor;\n"; bool hasPrivateMethod = false; forAllMethods([&](const OpMethod &method) { diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index bd93c00409ef29..117a676eb40a3c 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -12,8 +12,8 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Target/LLVMIR.h" #include "mlir/Target/LLVMIR/TypeTranslation.h" diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index bee7d18d75364a..7e6660ad73616f 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -16,7 +16,7 @@ #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/NVVMDialect.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Target/LLVMIR/ModuleTranslation.h" #include "mlir/Translation.h" diff --git a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp index 6bfcf197f8c30e..9fd3c745d811d2 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp @@ -16,8 +16,7 @@ #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/ROCDLDialect.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Target/LLVMIR/ModuleTranslation.h" #include "mlir/Translation.h" diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index a275c83e61e27a..0db5b1cc6f871c 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/IR/Attributes.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/RegionGraphTraits.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index 18c82578acb124..1c5f9f3ffb946d 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -14,7 +14,7 @@ #include "mlir/Transforms/Passes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Interfaces/LoopLikeInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Transforms/LoopUtils.h" diff --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp index 0ed8ca116d40bb..238f5e22c2cf1a 100644 --- a/mlir/lib/Transforms/OpStats.cpp +++ b/mlir/lib/Transforms/OpStats.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "mlir/IR/OperationSupport.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 15ce1c200c8abc..a4a6019717f785 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index dc9db79b60ed8a..615b624cec91ee 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -10,8 +10,7 @@ #include "mlir/IR/Block.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Rewrite/PatternApplicator.h" #include "mlir/Transforms/Utils.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp index db16129abd947d..50b18c84e95ce6 100644 --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -14,7 +14,7 @@ #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "llvm/ADT/MapVector.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp index 1bf9177bd81617..4ac710c02dea4f 100644 --- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp @@ -21,7 +21,7 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Operation.h" #include "mlir/Transforms/LoopUtils.h" #include "llvm/ADT/DenseMap.h" diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 0f49439c064b8f..4498bb55637b49 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -21,7 +21,7 @@ #include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Support/MathExtras.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index cef0a827f08d5f..c83a1160393904 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -18,9 +18,8 @@ #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dominance.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" #include "mlir/Support/MathExtras.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp index 7f47cc25f72032..90f462d7d1c29e 100644 --- a/mlir/lib/Translation/Translation.cpp +++ b/mlir/lib/Translation/Translation.cpp @@ -12,7 +12,7 @@ #include "mlir/Translation.h" #include "mlir/IR/AsmState.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Verifier.h" #include "mlir/Parser.h" #include "mlir/Support/FileUtilities.h" diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 7677c175ec9426..2ac9b2bc3f7c32 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -17,9 +17,9 @@ #include "mlir/EDSC/Builders.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/MLIRContext.h" -#include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" #include "mlir/IR/Types.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp index e211daff725a21..b38e442b60ad27 100644 --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -9,7 +9,7 @@ #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/SPIRV/SPIRVTypes.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp b/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp index b321954c87f387..01274560b7ab67 100644 --- a/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp @@ -11,7 +11,7 @@ #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/SPIRV/SPIRVTypes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index a14fd0b2aac908..d445644a243546 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -9,9 +9,8 @@ #include "TestDialect.h" #include "TestTypes.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Transforms/FoldUtils.h" diff --git a/mlir/test/lib/Dialect/Test/TestDialect.h b/mlir/test/lib/Dialect/Test/TestDialect.h index 3b9e8c5d9ef83a..84ec1fb00d5966 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.h +++ b/mlir/test/lib/Dialect/Test/TestDialect.h @@ -15,8 +15,8 @@ #define MLIR_TESTDIALECT_H #include "mlir/Dialect/Traits.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Function.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/RegionKindInterface.h" diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp index f6b8294258f98b..93800db154af9c 100644 --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp index a065325c41967d..35c6fa0bf51abe 100644 --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Matchers.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestPrintDefUse.cpp b/mlir/test/lib/IR/TestPrintDefUse.cpp index 3153a148477a9c..dc0a186591029e 100644 --- a/mlir/test/lib/IR/TestPrintDefUse.cpp +++ b/mlir/test/lib/IR/TestPrintDefUse.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/IR/TestPrintNesting.cpp b/mlir/test/lib/IR/TestPrintNesting.cpp index 825d241740fda0..8b6ce0c99f9048 100644 --- a/mlir/test/lib/IR/TestPrintNesting.cpp +++ b/mlir/test/lib/IR/TestPrintNesting.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp index a95b2f84cfcf56..0f18405a4df6da 100644 --- a/mlir/test/lib/IR/TestSlicing.cpp +++ b/mlir/test/lib/IR/TestSlicing.cpp @@ -14,8 +14,7 @@ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp index 0ec7f8258050a4..6a0e081849ed08 100644 --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "TestDialect.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp index f6ac0dee437343..d2bb59b0e42cfa 100644 --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index d7b062e588257c..761ca7295d78c1 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -9,7 +9,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/FoldUtils.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp index c56a38eeded0ac..abde1eb3ef4bc4 100644 --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -15,7 +15,7 @@ #include "TestDialect.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/InliningUtils.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp index cdadf3d145a376..25eb5039971f81 100644 --- a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp +++ b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp @@ -24,8 +24,7 @@ #include "mlir/Dialect/LLVMIR/NVVMDialect.h" #include "mlir/ExecutionEngine/JitRunner.h" #include "mlir/ExecutionEngine/OptUtils.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/InitAllDialects.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp b/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp index 2277ecca34d2ef..0fad537d203b76 100644 --- a/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp +++ b/mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp @@ -25,8 +25,7 @@ #include "mlir/Dialect/LLVMIR/ROCDLDialect.h" #include "mlir/ExecutionEngine/JitRunner.h" #include "mlir/ExecutionEngine/OptUtils.h" -#include "mlir/IR/Function.h" -#include "mlir/IR/Module.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/InitAllDialects.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/unittests/Pass/AnalysisManagerTest.cpp b/mlir/unittests/Pass/AnalysisManagerTest.cpp index 3ea88b0f9843e6..fe45f610964623 100644 --- a/mlir/unittests/Pass/AnalysisManagerTest.cpp +++ b/mlir/unittests/Pass/AnalysisManagerTest.cpp @@ -8,7 +8,7 @@ #include "mlir/Pass/AnalysisManager.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/Pass/PassManagerTest.cpp b/mlir/unittests/Pass/PassManagerTest.cpp index d47ba581e72879..1d007fc7a5c702 100644 --- a/mlir/unittests/Pass/PassManagerTest.cpp +++ b/mlir/unittests/Pass/PassManagerTest.cpp @@ -8,7 +8,7 @@ #include "mlir/Pass/PassManager.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/Function.h" +#include "mlir/IR/BuiltinDialect.h" #include "mlir/Pass/Pass.h" #include "gtest/gtest.h"