aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine/Interpreter
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-18 02:12:10 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-18 02:12:10 +0000
commit90935f608d0f6ea4bfa3dbd999b2e27063195e30 (patch)
tree47e1eb9f1a3852bcc9d32200cbbbf59ba6d401ca /lib/ExecutionEngine/Interpreter
parent071b9d5d7cb6dfe511e2b40aa28f6ee045b2a0bd (diff)
downloadexternal_llvm-90935f608d0f6ea4bfa3dbd999b2e27063195e30.zip
external_llvm-90935f608d0f6ea4bfa3dbd999b2e27063195e30.tar.gz
external_llvm-90935f608d0f6ea4bfa3dbd999b2e27063195e30.tar.bz2
Add an inline helper function that masks a GenericValue to a specified
bit width. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index c62249b..3007b0a 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -231,8 +231,20 @@ private: // Helper functions
GenericValue executeCastOperation(Instruction::CastOps opcode, Value *SrcVal,
const Type *Ty, ExecutionContext &SF);
void popStackAndReturnValueToCaller(const Type *RetTy, GenericValue Result);
+
};
+inline void maskToBitWidth(GenericValue& GV, unsigned BitWidth) {
+ uint64_t BitMask = (1ull << BitWidth) - 1;
+ if (BitWidth <= 8)
+ GV.Int8Val &= BitMask;
+ else if (BitWidth <= 16)
+ GV.Int16Val &= BitMask;
+ else if (BitWidth <= 32)
+ GV.Int32Val &= BitMask;
+ else
+ GV.Int64Val &= BitMask;
+}
} // End llvm namespace
#endif