diff options
author | Chris Lattner <sabre@nondot.org> | 2003-04-23 19:55:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-04-23 19:55:35 +0000 |
commit | ed27f84ed9d7fbd57a51c8bac9fcf718b4b7efe6 (patch) | |
tree | ebc4dd366e4452f2997686b0aec5672e37633ac3 /llvm/lib/ExecutionEngine/Interpreter | |
parent | 93f4ff73a6bd7f968d1cfbccbff7811272f2f0b5 (diff) | |
download | bcm5719-llvm-ed27f84ed9d7fbd57a51c8bac9fcf718b4b7efe6.tar.gz bcm5719-llvm-ed27f84ed9d7fbd57a51c8bac9fcf718b4b7efe6.zip |
Fix a problem with setcc instructions and pointers
llvm-svn: 5886
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter')
-rw-r--r-- | llvm/lib/ExecutionEngine/Interpreter/Execution.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp index 6542111709c..9d5166dab81 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -348,6 +348,15 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2, #define IMPLEMENT_SETCC(OP, TY) \ case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break +// Handle pointers specially because they must be compared with only as much +// width as the host has. We _do not_ want to be comparing 64 bit values when +// running on a 32-bit target, otherwise the upper 32 bits might mess up +// comparisons if they contain garbage. +#define IMPLEMENT_POINTERSETCC(OP) \ + case Type::PointerTyID: \ + Dest.BoolVal = (void*)(intptr_t)Src1.PointerVal OP \ + (void*)(intptr_t)Src2.PointerVal; break + static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, const Type *Ty) { GenericValue Dest; @@ -362,7 +371,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(==, Long); IMPLEMENT_SETCC(==, Float); IMPLEMENT_SETCC(==, Double); - IMPLEMENT_SETCC(==, Pointer); + IMPLEMENT_POINTERSETCC(==); default: std::cout << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; abort(); @@ -384,7 +393,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(!=, Long); IMPLEMENT_SETCC(!=, Float); IMPLEMENT_SETCC(!=, Double); - IMPLEMENT_SETCC(!=, Pointer); + IMPLEMENT_POINTERSETCC(!=); default: std::cout << "Unhandled type for SetNE instruction: " << *Ty << "\n"; @@ -407,7 +416,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<=, Long); IMPLEMENT_SETCC(<=, Float); IMPLEMENT_SETCC(<=, Double); - IMPLEMENT_SETCC(<=, Pointer); + IMPLEMENT_POINTERSETCC(<=); default: std::cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; abort(); @@ -429,7 +438,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>=, Long); IMPLEMENT_SETCC(>=, Float); IMPLEMENT_SETCC(>=, Double); - IMPLEMENT_SETCC(>=, Pointer); + IMPLEMENT_POINTERSETCC(>=); default: std::cout << "Unhandled type for SetGE instruction: " << *Ty << "\n"; abort(); @@ -451,7 +460,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<, Long); IMPLEMENT_SETCC(<, Float); IMPLEMENT_SETCC(<, Double); - IMPLEMENT_SETCC(<, Pointer); + IMPLEMENT_POINTERSETCC(<); default: std::cout << "Unhandled type for SetLT instruction: " << *Ty << "\n"; abort(); @@ -473,7 +482,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>, Long); IMPLEMENT_SETCC(>, Float); IMPLEMENT_SETCC(>, Double); - IMPLEMENT_SETCC(>, Pointer); + IMPLEMENT_POINTERSETCC(>); default: std::cout << "Unhandled type for SetGT instruction: " << *Ty << "\n"; abort(); |