aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine/Interpreter
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-18 01:32:46 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-18 01:32:46 +0000
commit547dcf2467f0701417afca2fd168a57971e7359f (patch)
treef17ad69205b018769e6daecf8ae9887cad89b21a /lib/ExecutionEngine/Interpreter
parent23e28836edaa6750a48dc318c8e2bbe6dc1529c8 (diff)
downloadexternal_llvm-547dcf2467f0701417afca2fd168a57971e7359f.zip
external_llvm-547dcf2467f0701417afca2fd168a57971e7359f.tar.gz
external_llvm-547dcf2467f0701417afca2fd168a57971e7359f.tar.bz2
Make shl instruction mask its result to the correct bitsize. This is
sufficient to get llvm-test/SingleSource/UnitTests/Integer/general-test.ll working with lli in interpreter mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 383e809..177ad36 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -1187,15 +1187,20 @@ static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
GenericValue Dest;
if (const IntegerType *ITy = cast<IntegerType>(Ty)) {
unsigned BitWidth = ITy->getBitWidth();
- if (BitWidth <= 8)
+ uint32_t BitMask = (1ull << BitWidth) - 1;
+ if (BitWidth <= 8) {
Dest.Int8Val = ((uint8_t)Src1.Int8Val) << ((uint32_t)Src2.Int8Val);
- else if (BitWidth <= 16)
+ Dest.Int8Val &= BitMask;
+ } else if (BitWidth <= 16) {
Dest.Int16Val = ((uint16_t)Src1.Int16Val) << ((uint32_t)Src2.Int8Val);
- else if (BitWidth <= 32)
+ Dest.Int16Val &= BitMask;
+ } else if (BitWidth <= 32) {
Dest.Int32Val = ((uint32_t)Src1.Int32Val) << ((uint32_t)Src2.Int8Val);
- else if (BitWidth <= 64)
+ Dest.Int32Val &= BitMask;
+ } else if (BitWidth <= 64) {
Dest.Int64Val = ((uint64_t)Src1.Int64Val) << ((uint32_t)Src2.Int8Val);
- else {
+ Dest.Int64Val &= BitMask;
+ } else {
cerr << "Integer types > 64 bits not supported: " << *Ty << "\n";
abort();
}