Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:54

0001 //===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // The GenericValue class is used to represent an LLVM value of arbitrary type.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
0014 #define LLVM_EXECUTIONENGINE_GENERICVALUE_H
0015 
0016 #include "llvm/ADT/APInt.h"
0017 #include <vector>
0018 
0019 namespace llvm {
0020 
0021 using PointerTy = void *;
0022 
0023 struct GenericValue {
0024   struct IntPair {
0025     unsigned int first;
0026     unsigned int second;
0027   };
0028   union {
0029     double DoubleVal;
0030     float FloatVal;
0031     PointerTy PointerVal;
0032     struct IntPair UIntPairVal;
0033     unsigned char Untyped[8];
0034   };
0035   APInt IntVal; // also used for long doubles.
0036   // For aggregate data types.
0037   std::vector<GenericValue> AggregateVal;
0038 
0039   // to make code faster, set GenericValue to zero could be omitted, but it is
0040   // potentially can cause problems, since GenericValue to store garbage
0041   // instead of zero.
0042   GenericValue() : IntVal(1, 0) {
0043     UIntPairVal.first = 0;
0044     UIntPairVal.second = 0;
0045   }
0046   explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
0047 };
0048 
0049 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
0050 inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
0051 
0052 } // end namespace llvm
0053 
0054 #endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H