1321369Sdim//===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===// 2193323Sed// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6193323Sed// 7193323Sed//===----------------------------------------------------------------------===// 8193323Sed// 9193323Sed// The GenericValue class is used to represent an LLVM value of arbitrary type. 10193323Sed// 11193323Sed//===----------------------------------------------------------------------===// 12193323Sed 13249423Sdim#ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H 14249423Sdim#define LLVM_EXECUTIONENGINE_GENERICVALUE_H 15193323Sed 16193323Sed#include "llvm/ADT/APInt.h" 17309124Sdim#include <vector> 18193323Sed 19193323Sednamespace llvm { 20193323Sed 21321369Sdimusing PointerTy = void *; 22193323Sed 23193323Sedstruct GenericValue { 24249423Sdim struct IntPair { 25249423Sdim unsigned int first; 26249423Sdim unsigned int second; 27249423Sdim }; 28193323Sed union { 29321369Sdim double DoubleVal; 30321369Sdim float FloatVal; 31321369Sdim PointerTy PointerVal; 32321369Sdim struct IntPair UIntPairVal; 33321369Sdim unsigned char Untyped[8]; 34193323Sed }; 35321369Sdim APInt IntVal; // also used for long doubles. 36249423Sdim // For aggregate data types. 37249423Sdim std::vector<GenericValue> AggregateVal; 38193323Sed 39249423Sdim // to make code faster, set GenericValue to zero could be omitted, but it is 40249423Sdim // potentially can cause problems, since GenericValue to store garbage 41249423Sdim // instead of zero. 42321369Sdim GenericValue() : IntVal(1, 0) { 43321369Sdim UIntPairVal.first = 0; 44321369Sdim UIntPairVal.second = 0; 45321369Sdim } 46321369Sdim explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {} 47193323Sed}; 48193323Sed 49193323Sedinline GenericValue PTOGV(void *P) { return GenericValue(P); } 50321369Sdiminline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; } 51193323Sed 52321369Sdim} // end namespace llvm 53321369Sdim 54321369Sdim#endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H 55