LLVM  8.0.1
GenericValue.h
Go to the documentation of this file.
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 #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
15 #define LLVM_EXECUTIONENGINE_GENERICVALUE_H
16 
17 #include "llvm/ADT/APInt.h"
18 #include <vector>
19 
20 namespace llvm {
21 
22 using PointerTy = void *;
23 
24 struct GenericValue {
25  struct IntPair {
26  unsigned int first;
27  unsigned int second;
28  };
29  union {
30  double DoubleVal;
31  float FloatVal;
34  unsigned char Untyped[8];
35  };
36  APInt IntVal; // also used for long doubles.
37  // For aggregate data types.
38  std::vector<GenericValue> AggregateVal;
39 
40  // to make code faster, set GenericValue to zero could be omitted, but it is
41  // potentially can cause problems, since GenericValue to store garbage
42  // instead of zero.
43  GenericValue() : IntVal(1, 0) {
44  UIntPairVal.first = 0;
45  UIntPairVal.second = 0;
46  }
47  explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
48 };
49 
50 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
51 inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
52 
53 } // end namespace llvm
54 
55 #endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H
PointerTy PointerVal
Definition: GenericValue.h:32
std::vector< GenericValue > AggregateVal
Definition: GenericValue.h:38
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned char Untyped[8]
Definition: GenericValue.h:34
void * PointerTy
Definition: GenericValue.h:22
This file implements a class to represent arbitrary precision integral constant values and operations...
#define P(N)
GenericValue(void *V)
Definition: GenericValue.h:47
struct IntPair UIntPairVal
Definition: GenericValue.h:33
void * GVTOP(const GenericValue &GV)
Definition: GenericValue.h:51
GenericValue PTOGV(void *P)
Definition: GenericValue.h:50
Class for arbitrary precision integers.
Definition: APInt.h:70