aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-08-06 16:28:49 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-08-06 16:28:49 +0000
commitdfd414ab770a389d29b7294f20e38cbf74c9f9a9 (patch)
tree59cff411777dc71243801088439c8b7b1a90f316
parent0897c6082215da422a486274efc7bbee78ba9a43 (diff)
downloadexternal_llvm-dfd414ab770a389d29b7294f20e38cbf74c9f9a9.zip
external_llvm-dfd414ab770a389d29b7294f20e38cbf74c9f9a9.tar.gz
external_llvm-dfd414ab770a389d29b7294f20e38cbf74c9f9a9.tar.bz2
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
-rw-r--r--support/tools/TableGen/CodeEmitterGen.cpp2
-rw-r--r--utils/TableGen/CodeEmitterGen.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/support/tools/TableGen/CodeEmitterGen.cpp b/support/tools/TableGen/CodeEmitterGen.cpp
index 0769456..a2839c9 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 0769456..a2839c9 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";