[llvm] r262873 - [MachineInstr] Get rid of some GlobalISel ifdefs.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 14:47:23 PST 2016
Author: qcolombet
Date: Mon Mar 7 16:47:23 2016
New Revision: 262873
URL: http://llvm.org/viewvc/llvm-project?rev=262873&view=rev
Log:
[MachineInstr] Get rid of some GlobalISel ifdefs.
Now the type API is always available, but when global-isel is not
built the implementation does nothing.
Note: The implementation free of ifdefs is WIP and tracked here in PR26576.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineInstr.h
llvm/trunk/lib/CodeGen/MachineInstr.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=262873&r1=262872&r2=262873&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Mon Mar 7 16:47:23 2016
@@ -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).
///
Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=262873&r1=262872&r2=262873&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Mar 7 16:47:23 2016
@@ -705,6 +705,25 @@ MachineRegisterInfo *MachineInstr::getRe
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
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;
More information about the llvm-commits
mailing list