Coverage Report

Created: 2019-02-20 00:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/TargetCallingConv.h
Line
Count
Source
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
49
    unsigned ByValSize; ///< Byval struct size
50
51
  public:
52
    ArgFlagsTy()
53
        : IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsNest(0),
54
          IsReturned(0), IsSplit(0), IsInAlloca(0), IsSplitEnd(0),
55
          IsSwiftSelf(0), IsSwiftError(0), IsHva(0), IsHvaStart(0),
56
          IsSecArgPass(0), ByValAlign(0), OrigAlign(0),
57
          IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
58
7.71M
          IsCopyElisionCandidate(0), ByValSize(0) {
59
7.71M
      static_assert(sizeof(*this) == 2 * sizeof(unsigned), "flags are too big");
60
7.71M
    }
61
62
187k
    bool isZExt() const { return IsZExt; }
63
160k
    void setZExt() { IsZExt = 1; }
64
65
244k
    bool isSExt() const { return IsSExt; }
66
29.2k
    void setSExt() { IsSExt = 1; }
67
68
363k
    bool isInReg() const { return IsInReg; }
69
4.86k
    void setInReg() { IsInReg = 1; }
70
71
4.93M
    bool isSRet() const { return IsSRet; }
72
9.55k
    void setSRet() { IsSRet = 1; }
73
74
11.2M
    bool isByVal() const { return IsByVal; }
75
1.94k
    void setByVal() { IsByVal = 1; }
76
77
5.39M
    bool isInAlloca() const { return IsInAlloca; }
78
46
    void setInAlloca() { IsInAlloca = 1; }
79
80
8.03M
    bool isSwiftSelf() const { return IsSwiftSelf; }
81
195
    void setSwiftSelf() { IsSwiftSelf = 1; }
82
83
9.85M
    bool isSwiftError() const { return IsSwiftError; }
84
483
    void setSwiftError() { IsSwiftError = 1; }
85
86
395
    bool isHva() const { return IsHva; }
87
58
    void setHva() { IsHva = 1; }
88
89
29
    bool isHvaStart() const { return IsHvaStart; }
90
16
    void setHvaStart() { IsHvaStart = 1; }
91
92
396
    bool isSecArgPass() const { return IsSecArgPass; }
93
183
    void setSecArgPass() { IsSecArgPass = 1; }
94
95
1.21M
    bool isNest() const { return IsNest; }
96
54
    void setNest() { IsNest = 1; }
97
98
327k
    bool isReturned() const { return IsReturned; }
99
7.46k
    void setReturned() { IsReturned = 1; }
100
101
4.64M
    bool isInConsecutiveRegs()  const { return IsInConsecutiveRegs; }
102
9.81k
    void setInConsecutiveRegs() { IsInConsecutiveRegs = 1; }
103
104
47.3k
    bool isInConsecutiveRegsLast() const { return IsInConsecutiveRegsLast; }
105
6.02k
    void setInConsecutiveRegsLast() { IsInConsecutiveRegsLast = 1; }
106
107
7.55M
    bool isSplit()   const { return IsSplit; }
108
42.0k
    void setSplit()  { IsSplit = 1; }
109
110
2.87k
    bool isSplitEnd()   const { return IsSplitEnd; }
111
42.0k
    void setSplitEnd()  { IsSplitEnd = 1; }
112
113
529k
    bool isCopyElisionCandidate()  const { return IsCopyElisionCandidate; }
114
1.97k
    void setCopyElisionCandidate() { IsCopyElisionCandidate = 1; }
115
116
2.94k
    unsigned getByValAlign() const { return (1U << ByValAlign) / 2; }
117
1.94k
    void setByValAlign(unsigned A) {
118
1.94k
      ByValAlign = Log2_32(A) + 1;
119
1.94k
      assert(getByValAlign() == A && "bitfield overflow");
120
1.94k
    }
121
122
218k
    unsigned getOrigAlign() const { return (1U << OrigAlign) / 2; }
123
6.24M
    void setOrigAlign(unsigned A) {
124
6.24M
      OrigAlign = Log2_32(A) + 1;
125
6.24M
      assert(getOrigAlign() == A && "bitfield overflow");
126
6.24M
    }
127
128
3.88k
    unsigned getByValSize() const { return ByValSize; }
129
1.94k
    void setByValSize(unsigned S) { ByValSize = S; }
130
  };
131
132
  /// InputArg - This struct carries flags and type information about a
133
  /// single incoming (formal) argument or incoming (from the perspective
134
  /// of the caller) return value virtual register.
135
  ///
136
  struct InputArg {
137
    ArgFlagsTy Flags;
138
    MVT VT = MVT::Other;
139
    EVT ArgVT;
140
    bool Used = false;
141
142
    /// Index original Function's argument.
143
    unsigned OrigArgIndex;
144
    /// Sentinel value for implicit machine-level input arguments.
145
    static const unsigned NoArgIndex = UINT_MAX;
146
147
    /// Offset in bytes of current input value relative to the beginning of
148
    /// original argument. E.g. if argument was splitted into four 32 bit
149
    /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
150
    unsigned PartOffset;
151
152
335k
    InputArg() = default;
153
    InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
154
             unsigned origIdx, unsigned partOffs)
155
555k
      : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
156
555k
      VT = vt.getSimpleVT();
157
555k
      ArgVT = argvt;
158
555k
    }
159
160
257k
    bool isOrigArg() const {
161
257k
      return OrigArgIndex != NoArgIndex;
162
257k
    }
163
164
515k
    unsigned getOrigArgIndex() const {
165
515k
      assert(OrigArgIndex != NoArgIndex && "Implicit machine-level argument");
166
515k
      return OrigArgIndex;
167
515k
    }
168
  };
169
170
  /// OutputArg - This struct carries flags and a value for a
171
  /// single outgoing (actual) argument or outgoing (from the perspective
172
  /// of the caller) return value virtual register.
173
  ///
174
  struct OutputArg {
175
    ArgFlagsTy Flags;
176
    MVT VT;
177
    EVT ArgVT;
178
179
    /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
180
    bool IsFixed = false;
181
182
    /// Index original Function's argument.
183
    unsigned OrigArgIndex;
184
185
    /// Offset in bytes of current output value relative to the beginning of
186
    /// original argument. E.g. if argument was splitted into four 32 bit
187
    /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
188
    unsigned PartOffset;
189
190
    OutputArg() = default;
191
    OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
192
              unsigned origIdx, unsigned partOffs)
193
      : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
194
1.99M
        PartOffset(partOffs) {
195
1.99M
      VT = vt.getSimpleVT();
196
1.99M
      ArgVT = argvt;
197
1.99M
    }
198
  };
199
200
} // end namespace ISD
201
} // end namespace llvm
202
203
#endif // LLVM_CODEGEN_TARGETCALLINGCONV_H