LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetCallingConv.h
Go to the documentation of this file.
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/Support/DataTypes.h"
19 #include <string>
20 
21 namespace llvm {
22 
23 namespace ISD {
24  struct ArgFlagsTy {
25  private:
26  static const uint64_t NoFlagSet = 0ULL;
27  static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
28  static const uint64_t ZExtOffs = 0;
29  static const uint64_t SExt = 1ULL<<1; ///< Sign extended
30  static const uint64_t SExtOffs = 1;
31  static const uint64_t InReg = 1ULL<<2; ///< Passed in register
32  static const uint64_t InRegOffs = 2;
33  static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
34  static const uint64_t SRetOffs = 3;
35  static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
36  static const uint64_t ByValOffs = 4;
37  static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
38  static const uint64_t NestOffs = 5;
39  static const uint64_t Returned = 1ULL<<6; ///< Always returned
40  static const uint64_t ReturnedOffs = 6;
41  static const uint64_t ByValAlign = 0xFULL<<7; ///< Struct alignment
42  static const uint64_t ByValAlignOffs = 7;
43  static const uint64_t Split = 1ULL<<11;
44  static const uint64_t SplitOffs = 11;
45  static const uint64_t OrigAlign = 0x1FULL<<27;
46  static const uint64_t OrigAlignOffs = 27;
47  static const uint64_t ByValSize = 0xffffffffULL<<32; ///< Struct size
48  static const uint64_t ByValSizeOffs = 32;
49 
50  static const uint64_t One = 1ULL; ///< 1 of this type, for shifts
51 
52  uint64_t Flags;
53  public:
54  ArgFlagsTy() : Flags(0) { }
55 
56  bool isZExt() const { return Flags & ZExt; }
57  void setZExt() { Flags |= One << ZExtOffs; }
58 
59  bool isSExt() const { return Flags & SExt; }
60  void setSExt() { Flags |= One << SExtOffs; }
61 
62  bool isInReg() const { return Flags & InReg; }
63  void setInReg() { Flags |= One << InRegOffs; }
64 
65  bool isSRet() const { return Flags & SRet; }
66  void setSRet() { Flags |= One << SRetOffs; }
67 
68  bool isByVal() const { return Flags & ByVal; }
69  void setByVal() { Flags |= One << ByValOffs; }
70 
71  bool isNest() const { return Flags & Nest; }
72  void setNest() { Flags |= One << NestOffs; }
73 
74  bool isReturned() const { return Flags & Returned; }
75  void setReturned() { Flags |= One << ReturnedOffs; }
76 
77  unsigned getByValAlign() const {
78  return (unsigned)
79  ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
80  }
81  void setByValAlign(unsigned A) {
82  Flags = (Flags & ~ByValAlign) |
83  (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
84  }
85 
86  bool isSplit() const { return Flags & Split; }
87  void setSplit() { Flags |= One << SplitOffs; }
88 
89  unsigned getOrigAlign() const {
90  return (unsigned)
91  ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
92  }
93  void setOrigAlign(unsigned A) {
94  Flags = (Flags & ~OrigAlign) |
95  (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
96  }
97 
98  unsigned getByValSize() const {
99  return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
100  }
101  void setByValSize(unsigned S) {
102  Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
103  }
104 
105  /// getRawBits - Represent the flags as a bunch of bits.
106  uint64_t getRawBits() const { return Flags; }
107  };
108 
109  /// InputArg - This struct carries flags and type information about a
110  /// single incoming (formal) argument or incoming (from the perspective
111  /// of the caller) return value virtual register.
112  ///
113  struct InputArg {
117  bool Used;
118 
119  /// Index original Function's argument.
120  unsigned OrigArgIndex;
121 
122  /// Offset in bytes of current input value relative to the beginning of
123  /// original argument. E.g. if argument was splitted into four 32 bit
124  /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
125  unsigned PartOffset;
126 
127  InputArg() : VT(MVT::Other), Used(false) {}
128  InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
129  unsigned origIdx, unsigned partOffs)
130  : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
131  VT = vt.getSimpleVT();
132  ArgVT = argvt;
133  }
134  };
135 
136  /// OutputArg - This struct carries flags and a value for a
137  /// single outgoing (actual) argument or outgoing (from the perspective
138  /// of the caller) return value virtual register.
139  ///
140  struct OutputArg {
144 
145  /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
146  bool IsFixed;
147 
148  /// Index original Function's argument.
149  unsigned OrigArgIndex;
150 
151  /// Offset in bytes of current output value relative to the beginning of
152  /// original argument. E.g. if argument was splitted into four 32 bit
153  /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
154  unsigned PartOffset;
155 
157  OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
158  unsigned origIdx, unsigned partOffs)
159  : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
160  PartOffset(partOffs) {
161  VT = vt.getSimpleVT();
162  ArgVT = argvt;
163  }
164  };
165 }
166 
167 } // end llvm namespace
168 
169 #endif
void setByValAlign(unsigned A)
unsigned getByValSize() const
void setByValSize(unsigned S)
#define false
Definition: ConvertUTF.c:64
void setOrigAlign(unsigned A)
bool IsFixed
IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed, unsigned origIdx, unsigned partOffs)
unsigned getByValAlign() const
unsigned Log2_32(uint32_t Value)
Definition: MathExtras.h:443
unsigned OrigArgIndex
Index original Function's argument.
uint64_t getRawBits() const
getRawBits - Represent the flags as a bunch of bits.
InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used, unsigned origIdx, unsigned partOffs)
unsigned OrigArgIndex
Index original Function's argument.
unsigned getOrigAlign() const
MVT getSimpleVT() const
Definition: ValueTypes.h:749