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