1 //===-- SystemZCallingConv.h - Calling conventions for SystemZ --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
11 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/CodeGen/CallingConvLower.h"
18 const unsigned NumArgGPRs = 5;
19 extern const unsigned ArgGPRs[NumArgGPRs];
21 const unsigned NumArgFPRs = 4;
22 extern const unsigned ArgFPRs[NumArgFPRs];
23 } // end namespace SystemZ
25 class SystemZCCState : public CCState {
27 /// Records whether the value was a fixed argument.
28 /// See ISD::OutputArg::IsFixed.
29 SmallVector<bool, 4> ArgIsFixed;
31 /// Records whether the value was widened from a short vector type.
32 SmallVector<bool, 4> ArgIsShortVector;
34 // Check whether ArgVT is a short vector type.
35 bool IsShortVectorType(EVT ArgVT) {
36 return ArgVT.isVector() && ArgVT.getStoreSize() <= 8;
40 SystemZCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
41 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
42 : CCState(CC, isVarArg, MF, locs, C) {}
44 void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
46 // Formal arguments are always fixed.
48 for (unsigned i = 0; i < Ins.size(); ++i)
49 ArgIsFixed.push_back(true);
50 // 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));
55 CCState::AnalyzeFormalArguments(Ins, Fn);
58 void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
60 // Record whether the call operand was a fixed argument.
62 for (unsigned i = 0; i < Outs.size(); ++i)
63 ArgIsFixed.push_back(Outs[i].IsFixed);
64 // 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));
69 CCState::AnalyzeCallOperands(Outs, Fn);
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;
78 bool IsFixed(unsigned ValNo) { return ArgIsFixed[ValNo]; }
79 bool IsShortVector(unsigned ValNo) { return ArgIsShortVector[ValNo]; }
82 } // end namespace llvm