[llvm-commits] CVS: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h GenericValue.h

Reid Spencer reid at x10sys.com
Mon Mar 5 19:02:11 PST 2007



Changes in directory llvm/include/llvm/ExecutionEngine:

ExecutionEngine.h updated: 1.43 -> 1.44
GenericValue.h updated: 1.10 -> 1.11
---
Log message:

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.


---
Diffs of the changes:  (+16 -23)

 ExecutionEngine.h |    2 +-
 GenericValue.h    |   37 +++++++++++++++----------------------
 2 files changed, 16 insertions(+), 23 deletions(-)


Index: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
diff -u llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.43 llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.44
--- llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.43	Sat Mar  3 12:18:11 2007
+++ llvm/include/llvm/ExecutionEngine/ExecutionEngine.h	Mon Mar  5 21:01:54 2007
@@ -24,7 +24,7 @@
 
 namespace llvm {
 
-union GenericValue;
+struct GenericValue;
 class Constant;
 class Function;
 class GlobalVariable;


Index: llvm/include/llvm/ExecutionEngine/GenericValue.h
diff -u llvm/include/llvm/ExecutionEngine/GenericValue.h:1.10 llvm/include/llvm/ExecutionEngine/GenericValue.h:1.11
--- llvm/include/llvm/ExecutionEngine/GenericValue.h:1.10	Sat Mar  3 01:36:44 2007
+++ llvm/include/llvm/ExecutionEngine/GenericValue.h	Mon Mar  5 21:01:54 2007
@@ -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






More information about the llvm-commits mailing list