TargetCallingConv.h revision ce5172098d5eaae22244c925b608fe62a23baaf2
1//===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- 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// This file defines types for working with calling-convention information. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_TARGET_TARGETCALLINGCONV_H 15#define LLVM_TARGET_TARGETCALLINGCONV_H 16 17#include "llvm/CodeGen/SelectionDAGNodes.h" 18 19namespace llvm { 20 21namespace ISD { 22 struct ArgFlagsTy { 23 private: 24 static const uint64_t NoFlagSet = 0ULL; 25 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 26 static const uint64_t ZExtOffs = 0; 27 static const uint64_t SExt = 1ULL<<1; ///< Sign extended 28 static const uint64_t SExtOffs = 1; 29 static const uint64_t InReg = 1ULL<<2; ///< Passed in register 30 static const uint64_t InRegOffs = 2; 31 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 32 static const uint64_t SRetOffs = 3; 33 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 34 static const uint64_t ByValOffs = 4; 35 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 36 static const uint64_t NestOffs = 5; 37 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 38 static const uint64_t ByValAlignOffs = 6; 39 static const uint64_t Split = 1ULL << 10; 40 static const uint64_t SplitOffs = 10; 41 static const uint64_t OrigAlign = 0x1FULL<<27; 42 static const uint64_t OrigAlignOffs = 27; 43 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 44 static const uint64_t ByValSizeOffs = 32; 45 46 static const uint64_t One = 1ULL; //< 1 of this type, for shifts 47 48 uint64_t Flags; 49 public: 50 ArgFlagsTy() : Flags(0) { } 51 52 bool isZExt() const { return Flags & ZExt; } 53 void setZExt() { Flags |= One << ZExtOffs; } 54 55 bool isSExt() const { return Flags & SExt; } 56 void setSExt() { Flags |= One << SExtOffs; } 57 58 bool isInReg() const { return Flags & InReg; } 59 void setInReg() { Flags |= One << InRegOffs; } 60 61 bool isSRet() const { return Flags & SRet; } 62 void setSRet() { Flags |= One << SRetOffs; } 63 64 bool isByVal() const { return Flags & ByVal; } 65 void setByVal() { Flags |= One << ByValOffs; } 66 67 bool isNest() const { return Flags & Nest; } 68 void setNest() { Flags |= One << NestOffs; } 69 70 unsigned getByValAlign() const { 71 return (unsigned) 72 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 73 } 74 void setByValAlign(unsigned A) { 75 Flags = (Flags & ~ByValAlign) | 76 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 77 } 78 79 bool isSplit() const { return Flags & Split; } 80 void setSplit() { Flags |= One << SplitOffs; } 81 82 unsigned getOrigAlign() const { 83 return (unsigned) 84 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 85 } 86 void setOrigAlign(unsigned A) { 87 Flags = (Flags & ~OrigAlign) | 88 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 89 } 90 91 unsigned getByValSize() const { 92 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 93 } 94 void setByValSize(unsigned S) { 95 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 96 } 97 98 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 99 std::string getArgFlagsString(); 100 101 /// getRawBits - Represent the flags as a bunch of bits. 102 uint64_t getRawBits() const { return Flags; } 103 }; 104 105 /// InputArg - This struct carries flags and type information about a 106 /// single incoming (formal) argument or incoming (from the perspective 107 /// of the caller) return value virtual register. 108 /// 109 struct InputArg { 110 ArgFlagsTy Flags; 111 EVT VT; 112 bool Used; 113 114 InputArg() : VT(MVT::Other), Used(false) {} 115 InputArg(ISD::ArgFlagsTy flags, EVT vt, bool used) 116 : Flags(flags), VT(vt), Used(used) { 117 assert(VT.isSimple() && 118 "InputArg value type must be Simple!"); 119 } 120 }; 121 122 /// OutputArg - This struct carries flags and a value for a 123 /// single outgoing (actual) argument or outgoing (from the perspective 124 /// of the caller) return value virtual register. 125 /// 126 struct OutputArg { 127 ArgFlagsTy Flags; 128 SDValue Val; 129 130 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...". 131 bool IsFixed; 132 133 OutputArg() : IsFixed(false) {} 134 OutputArg(ISD::ArgFlagsTy flags, SDValue val, bool isfixed) 135 : Flags(flags), Val(val), IsFixed(isfixed) { 136 assert(Val.getValueType().isSimple() && 137 "OutputArg value type must be Simple!"); 138 } 139 }; 140 141 /// OutputArgReg - This struct carries flags and a register value for a 142 /// single outgoing (actual) argument or outgoing (from the perspective 143 /// of the caller) return value virtual register. 144 /// 145 struct OutputArgReg { 146 ArgFlagsTy Flags; 147 EVT VT; 148 unsigned Reg; 149 150 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...". 151 bool IsFixed; 152 153 OutputArgReg() : IsFixed(false) {} 154 OutputArgReg(ISD::ArgFlagsTy flags, EVT vt, unsigned reg, bool isfixed) 155 : Flags(flags), VT(vt), Reg(reg), IsFixed(isfixed) {} 156 }; 157} 158 159} // end llvm namespace 160 161#endif 162