blob: bff0706618aa8aa4087be36ffeb0ce8e347b3f2a [file] [log] [blame]
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001//===-- SystemZCallingConv.h - Calling conventions for SystemZ --*- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
11#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
Ulrich Weigand5f613df2013-05-06 16:15:19 +000012
Ulrich Weigandce4c1092015-05-05 19:25:42 +000013#include "llvm/ADT/SmallVector.h"
14#include "llvm/CodeGen/CallingConvLower.h"
15
Ulrich Weigand5f613df2013-05-06 16:15:19 +000016namespace llvm {
Richard Sandifordc2312692014-03-06 10:38:30 +000017namespace SystemZ {
18 const unsigned NumArgGPRs = 5;
19 extern const unsigned ArgGPRs[NumArgGPRs];
Ulrich Weigand5f613df2013-05-06 16:15:19 +000020
Richard Sandifordc2312692014-03-06 10:38:30 +000021 const unsigned NumArgFPRs = 4;
22 extern const unsigned ArgFPRs[NumArgFPRs];
23} // end namespace SystemZ
Ulrich Weigandce4c1092015-05-05 19:25:42 +000024
25class SystemZCCState : public CCState {
26private:
27 /// Records whether the value was a fixed argument.
28 /// See ISD::OutputArg::IsFixed.
29 SmallVector<bool, 4> ArgIsFixed;
30
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +000031 /// 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 bool IsShortVectorType(EVT ArgVT) {
36 return ArgVT.isVector() && ArgVT.getStoreSize() <= 8;
37 }
38
Ulrich Weigandce4c1092015-05-05 19:25:42 +000039public:
40 SystemZCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
41 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
42 : CCState(CC, isVarArg, MF, locs, C) {}
43
44 void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
45 CCAssignFn Fn) {
46 // Formal arguments are always fixed.
47 ArgIsFixed.clear();
48 for (unsigned i = 0; i < Ins.size(); ++i)
49 ArgIsFixed.push_back(true);
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +000050 // Record whether the call operand was a short vector.
51 ArgIsShortVector.clear();
52 for (unsigned i = 0; i < Ins.size(); ++i)
53 ArgIsShortVector.push_back(IsShortVectorType(Ins[i].ArgVT));
Ulrich Weigandce4c1092015-05-05 19:25:42 +000054
55 CCState::AnalyzeFormalArguments(Ins, Fn);
56 }
57
58 void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
59 CCAssignFn Fn) {
60 // Record whether the call operand was a fixed argument.
61 ArgIsFixed.clear();
62 for (unsigned i = 0; i < Outs.size(); ++i)
63 ArgIsFixed.push_back(Outs[i].IsFixed);
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +000064 // Record whether the call operand was a short vector.
65 ArgIsShortVector.clear();
66 for (unsigned i = 0; i < Outs.size(); ++i)
67 ArgIsShortVector.push_back(IsShortVectorType(Outs[i].ArgVT));
Ulrich Weigandce4c1092015-05-05 19:25:42 +000068
69 CCState::AnalyzeCallOperands(Outs, Fn);
70 }
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 bool IsFixed(unsigned ValNo) { return ArgIsFixed[ValNo]; }
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +000079 bool IsShortVector(unsigned ValNo) { return ArgIsShortVector[ValNo]; }
Ulrich Weigandce4c1092015-05-05 19:25:42 +000080};
81
Richard Sandifordc2312692014-03-06 10:38:30 +000082} // end namespace llvm
Ulrich Weigand5f613df2013-05-06 16:15:19 +000083
84#endif