1 //===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines types for working with calling-convention information.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
15 #define LLVM_TARGET_TARGETCALLINGCONV_H
17 #include "llvm/CodeGen/SelectionDAGNodes.h"
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;
46 static const uint64_t One = 1ULL; //< 1 of this type, for shifts
50 ArgFlagsTy() : Flags(0) { }
52 bool isZExt() const { return Flags & ZExt; }
53 void setZExt() { Flags |= One << ZExtOffs; }
55 bool isSExt() const { return Flags & SExt; }
56 void setSExt() { Flags |= One << SExtOffs; }
58 bool isInReg() const { return Flags & InReg; }
59 void setInReg() { Flags |= One << InRegOffs; }
61 bool isSRet() const { return Flags & SRet; }
62 void setSRet() { Flags |= One << SRetOffs; }
64 bool isByVal() const { return Flags & ByVal; }
65 void setByVal() { Flags |= One << ByValOffs; }
67 bool isNest() const { return Flags & Nest; }
68 void setNest() { Flags |= One << NestOffs; }
70 unsigned getByValAlign() const {
72 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
74 void setByValAlign(unsigned A) {
75 Flags = (Flags & ~ByValAlign) |
76 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
79 bool isSplit() const { return Flags & Split; }
80 void setSplit() { Flags |= One << SplitOffs; }
82 unsigned getOrigAlign() const {
84 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
86 void setOrigAlign(unsigned A) {
87 Flags = (Flags & ~OrigAlign) |
88 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
91 unsigned getByValSize() const {
92 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
94 void setByValSize(unsigned S) {
95 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
98 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
99 std::string getArgFlagsString();
101 /// getRawBits - Represent the flags as a bunch of bits.
102 uint64_t getRawBits() const { return Flags; }
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.
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!");
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.
130 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
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!");
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.
145 struct OutputArgReg {
150 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
153 OutputArgReg() : IsFixed(false) {}
154 OutputArgReg(ISD::ArgFlagsTy flags, EVT vt, unsigned reg, bool isfixed)
155 : Flags(flags), VT(vt), Reg(reg), IsFixed(isfixed) {}
159 } // end llvm namespace