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
This commit is contained in:
Reid Spencer 2007-03-06 03:01:54 +00:00
parent 7ca0689b9b
commit 9d87eb19be
2 changed files with 15 additions and 22 deletions

View File

@ -24,7 +24,7 @@
namespace llvm {
union GenericValue;
struct GenericValue;
class Constant;
class Function;
class GlobalVariable;

View File

@ -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];
struct GenericValue {
union {
double DoubleVal;
float FloatVal;
PointerTy PointerVal;
struct { unsigned int first; unsigned int second; } UIntPairVal;
unsigned char Untyped[8];
};
APInt IntVal;
GenericValue() {}
GenericValue(void *V) {
PointerVal = (PointerTy)(intptr_t)V;
}
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