From 7636512f59e61429eae8839aa5c472c5e2f24b85 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 16 Jan 2005 02:23:22 +0000 Subject: [PATCH] Add assertions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19596 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index d3d44a82e08..a8e383060f0 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(N1.Val); ConstantSDNode *N2C = dyn_cast(N2.Val); if (N1C) { -- 2.34.1