diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-03 19:52:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-03 19:52:30 +0000 |
commit | 79baf91f17d5a43146da893903ca2984ce2f3e9c (patch) | |
tree | 712f203e8eb2b192d00ef5d176adff8c752ce9e7 /llvm/lib/ExecutionEngine/Interpreter/Execution.cpp | |
parent | eb164bc1fb7e407bd2298b69a0b364630ddaceef (diff) | |
download | bcm5719-llvm-79baf91f17d5a43146da893903ca2984ce2f3e9c.tar.gz bcm5719-llvm-79baf91f17d5a43146da893903ca2984ce2f3e9c.zip |
Implement the NOT operator.
llvm-svn: 2455
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Execution.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Interpreter/Execution.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp index 6254293ad7f..b9f8030a468 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -260,6 +260,33 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){ //===----------------------------------------------------------------------===// +// Unary Instruction Implementations +//===----------------------------------------------------------------------===// + +#define IMPLEMENT_UNARY_OPERATOR(OP, TY) \ + case Type::TY##TyID: Dest.TY##Val = OP Src.TY##Val; break + +static void executeNotInst(UnaryOperator *I, ExecutionContext &SF) { + const Type *Ty = I->getOperand(0)->getType(); + GenericValue Src = getOperandValue(I->getOperand(0), SF); + GenericValue Dest; + switch (Ty->getPrimitiveID()) { + IMPLEMENT_UNARY_OPERATOR(~, UByte); + IMPLEMENT_UNARY_OPERATOR(~, SByte); + IMPLEMENT_UNARY_OPERATOR(~, UShort); + IMPLEMENT_UNARY_OPERATOR(~, Short); + IMPLEMENT_UNARY_OPERATOR(~, UInt); + IMPLEMENT_UNARY_OPERATOR(~, Int); + IMPLEMENT_UNARY_OPERATOR(~, ULong); + IMPLEMENT_UNARY_OPERATOR(~, Long); + IMPLEMENT_UNARY_OPERATOR(~, Pointer); + default: + cout << "Unhandled type for Not instruction: " << Ty << "\n"; + } + SetValue(I, Dest, SF); +} + +//===----------------------------------------------------------------------===// // Binary Instruction Implementations //===----------------------------------------------------------------------===// @@ -1152,6 +1179,7 @@ bool Interpreter::executeInstruction() { executeBinaryInst(cast<BinaryOperator>(I), SF); } else { switch (I->getOpcode()) { + case Instruction::Not: executeNotInst(cast<UnaryOperator>(I),SF); break; // Terminators case Instruction::Ret: executeRetInst (cast<ReturnInst>(I), SF); break; case Instruction::Br: executeBrInst (cast<BranchInst>(I), SF); break; |