[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / ExecutionEngine / GenericValue.h
blob1ca989da1b7ee7a5cb4bc7a84259d92daeb18c6a
1 //===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // The GenericValue class is used to represent an LLVM value of arbitrary type.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
14 #define LLVM_EXECUTIONENGINE_GENERICVALUE_H
16 #include "llvm/ADT/APInt.h"
17 #include <vector>
19 namespace llvm {
21 using PointerTy = void *;
23 struct GenericValue {
24 struct IntPair {
25 unsigned int first;
26 unsigned int second;
28 union {
29 double DoubleVal;
30 float FloatVal;
31 PointerTy PointerVal;
32 struct IntPair UIntPairVal;
33 unsigned char Untyped[8];
35 APInt IntVal; // also used for long doubles.
36 // For aggregate data types.
37 std::vector<GenericValue> AggregateVal;
39 // to make code faster, set GenericValue to zero could be omitted, but it is
40 // potentially can cause problems, since GenericValue to store garbage
41 // instead of zero.
42 GenericValue() : IntVal(1, 0) {
43 UIntPairVal.first = 0;
44 UIntPairVal.second = 0;
46 explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
49 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
50 inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
52 } // end namespace llvm
54 #endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H