Home | History | Annotate | Download | only in ExecutionEngine
      1 //===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // 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 LLVM_EXECUTIONENGINE_GENERICVALUE_H
     16 #define LLVM_EXECUTIONENGINE_GENERICVALUE_H
     17 
     18 #include "llvm/ADT/APInt.h"
     19 #include "llvm/Support/DataTypes.h"
     20 
     21 namespace llvm {
     22 
     23 typedef void* PointerTy;
     24 class APInt;
     25 
     26 struct GenericValue {
     27   struct IntPair {
     28     unsigned int first;
     29     unsigned int second;
     30   };
     31   union {
     32     double          DoubleVal;
     33     float           FloatVal;
     34     PointerTy       PointerVal;
     35     struct IntPair  UIntPairVal;
     36     unsigned char   Untyped[8];
     37   };
     38   APInt IntVal;   // also used for long doubles
     39 
     40   GenericValue() : DoubleVal(0.0), IntVal(1,0) {}
     41   explicit GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
     42 };
     43 
     44 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
     45 inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
     46 
     47 } // End llvm namespace
     48 #endif
     49