summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorPhilip Reames <preames@rivosinc.com>2023-02-07 10:41:18 -0800
committerPhilip Reames <listmail@philipreames.com>2023-02-07 10:50:14 -0800
commit3be1ae24fb17bf90cb3d8fc8e83ebd9d4523a594 (patch)
treeca9946d20adc81a1fd5fe33d386072719ccf4df8 /llvm/lib/CodeGen
parent07c7784d7bf69b9944b92ecc283cac823bcfce16 (diff)
[CodeGen] Add standard print/debug utilities to MVT
Doing so makes it easier to do printf style debugging in idiomatic manner. I followed the code structure of Value with only the definition of dump being #ifdef out in non-debug builds. Not sure if this is the "right" option; we don't seem to have any single consistent scheme on how dump is handled. Note: This is a follow up to D143454 which did the same for EVT. Differential Revision: https://reviews.llvm.org/D143511
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/CallingConvLower.cpp10
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp2
-rw-r--r--llvm/lib/CodeGen/ValueTypes.cpp12
3 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp
index ce1ef571c9df..fe70f9696eb3 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -129,7 +129,7 @@ void CCState::AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
#ifndef NDEBUG
dbgs() << "Call operand #" << i << " has unhandled type "
- << EVT(ArgVT).getEVTString() << '\n';
+ << ArgVT << '\n';
#endif
llvm_unreachable(nullptr);
}
@@ -147,7 +147,7 @@ void CCState::AnalyzeCallOperands(SmallVectorImpl<MVT> &ArgVTs,
if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
#ifndef NDEBUG
dbgs() << "Call operand #" << i << " has unhandled type "
- << EVT(ArgVT).getEVTString() << '\n';
+ << ArgVT << '\n';
#endif
llvm_unreachable(nullptr);
}
@@ -164,7 +164,7 @@ void CCState::AnalyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins,
if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) {
#ifndef NDEBUG
dbgs() << "Call result #" << i << " has unhandled type "
- << EVT(VT).getEVTString() << '\n';
+ << VT << '\n';
#endif
llvm_unreachable(nullptr);
}
@@ -176,7 +176,7 @@ void CCState::AnalyzeCallResult(MVT VT, CCAssignFn Fn) {
if (Fn(0, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
#ifndef NDEBUG
dbgs() << "Call result has unhandled type "
- << EVT(VT).getEVTString() << '\n';
+ << VT << '\n';
#endif
llvm_unreachable(nullptr);
}
@@ -212,7 +212,7 @@ void CCState::getRemainingRegParmsForType(SmallVectorImpl<MCPhysReg> &Regs,
do {
if (Fn(0, VT, VT, CCValAssign::Full, Flags, *this)) {
#ifndef NDEBUG
- dbgs() << "Call has unhandled type " << EVT(VT).getEVTString()
+ dbgs() << "Call has unhandled type " << VT
<< " while computing remaining regparms\n";
#endif
llvm_unreachable(nullptr);
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 54986ac2ec9f..d4452fa8c9d0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3240,7 +3240,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
if (CaseSize == 0) break;
// Otherwise, execute the case we found.
- LLVM_DEBUG(dbgs() << " TypeSwitch[" << EVT(CurNodeVT).getEVTString()
+ LLVM_DEBUG(dbgs() << " TypeSwitch[" << CurNodeVT
<< "] from " << SwitchStart << " to " << MatcherIndex
<< '\n');
continue;
diff --git a/llvm/lib/CodeGen/ValueTypes.cpp b/llvm/lib/CodeGen/ValueTypes.cpp
index 8530a8da0073..fc8c08e43727 100644
--- a/llvm/lib/CodeGen/ValueTypes.cpp
+++ b/llvm/lib/CodeGen/ValueTypes.cpp
@@ -615,3 +615,15 @@ EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
}
}
}
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+void MVT::dump() const {
+ print(dbgs());
+ dbgs() << "\n";
+}
+#endif
+
+void MVT::print(raw_ostream &OS) const {
+ OS << EVT(*this).getEVTString();
+}
+