From: Reid Spencer Date: Tue, 6 Mar 2007 03:01:54 +0000 (+0000) Subject: Make GenericeValue into a struct with a union instead of just a union. This X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9d87eb19be82b28d288e38eab3bbe145060a0701;p=oota-llvm.git Make GenericeValue into a struct with a union instead of just a union. This allows an APInt value to be constructed. Remove all the native integer types from the union. These are replaced with the single IntVal of type APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34945 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 71aa18e0e50..ab2924ef294 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -24,7 +24,7 @@ namespace llvm { -union GenericValue; +struct GenericValue; class Constant; class Function; class GlobalVariable; diff --git a/include/llvm/ExecutionEngine/GenericValue.h b/include/llvm/ExecutionEngine/GenericValue.h index 930261cecc9..d0cd2cd0bc8 100644 --- a/include/llvm/ExecutionEngine/GenericValue.h +++ b/include/llvm/ExecutionEngine/GenericValue.h @@ -15,37 +15,30 @@ #ifndef GENERIC_VALUE_H #define GENERIC_VALUE_H +#include "llvm/ADT/APInt.h" #include "llvm/Support/DataTypes.h" namespace llvm { -typedef uintptr_t PointerTy; +typedef void* PointerTy; class APInt; -class Type; - -union GenericValue { - bool Int1Val; - unsigned char Int8Val; - unsigned short Int16Val; - unsigned int Int32Val; - uint64_t Int64Val; - APInt *APIntVal; - double DoubleVal; - float FloatVal; - struct { unsigned int first; unsigned int second; } UIntPairVal; - PointerTy PointerVal; - unsigned char Untyped[8]; - - GenericValue() {} - GenericValue(void *V) { - PointerVal = (PointerTy)(intptr_t)V; - } + +struct GenericValue { + union { + double DoubleVal; + float FloatVal; + PointerTy PointerVal; + struct { unsigned int first; unsigned int second; } UIntPairVal; + unsigned char Untyped[8]; + }; + APInt IntVal; + + GenericValue() : DoubleVal(0.0), IntVal(1,0) {} + GenericValue(void *V) : PointerVal(V), IntVal(1,0) { } }; inline GenericValue PTOGV(void *P) { return GenericValue(P); } -inline void* GVTOP(const GenericValue &GV) { - return (void*)(intptr_t)GV.PointerVal; -} +inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; } } // End llvm namespace #endif