1129198Scognet//===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===// 2129198Scognet// 3139735Simp// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4129198Scognet// See https://llvm.org/LICENSE.txt for license information. 5129198Scognet// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6129198Scognet// 7129198Scognet//===----------------------------------------------------------------------===// 8129198Scognet// 9129198Scognet// The GenericValue class is used to represent an LLVM value of arbitrary type. 10129198Scognet// 11129198Scognet//===----------------------------------------------------------------------===// 12129198Scognet 13129198Scognet#ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H 14129198Scognet#define LLVM_EXECUTIONENGINE_GENERICVALUE_H 15129198Scognet 16129198Scognet#include "llvm/ADT/APInt.h" 17129198Scognet#include <vector> 18129198Scognet 19129198Scognetnamespace llvm { 20129198Scognet 21129198Scognetusing PointerTy = void *; 22129198Scognet 23129198Scognetstruct GenericValue { 24129198Scognet struct IntPair { 25129198Scognet unsigned int first; 26129198Scognet unsigned int second; 27129198Scognet }; 28129198Scognet union { 29129198Scognet double DoubleVal; 30129198Scognet float FloatVal; 31129198Scognet PointerTy PointerVal; 32129198Scognet struct IntPair UIntPairVal; 33129198Scognet unsigned char Untyped[8]; 34129198Scognet }; 35129198Scognet APInt IntVal; // also used for long doubles. 36129198Scognet // For aggregate data types. 37129198Scognet std::vector<GenericValue> AggregateVal; 38129198Scognet 39129198Scognet // to make code faster, set GenericValue to zero could be omitted, but it is 40129198Scognet // potentially can cause problems, since GenericValue to store garbage 41129198Scognet // instead of zero. 42150996Scognet GenericValue() : IntVal(1, 0) { 43129198Scognet UIntPairVal.first = 0; 44150996Scognet UIntPairVal.second = 0; 45150996Scognet } 46150996Scognet explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {} 47172614Scognet}; 48129198Scognet 49129198Scognetinline GenericValue PTOGV(void *P) { return GenericValue(P); } 50129198Scognetinline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; } 51129198Scognet 52129198Scognet} // end namespace llvm 53129198Scognet 54129198Scognet#endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H 55129198Scognet