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
22 static const uint64_t NoFlagSet = 0ULL;
23 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
24 static const uint64_t ZExtOffs = 0;
25 static const uint64_t SExt = 1ULL<<1; ///< Sign extended
26 static const uint64_t SExtOffs = 1;
27 static const uint64_t InReg = 1ULL<<2; ///< Passed in register
28 static const uint64_t InRegOffs = 2;
29 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
30 static const uint64_t SRetOffs = 3;
31 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
32 static const uint64_t ByValOffs = 4;
33 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
34 static const uint64_t NestOffs = 5;
35 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment
36 static const uint64_t ByValAlignOffs = 6;
37 static const uint64_t Split = 1ULL << 10;
38 static const uint64_t SplitOffs = 10;
39 static const uint64_t OrigAlign = 0x1FULL<<27;
40 static const uint64_t OrigAlignOffs = 27;
41 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size
42 static const uint64_t ByValSizeOffs = 32;
44 static const uint64_t One = 1ULL; //< 1 of this type, for shifts
48 ArgFlagsTy() : Flags(0) { }
50 bool isZExt() const { return Flags & ZExt; }
51 void setZExt() { Flags |= One << ZExtOffs; }
53 bool isSExt() const { return Flags & SExt; }
54 void setSExt() { Flags |= One << SExtOffs; }
56 bool isInReg() const { return Flags & InReg; }
57 void setInReg() { Flags |= One << InRegOffs; }
59 bool isSRet() const { return Flags & SRet; }
60 void setSRet() { Flags |= One << SRetOffs; }
62 bool isByVal() const { return Flags & ByVal; }
63 void setByVal() { Flags |= One << ByValOffs; }
65 bool isNest() const { return Flags & Nest; }
66 void setNest() { Flags |= One << NestOffs; }
68 unsigned getByValAlign() const {
70 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
72 void setByValAlign(unsigned A) {
73 Flags = (Flags & ~ByValAlign) |
74 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
77 bool isSplit() const { return Flags & Split; }
78 void setSplit() { Flags |= One << SplitOffs; }
80 unsigned getOrigAlign() const {
82 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
84 void setOrigAlign(unsigned A) {
85 Flags = (Flags & ~OrigAlign) |
86 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
89 unsigned getByValSize() const {
90 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
92 void setByValSize(unsigned S) {
93 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
96 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
97 std::string getArgFlagsString();
99 /// getRawBits - Represent the flags as a bunch of bits.
100 uint64_t getRawBits() const { return Flags; }
103 /// InputArg - This struct carries flags and type information about a
104 /// single incoming (formal) argument or incoming (from the perspective
105 /// of the caller) return value virtual register.
112 InputArg() : VT(MVT::Other), Used(false) {}
113 InputArg(ArgFlagsTy flags, EVT vt, bool used)
114 : Flags(flags), VT(vt), Used(used) {
115 assert(VT.isSimple() &&
116 "InputArg value type must be Simple!");
120 /// OutputArg - This struct carries flags and a value for a
121 /// single outgoing (actual) argument or outgoing (from the perspective
122 /// of the caller) return value virtual register.
128 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
131 OutputArg() : IsFixed(false) {}
132 OutputArg(ArgFlagsTy flags, EVT vt, bool isfixed)
133 : Flags(flags), VT(vt), IsFixed(isfixed) {
134 assert(VT.isSimple() &&
135 "OutputArg value type must be Simple!");
140 } // end llvm namespace