From dfd414ab770a389d29b7294f20e38cbf74c9f9a9 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Wed, 6 Aug 2003 16:28:49 +0000 Subject: [PATCH] Added asserts to prevent negative shift amounts from being generated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7640 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/CodeEmitterGen.cpp | 2 ++ utils/TableGen/CodeEmitterGen.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/support/tools/TableGen/CodeEmitterGen.cpp b/support/tools/TableGen/CodeEmitterGen.cpp index 076945616f9..a2839c91779 100644 --- a/support/tools/TableGen/CodeEmitterGen.cpp +++ b/support/tools/TableGen/CodeEmitterGen.cpp @@ -131,6 +131,7 @@ void CodeEmitterGen::run(std::ostream &o) { // Mask off the right bits // Low mask (ie. shift, if necessary) + assert(endBitInVar >= 0 && "Negative shift amount in masking!"); if (endBitInVar != 0) { o << " op" << OpOrder[Vals[i].getName()] << " >>= " << endBitInVar << ";\n"; @@ -143,6 +144,7 @@ void CodeEmitterGen::run(std::ostream &o) { << " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; // Shift the value to the correct place (according to place in inst) + assert(endBitInInst >= 0 && "Negative shift amount in inst position!"); if (endBitInInst != 0) o << " op" << OpOrder[Vals[i].getName()] << " <<= " << endBitInInst << ";\n"; diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 076945616f9..a2839c91779 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -131,6 +131,7 @@ void CodeEmitterGen::run(std::ostream &o) { // Mask off the right bits // Low mask (ie. shift, if necessary) + assert(endBitInVar >= 0 && "Negative shift amount in masking!"); if (endBitInVar != 0) { o << " op" << OpOrder[Vals[i].getName()] << " >>= " << endBitInVar << ";\n"; @@ -143,6 +144,7 @@ void CodeEmitterGen::run(std::ostream &o) { << " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; // Shift the value to the correct place (according to place in inst) + assert(endBitInInst >= 0 && "Negative shift amount in inst position!"); if (endBitInInst != 0) o << " op" << OpOrder[Vals[i].getName()] << " <<= " << endBitInInst << ";\n";