Changes For Bug 352
[oota-llvm.git] / include / llvm / ExecutionEngine / GenericValue.h
1 //===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
10 // The GenericValue class is used to represent an LLVM value of arbitrary type.
11 //
12 //===----------------------------------------------------------------------===//
13
14
15 #ifndef GENERIC_VALUE_H
16 #define GENERIC_VALUE_H
17
18 #include "llvm/Support/DataTypes.h"
19
20 namespace llvm {
21
22 typedef uintptr_t PointerTy;
23
24 union GenericValue {
25   bool            BoolVal;
26   unsigned char   UByteVal;
27   signed   char   SByteVal;
28   unsigned short  UShortVal;
29   signed   short  ShortVal;
30   unsigned int    UIntVal;
31   signed   int    IntVal;
32   uint64_t        ULongVal;
33   int64_t         LongVal;
34   double          DoubleVal;
35   float           FloatVal;
36   struct { unsigned int first; unsigned int second; } UIntPairVal;
37   PointerTy       PointerVal;
38   unsigned char   Untyped[8];
39
40   GenericValue() {}
41   GenericValue(void *V) {
42     PointerVal = (PointerTy)(intptr_t)V;
43   }
44 };
45
46 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
47 inline void* GVTOP(const GenericValue &GV) {
48   return (void*)(intptr_t)GV.PointerVal;
49 }
50
51 } // End llvm namespace
52 #endif