Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/TargetCallingConv.h
Line
Count
Source (jump to first uncovered line)
1
//===-- llvm/CodeGen/TargetCallingConv.h - Calling Convention ---*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines types for working with calling-convention information.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CODEGEN_TARGETCALLINGCONV_H
14
#define LLVM_CODEGEN_TARGETCALLINGCONV_H
15
16
#include "llvm/CodeGen/ValueTypes.h"
17
#include "llvm/Support/MachineValueType.h"
18
#include "llvm/Support/MathExtras.h"
19
#include <cassert>
20
#include <climits>
21
#include <cstdint>
22
23
namespace llvm {
24
namespace ISD {
25
26
  struct ArgFlagsTy {
27
  private:
28
    unsigned IsZExt : 1;     ///< Zero extended
29
    unsigned IsSExt : 1;     ///< Sign extended
30
    unsigned IsInReg : 1;    ///< Passed in register
31
    unsigned IsSRet : 1;     ///< Hidden struct-ret ptr
32
    unsigned IsByVal : 1;    ///< Struct passed by value
33
    unsigned IsNest : 1;     ///< Nested fn static chain
34
    unsigned IsReturned : 1; ///< Always returned
35
    unsigned IsSplit : 1;
36
    unsigned IsInAlloca : 1;   ///< Passed with inalloca
37
    unsigned IsSplitEnd : 1;   ///< Last part of a split
38
    unsigned IsSwiftSelf : 1;  ///< Swift self parameter
39
    unsigned IsSwiftError : 1; ///< Swift error parameter
40
    unsigned IsHva : 1;        ///< HVA field for
41
    unsigned IsHvaStart : 1;   ///< HVA structure start
42
    unsigned IsSecArgPass : 1; ///< Second argument
43
    unsigned ByValAlign : 4;   ///< Log 2 of byval alignment
44
    unsigned OrigAlign : 5;    ///< Log 2 of original alignment
45
    unsigned IsInConsecutiveRegsLast : 1;
46
    unsigned IsInConsecutiveRegs : 1;
47
    unsigned IsCopyElisionCandidate : 1; ///< Argument copy elision candidate
48
    unsigned IsPointer : 1;
49
50
    unsigned ByValSize; ///< Byval struct size
51
52
    unsigned PointerAddrSpace; ///< Address space of pointer argument
53
54
  public:
55
    ArgFlagsTy()
56
        : IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsNest(0),
57
          IsReturned(0), IsSplit(0), IsInAlloca(0), IsSplitEnd(0),
58
          IsSwiftSelf(0), IsSwiftError(0), IsHva(0), IsHvaStart(0),
59
          IsSecArgPass(0), ByValAlign(0), OrigAlign(0),
60
          IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
61
          IsCopyElisionCandidate(0), IsPointer(0), ByValSize(0),
62
7.66M
          PointerAddrSpace(0) {
63
7.66M
      static_assert(sizeof(*this) == 3 * sizeof(unsigned), "flags are too big");
64
7.66M
    }
65
66
189k
    bool isZExt() const { return IsZExt; }
67
166k
    void setZExt() { IsZExt = 1; }
68
69
251k
    bool isSExt() const { return IsSExt; }
70
30.2k
    void setSExt() { IsSExt = 1; }
71
72
390k
    bool isInReg() const { return IsInReg; }
73
6.37k
    void setInReg() { IsInReg = 1; }
74
75
4.71M
    bool isSRet() const { return IsSRet; }
76
9.81k
    void setSRet() { IsSRet = 1; }
77
78
10.8M
    bool isByVal() const { return IsByVal; }
79
1.88k
    void setByVal() { IsByVal = 1; }
80
81
5.35M
    bool isInAlloca() const { return IsInAlloca; }
82
46
    void setInAlloca() { IsInAlloca = 1; }
83
84
7.73M
    bool isSwiftSelf() const { return IsSwiftSelf; }
85
197
    void setSwiftSelf() { IsSwiftSelf = 1; }
86
87
6.73M
    bool isSwiftError() const { return IsSwiftError; }
88
497
    void setSwiftError() { IsSwiftError = 1; }
89
90
437
    bool isHva() const { return IsHva; }
91
58
    void setHva() { IsHva = 1; }
92
93
29
    bool isHvaStart() const { return IsHvaStart; }
94
16
    void setHvaStart() { IsHvaStart = 1; }
95
96
424
    bool isSecArgPass() const { return IsSecArgPass; }
97
197
    void setSecArgPass() { IsSecArgPass = 1; }
98
99
1.20M
    bool isNest() const { return IsNest; }
100
77
    void setNest() { IsNest = 1; }
101
102
280k
    bool isReturned() const { return IsReturned; }
103
5.86k
    void setReturned() { IsReturned = 1; }
104
105
4.39M
    bool isInConsecutiveRegs()  const { return IsInConsecutiveRegs; }
106
13.7k
    void setInConsecutiveRegs() { IsInConsecutiveRegs = 1; }
107
108
53.2k
    bool isInConsecutiveRegsLast() const { return IsInConsecutiveRegsLast; }
109
9.72k
    void setInConsecutiveRegsLast() { IsInConsecutiveRegsLast = 1; }
110
111
7.18M
    bool isSplit()   const { return IsSplit; }
112
47.4k
    void setSplit()  { IsSplit = 1; }
113
114
22.7k
    bool isSplitEnd()   const { return IsSplitEnd; }
115
47.4k
    void setSplitEnd()  { IsSplitEnd = 1; }
116
117
556k
    bool isCopyElisionCandidate()  const { return IsCopyElisionCandidate; }
118
2.06k
    void setCopyElisionCandidate() { IsCopyElisionCandidate = 1; }
119
120
0
    bool isPointer()  const { return IsPointer; }
121
887k
    void setPointer() { IsPointer = 1; }
122
123
3.01k
    unsigned getByValAlign() const { return (1U << ByValAlign) / 2; }
124
1.88k
    void setByValAlign(unsigned A) {
125
1.88k
      ByValAlign = Log2_32(A) + 1;
126
1.88k
      assert(getByValAlign() == A && "bitfield overflow");
127
1.88k
    }
128
129
206k
    unsigned getOrigAlign() const { return (1U << OrigAlign) / 2; }
130
6.05M
    void setOrigAlign(unsigned A) {
131
6.05M
      OrigAlign = Log2_32(A) + 1;
132
6.05M
      assert(getOrigAlign() == A && "bitfield overflow");
133
6.05M
    }
134
135
4.00k
    unsigned getByValSize() const { return ByValSize; }
136
1.88k
    void setByValSize(unsigned S) { ByValSize = S; }
137
138
0
    unsigned getPointerAddrSpace() const { return PointerAddrSpace; }
139
887k
    void setPointerAddrSpace(unsigned AS) { PointerAddrSpace = AS; }
140
};
141
142
  /// InputArg - This struct carries flags and type information about a
143
  /// single incoming (formal) argument or incoming (from the perspective
144
  /// of the caller) return value virtual register.
145
  ///
146
  struct InputArg {
147
    ArgFlagsTy Flags;
148
    MVT VT = MVT::Other;
149
    EVT ArgVT;
150
    bool Used = false;
151
152
    /// Index original Function's argument.
153
    unsigned OrigArgIndex;
154
    /// Sentinel value for implicit machine-level input arguments.
155
    static const unsigned NoArgIndex = UINT_MAX;
156
157
    /// Offset in bytes of current input value relative to the beginning of
158
    /// original argument. E.g. if argument was splitted into four 32 bit
159
    /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
160
    unsigned PartOffset;
161
162
272k
    InputArg() = default;
163
    InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
164
             unsigned origIdx, unsigned partOffs)
165
589k
      : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
166
589k
      VT = vt.getSimpleVT();
167
589k
      ArgVT = argvt;
168
589k
    }
169
170
268k
    bool isOrigArg() const {
171
268k
      return OrigArgIndex != NoArgIndex;
172
268k
    }
173
174
524k
    unsigned getOrigArgIndex() const {
175
524k
      assert(OrigArgIndex != NoArgIndex && "Implicit machine-level argument");
176
524k
      return OrigArgIndex;
177
524k
    }
178
  };
179
180
  /// OutputArg - This struct carries flags and a value for a
181
  /// single outgoing (actual) argument or outgoing (from the perspective
182
  /// of the caller) return value virtual register.
183
  ///
184
  struct OutputArg {
185
    ArgFlagsTy Flags;
186
    MVT VT;
187
    EVT ArgVT;
188
189
    /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
190
    bool IsFixed = false;
191
192
    /// Index original Function's argument.
193
    unsigned OrigArgIndex;
194
195
    /// Offset in bytes of current output value relative to the beginning of
196
    /// original argument. E.g. if argument was splitted into four 32 bit
197
    /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
198
    unsigned PartOffset;
199
200
    OutputArg() = default;
201
    OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
202
              unsigned origIdx, unsigned partOffs)
203
      : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
204
1.76M
        PartOffset(partOffs) {
205
1.76M
      VT = vt.getSimpleVT();
206
1.76M
      ArgVT = argvt;
207
1.76M
    }
208
  };
209
210
} // end namespace ISD
211
} // end namespace llvm
212
213
#endif // LLVM_CODEGEN_TARGETCALLINGCONV_H