Index: llvm/include/llvm/CodeGen/ValueTypes.h =================================================================== --- llvm/include/llvm/CodeGen/ValueTypes.h +++ llvm/include/llvm/CodeGen/ValueTypes.h @@ -456,6 +456,14 @@ /// This function returns value type as a string, e.g. "i32". std::string getEVTString() const; + /// Support for debugging, callable in GDB: VT.dump() + void dump() const; + + /// Implement operator<<. + void print(raw_ostream &OS) const { + OS << getEVTString(); + } + /// This method returns an LLVM type corresponding to the specified EVT. /// For integer types, this returns an unsigned type. Note that this will /// abort for types that cannot be represented. @@ -516,6 +524,10 @@ TypeSize getExtendedSizeInBits() const LLVM_READONLY; }; + inline raw_ostream &operator<<(raw_ostream &OS, const EVT &V) { + V.print(OS); + return OS; + } } // end namespace llvm #endif // LLVM_CODEGEN_VALUETYPES_H Index: llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -245,8 +245,7 @@ // types are illegal. for (unsigned i = 0, NumResults = N->getNumValues(); i < NumResults; ++i) { EVT ResultVT = N->getValueType(i); - LLVM_DEBUG(dbgs() << "Analyzing result type: " << ResultVT.getEVTString() - << "\n"); + LLVM_DEBUG(dbgs() << "Analyzing result type: " << ResultVT << "\n"); switch (getTypeAction(ResultVT)) { case TargetLowering::TypeLegal: LLVM_DEBUG(dbgs() << "Legal result type\n"); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -698,7 +698,7 @@ else OS << ""; } else if (const VTSDNode *N = dyn_cast(this)) { - OS << ":" << N->getVT().getEVTString(); + OS << ":" << N->getVT(); } else if (const LoadSDNode *LD = dyn_cast(this)) { OS << "<"; @@ -713,7 +713,7 @@ case ISD::ZEXTLOAD: OS << ", zext"; break; } if (doExt) - OS << " from " << LD->getMemoryVT().getEVTString(); + OS << " from " << LD->getMemoryVT(); const char *AM = getIndexedModeName(LD->getAddressingMode()); if (*AM) @@ -725,7 +725,7 @@ printMemOperand(OS, *ST->getMemOperand(), G); if (ST->isTruncatingStore()) - OS << ", trunc to " << ST->getMemoryVT().getEVTString(); + OS << ", trunc to " << ST->getMemoryVT(); const char *AM = getIndexedModeName(ST->getAddressingMode()); if (*AM) @@ -745,7 +745,7 @@ case ISD::ZEXTLOAD: OS << ", zext"; break; } if (doExt) - OS << " from " << MLd->getMemoryVT().getEVTString(); + OS << " from " << MLd->getMemoryVT(); const char *AM = getIndexedModeName(MLd->getAddressingMode()); if (*AM) @@ -760,7 +760,7 @@ printMemOperand(OS, *MSt->getMemOperand(), G); if (MSt->isTruncatingStore()) - OS << ", trunc to " << MSt->getMemoryVT().getEVTString(); + OS << ", trunc to " << MSt->getMemoryVT(); const char *AM = getIndexedModeName(MSt->getAddressingMode()); if (*AM) @@ -782,7 +782,7 @@ case ISD::ZEXTLOAD: OS << ", zext"; break; } if (doExt) - OS << " from " << MGather->getMemoryVT().getEVTString(); + OS << " from " << MGather->getMemoryVT(); auto Signed = MGather->isIndexSigned() ? "signed" : "unsigned"; auto Scaled = MGather->isIndexScaled() ? "scaled" : "unscaled"; @@ -794,7 +794,7 @@ printMemOperand(OS, *MScatter->getMemOperand(), G); if (MScatter->isTruncatingStore()) - OS << ", trunc to " << MScatter->getMemoryVT().getEVTString(); + OS << ", trunc to " << MScatter->getMemoryVT(); auto Signed = MScatter->isIndexSigned() ? "signed" : "unsigned"; auto Scaled = MScatter->isIndexScaled() ? "scaled" : "unscaled"; Index: llvm/lib/CodeGen/ValueTypes.cpp =================================================================== --- llvm/lib/CodeGen/ValueTypes.cpp +++ llvm/lib/CodeGen/ValueTypes.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Type.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/TypeSize.h" #include "llvm/Support/WithColor.h" @@ -176,6 +177,13 @@ } } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +void EVT::dump() const { + print(dbgs()); + dbgs() << "\n"; +} +#endif + /// getTypeForEVT - This method returns an LLVM type corresponding to the /// specified EVT. For integer types, this returns an unsigned type. Note /// that this will abort for types that cannot be represented.