From: Chris Lattner Date: Fri, 3 May 2002 19:52:30 +0000 (+0000) Subject: Implement the NOT operator. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2adcd83b89d1eb38c7118861454b528d5812aad0;p=oota-llvm.git Implement the NOT operator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2455 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 6254293ad7f..b9f8030a468 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -259,6 +259,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(I), SF); } else { switch (I->getOpcode()) { + case Instruction::Not: executeNotInst(cast(I),SF); break; // Terminators case Instruction::Ret: executeRetInst (cast(I), SF); break; case Instruction::Br: executeBrInst (cast(I), SF); break;