diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-18 02:12:10 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-18 02:12:10 +0000 |
commit | 10fe0e0d48376e77073520e3601343685fd6bf5b (patch) | |
tree | 1acafe814afb870b33d4d5ed6265fc4f352c402d /llvm/lib/ExecutionEngine/Interpreter/Interpreter.h | |
parent | 4b8d03e084a50722d2fd8e964eb801d9cf7b53d7 (diff) | |
download | bcm5719-llvm-10fe0e0d48376e77073520e3601343685fd6bf5b.tar.gz bcm5719-llvm-10fe0e0d48376e77073520e3601343685fd6bf5b.zip |
Add an inline helper function that masks a GenericValue to a specified
bit width.
llvm-svn: 33325
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Interpreter.h')
-rw-r--r-- | llvm/lib/ExecutionEngine/Interpreter/Interpreter.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h index c62249bdb93..3007b0adb2a 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/llvm/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 |