Make GenericeValue into a struct with a union instead of just a union. This
authorReid Spencer <rspencer@reidspencer.com>
Tue, 6 Mar 2007 03:01:54 +0000 (03:01 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Tue, 6 Mar 2007 03:01:54 +0000 (03:01 +0000)
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

include/llvm/ExecutionEngine/ExecutionEngine.h
include/llvm/ExecutionEngine/GenericValue.h

index 71aa18e0e502f3b0b6b0de58b09aebca7e08652a..ab2924ef294b358c1b408a3e0cfb73fd55aa519e 100644 (file)
@@ -24,7 +24,7 @@
 
 namespace llvm {
 
-union GenericValue;
+struct GenericValue;
 class Constant;
 class Function;
 class GlobalVariable;
index 930261cecc9da4f2a0e394c38226a001d75fb6cb..d0cd2cd0bc832c22af9dbead148ddb05ccde550b 100644 (file)
 #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