aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-16 02:23:22 +0000
committerChris Lattner <sabre@nondot.org>2005-01-16 02:23:22 +0000
commit7636512f59e61429eae8839aa5c472c5e2f24b85 (patch)
treec505a94608134a6d25c403b00850b6a3d1d70ecc /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentc8ea3c47103656a0924909f41651bf5d396c26cd (diff)
Add assertions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19596 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index d3d44a82e0..a8e383060f 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -543,6 +543,37 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand N1, SDOperand N2) {
+#ifndef NDEBUG
+ switch (Opcode) {
+ case ISD::AND:
+ case ISD::OR:
+ case ISD::XOR:
+ case ISD::UDIV:
+ case ISD::UREM:
+ assert(MVT::isInteger(VT) && "This operator does not apply to FP types!");
+ // fall through
+ case ISD::ADD:
+ case ISD::SUB:
+ case ISD::MUL:
+ case ISD::SDIV:
+ case ISD::SREM:
+ assert(N1.getValueType() == N2.getValueType() &&
+ N1.getValueType() == VT && "Binary operator types must match!");
+ break;
+
+ case ISD::SHL:
+ case ISD::SRA:
+ case ISD::SRL:
+ assert(VT == N1.getValueType() &&
+ "Shift operators return type must be the same as their first arg");
+ assert(MVT::isInteger(VT) && MVT::isInteger(N2.getValueType()) &&
+ "Shifts only work on integers");
+ assert(VT >= MVT::i8 && "Shift amount cannot be a MVT::i1");
+ break;
+ default: break;
+ }
+#endif
+
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val);
ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val);
if (N1C) {