Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/SystemZ/SystemZCallingConv.h
Line
Count
Source
1
//===-- SystemZCallingConv.h - Calling conventions for SystemZ --*- 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
#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
10
#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
11
12
#include "llvm/ADT/SmallVector.h"
13
#include "llvm/CodeGen/CallingConvLower.h"
14
#include "llvm/MC/MCRegisterInfo.h"
15
16
namespace llvm {
17
namespace SystemZ {
18
  const unsigned NumArgGPRs = 5;
19
  extern const MCPhysReg ArgGPRs[NumArgGPRs];
20
21
  const unsigned NumArgFPRs = 4;
22
  extern const MCPhysReg ArgFPRs[NumArgFPRs];
23
} // end namespace SystemZ
24
25
class SystemZCCState : public CCState {
26
private:
27
  /// Records whether the value was a fixed argument.
28
  /// See ISD::OutputArg::IsFixed.
29
  SmallVector<bool, 4> ArgIsFixed;
30
31
  /// Records whether the value was widened from a short vector type.
32
  SmallVector<bool, 4> ArgIsShortVector;
33
34
  // Check whether ArgVT is a short vector type.
35
17.0k
  bool IsShortVectorType(EVT ArgVT) {
36
17.0k
    return ArgVT.isVector() && 
ArgVT.getStoreSize() <= 83.58k
;
37
17.0k
  }
38
39
public:
40
  SystemZCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
41
                 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
42
9.15k
      : CCState(CC, isVarArg, MF, locs, C) {}
43
44
  void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
45
8.11k
                              CCAssignFn Fn) {
46
8.11k
    // Formal arguments are always fixed.
47
8.11k
    ArgIsFixed.clear();
48
23.6k
    for (unsigned i = 0; i < Ins.size(); 
++i15.5k
)
49
15.5k
      ArgIsFixed.push_back(true);
50
8.11k
    // Record whether the call operand was a short vector.
51
8.11k
    ArgIsShortVector.clear();
52
23.6k
    for (unsigned i = 0; i < Ins.size(); 
++i15.5k
)
53
15.5k
      ArgIsShortVector.push_back(IsShortVectorType(Ins[i].ArgVT));
54
8.11k
55
8.11k
    CCState::AnalyzeFormalArguments(Ins, Fn);
56
8.11k
  }
57
58
  void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
59
1.03k
                           CCAssignFn Fn) {
60
1.03k
    // Record whether the call operand was a fixed argument.
61
1.03k
    ArgIsFixed.clear();
62
2.51k
    for (unsigned i = 0; i < Outs.size(); 
++i1.47k
)
63
1.47k
      ArgIsFixed.push_back(Outs[i].IsFixed);
64
1.03k
    // Record whether the call operand was a short vector.
65
1.03k
    ArgIsShortVector.clear();
66
2.51k
    for (unsigned i = 0; i < Outs.size(); 
++i1.47k
)
67
1.47k
      ArgIsShortVector.push_back(IsShortVectorType(Outs[i].ArgVT));
68
1.03k
69
1.03k
    CCState::AnalyzeCallOperands(Outs, Fn);
70
1.03k
  }
71
72
  // This version of AnalyzeCallOperands in the base class is not usable
73
  // since we must provide a means of accessing ISD::OutputArg::IsFixed.
74
  void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
75
                           SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
76
                           CCAssignFn Fn) = delete;
77
78
3.58k
  bool IsFixed(unsigned ValNo) { return ArgIsFixed[ValNo]; }
79
100
  bool IsShortVector(unsigned ValNo) { return ArgIsShortVector[ValNo]; }
80
};
81
82
// Handle i128 argument types.  These need to be passed by implicit
83
// reference.  This could be as simple as the following .td line:
84
//    CCIfType<[i128], CCPassIndirect<i64>>,
85
// except that i128 is not a legal type, and therefore gets split by
86
// common code into a pair of i64 arguments.
87
inline bool CC_SystemZ_I128Indirect(unsigned &ValNo, MVT &ValVT,
88
                                    MVT &LocVT,
89
                                    CCValAssign::LocInfo &LocInfo,
90
                                    ISD::ArgFlagsTy &ArgFlags,
91
8.12k
                                    CCState &State) {
92
8.12k
  SmallVectorImpl<CCValAssign> &PendingMembers = State.getPendingLocs();
93
8.12k
94
8.12k
  // ArgFlags.isSplit() is true on the first part of a i128 argument;
95
8.12k
  // PendingMembers.empty() is false on all subsequent parts.
96
8.12k
  if (!ArgFlags.isSplit() && 
PendingMembers.empty()8.08k
)
97
8.04k
    return false;
98
76
99
76
  // Push a pending Indirect value location for each part.
100
76
  LocVT = MVT::i64;
101
76
  LocInfo = CCValAssign::Indirect;
102
76
  PendingMembers.push_back(CCValAssign::getPending(ValNo, ValVT,
103
76
                                                   LocVT, LocInfo));
104
76
  if (!ArgFlags.isSplitEnd())
105
38
    return true;
106
38
107
38
  // OK, we've collected all parts in the pending list.  Allocate
108
38
  // the location (register or stack slot) for the indirect pointer.
109
38
  // (This duplicates the usual i64 calling convention rules.)
110
38
  unsigned Reg = State.AllocateReg(SystemZ::ArgGPRs);
111
38
  unsigned Offset = Reg ? 
033
:
State.AllocateStack(8, 8)5
;
112
38
113
38
  // Use that same location for all the pending parts.
114
76
  for (auto &It : PendingMembers) {
115
76
    if (Reg)
116
66
      It.convertToReg(Reg);
117
10
    else
118
10
      It.convertToMem(Offset);
119
76
    State.addLoc(It);
120
76
  }
121
38
122
38
  PendingMembers.clear();
123
38
124
38
  return true;
125
38
}
126
127
} // end namespace llvm
128
129
#endif