f5e70e5fd56ab0ef38bef5df26b88c3d7ba025a1
[oota-llvm.git] / include / llvm / ExecutionEngine / GenericValue.h
1 //===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
2 // 
3 // The GenericValue class is used to represent an LLVM value of arbitrary type.
4 //
5 //===----------------------------------------------------------------------===//
6
7
8 #ifndef GENERIC_VALUE_H
9 #define GENERIC_VALUE_H
10
11 #include "Support/DataTypes.h"
12
13 typedef uint64_t PointerTy;
14
15 union GenericValue {
16   bool            BoolVal;
17   unsigned char   UByteVal;
18   signed   char   SByteVal;
19   unsigned short  UShortVal;
20   signed   short  ShortVal;
21   unsigned int    UIntVal;
22   signed   int    IntVal;
23   uint64_t        ULongVal;
24   int64_t         LongVal;
25   double          DoubleVal;
26   float           FloatVal;
27   PointerTy       PointerVal;
28   unsigned char   Untyped[8];
29
30   GenericValue() {}
31   GenericValue(void *V) {
32     PointerVal = (PointerTy)(intptr_t)V;
33   }
34 };
35
36 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
37 inline void* GVTOP(const GenericValue &GV) {
38   return (void*)(intptr_t)GV.PointerVal;
39 }
40 #endif