llvm.org GIT mirror llvm / 9d87eb1
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 Reid Spencer 13 years ago
2 changed file(s) with 15 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
2323
2424 namespace llvm {
2525
26 union GenericValue;
26 struct GenericValue;
2727 class Constant;
2828 class Function;
2929 class GlobalVariable;
1414 #ifndef GENERIC_VALUE_H
1515 #define GENERIC_VALUE_H
1616
17 #include "llvm/ADT/APInt.h"
1718 #include "llvm/Support/DataTypes.h"
1819
1920 namespace llvm {
2021
21 typedef uintptr_t PointerTy;
22 typedef void* PointerTy;
2223 class APInt;
23 class Type;
2424
25 union GenericValue {
26 bool Int1Val;
27 unsigned char Int8Val;
28 unsigned short Int16Val;
29 unsigned int Int32Val;
30 uint64_t Int64Val;
31 APInt *APIntVal;
32 double DoubleVal;
33 float FloatVal;
34 struct { unsigned int first; unsigned int second; } UIntPairVal;
35 PointerTy PointerVal;
36 unsigned char Untyped[8];
25 struct GenericValue {
26 union {
27 double DoubleVal;
28 float FloatVal;
29 PointerTy PointerVal;
30 struct { unsigned int first; unsigned int second; } UIntPairVal;
31 unsigned char Untyped[8];
32 };
33 APInt IntVal;
3734
38 GenericValue() {}
39 GenericValue(void *V) {
40 PointerVal = (PointerTy)(intptr_t)V;
41 }
35 GenericValue() : DoubleVal(0.0), IntVal(1,0) {}
36 GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
4237 };
4338
4439 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
45 inline void* GVTOP(const GenericValue &GV) {
46 return (void*)(intptr_t)GV.PointerVal;
47 }
40 inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
4841
4942 } // End llvm namespace
5043 #endif