diff options
| -rw-r--r-- | llvm/include/llvm/CodeGen/MachineInstr.h | 10 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 29 |
2 files changed, 26 insertions, 13 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index da9eddf7ebd..4647a63853c 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -186,16 +186,10 @@ public: Flags &= ~((uint8_t)Flag); } -#ifdef LLVM_BUILD_GLOBAL_ISEL /// Set the type of the instruction. /// \pre getOpcode() is in the range of the generic opcodes. - void setType(Type *Ty) { - assert((!Ty || isPreISelGenericOpcode(getOpcode())) && - "Non generic instructions are not supposed to be typed"); - this->Ty = Ty; - } - Type *getType() const { return Ty; } -#endif + void setType(Type *Ty); + Type *getType() const; /// Return true if MI is in a bundle (but not the first MI in a bundle). /// diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index e1c682e1c8c..bc99a069192 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -705,6 +705,25 @@ MachineRegisterInfo *MachineInstr::getRegInfo() { return nullptr; } +// Implement dummy setter and getter for type when +// global-isel is not built. +// The proper implementation is WIP and is tracked here: +// PR26576. +#ifndef LLVM_BUILD_GLOBAL_ISEL +void MachineInstr::setType(Type *Ty) {} + +Type *MachineInstr::getType() const { return nullptr; } + +#else +void MachineInstr::setType(Type *Ty) { + assert((!Ty || isPreISelGenericOpcode(getOpcode())) && + "Non generic instructions are not supposed to be typed"); + this->Ty = Ty; +} + +Type *MachineInstr::getType() const { return Ty; } +#endif // LLVM_BUILD_GLOBAL_ISEL + /// RemoveRegOperandsFromUseLists - Unlink all of the register operands in /// this instruction from their respective use lists. This requires that the /// operands already be on their use lists. @@ -1688,11 +1707,11 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST, else OS << "UNKNOWN"; - -#ifdef LLVM_BUILD_GLOBAL_ISEL - if (Ty) - OS << ' ' << *Ty << ' '; -#endif + if (getType()) { + OS << ' '; + getType()->print(OS, /*IsForDebug*/ false, /*NoDetails*/ true); + OS << ' '; + } if (SkipOpers) return; |

