blob: 27901699480bfe194b930b03f4b9978f2b09354c [file] [log] [blame]
Daniel Sanders0456c152014-11-07 14:24:31 +00001//===---- MipsCCState.h - CCState with Mips specific extensions -----------===//
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
10#ifndef MIPSCCSTATE_H
11#define MIPSCCSTATE_H
12
Chandler Carruthd9903882015-01-14 11:23:27 +000013#include "MipsISelLowering.h"
Daniel Sanders0456c152014-11-07 14:24:31 +000014#include "llvm/ADT/SmallVector.h"
15#include "llvm/CodeGen/CallingConvLower.h"
Daniel Sanders0456c152014-11-07 14:24:31 +000016
17namespace llvm {
18class SDNode;
19class MipsSubtarget;
20
21class MipsCCState : public CCState {
22public:
23 enum SpecialCallingConvType { Mips16RetHelperConv, NoSpecialCallingConv };
24
25 /// Determine the SpecialCallingConvType for the given callee
26 static SpecialCallingConvType
27 getSpecialCallingConvForCallee(const SDNode *Callee,
28 const MipsSubtarget &Subtarget);
29
30private:
31 /// Identify lowered values that originated from f128 arguments and record
32 /// this for use by RetCC_MipsN.
33 void PreAnalyzeCallResultForF128(const SmallVectorImpl<ISD::InputArg> &Ins,
Simon Dardis70f79252017-04-26 11:10:38 +000034 const Type *RetTy, const char * Func);
Daniel Sanders0456c152014-11-07 14:24:31 +000035
36 /// Identify lowered values that originated from f128 arguments and record
37 /// this for use by RetCC_MipsN.
38 void PreAnalyzeReturnForF128(const SmallVectorImpl<ISD::OutputArg> &Outs);
39
40 /// Identify lowered values that originated from f128 arguments and record
41 /// this.
42 void
43 PreAnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
44 std::vector<TargetLowering::ArgListEntry> &FuncArgs,
Simon Dardis70f79252017-04-26 11:10:38 +000045 const char *Func);
Daniel Sanders0456c152014-11-07 14:24:31 +000046
47 /// Identify lowered values that originated from f128 arguments and record
Simon Dardis212cccb2017-06-09 14:37:08 +000048 /// this for use by RetCC_MipsN.
Daniel Sanders0456c152014-11-07 14:24:31 +000049 void
50 PreAnalyzeFormalArgumentsForF128(const SmallVectorImpl<ISD::InputArg> &Ins);
51
Simon Dardis212cccb2017-06-09 14:37:08 +000052 void
53 PreAnalyzeCallResultForVectorFloat(const SmallVectorImpl<ISD::InputArg> &Ins,
54 const Type *RetTy);
55
56 void PreAnalyzeFormalArgumentsForVectorFloat(
57 const SmallVectorImpl<ISD::InputArg> &Ins);
58
59 void
60 PreAnalyzeReturnForVectorFloat(const SmallVectorImpl<ISD::OutputArg> &Outs);
61
Daniel Sanders0456c152014-11-07 14:24:31 +000062 /// Records whether the value has been lowered from an f128.
63 SmallVector<bool, 4> OriginalArgWasF128;
64
Daniel Sandersc43cda82014-11-07 16:54:21 +000065 /// Records whether the value has been lowered from float.
66 SmallVector<bool, 4> OriginalArgWasFloat;
67
Simon Dardis212cccb2017-06-09 14:37:08 +000068 /// Records whether the value has been lowered from a floating point vector.
69 SmallVector<bool, 4> OriginalArgWasFloatVector;
70
71 /// Records whether the return value has been lowered from a floating point
72 /// vector.
73 SmallVector<bool, 4> OriginalRetWasFloatVector;
74
Daniel Sanders0456c152014-11-07 14:24:31 +000075 /// Records whether the value was a fixed argument.
76 /// See ISD::OutputArg::IsFixed,
77 SmallVector<bool, 4> CallOperandIsFixed;
78
79 // Used to handle MIPS16-specific calling convention tweaks.
80 // FIXME: This should probably be a fully fledged calling convention.
81 SpecialCallingConvType SpecialCallingConv;
82
83public:
84 MipsCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
85 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C,
86 SpecialCallingConvType SpecialCC = NoSpecialCallingConv)
87 : CCState(CC, isVarArg, MF, locs, C), SpecialCallingConv(SpecialCC) {}
88
89 void
90 AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
91 CCAssignFn Fn,
92 std::vector<TargetLowering::ArgListEntry> &FuncArgs,
Simon Dardis70f79252017-04-26 11:10:38 +000093 const char *Func) {
94 PreAnalyzeCallOperands(Outs, FuncArgs, Func);
Daniel Sanders0456c152014-11-07 14:24:31 +000095 CCState::AnalyzeCallOperands(Outs, Fn);
96 OriginalArgWasF128.clear();
Daniel Sandersc43cda82014-11-07 16:54:21 +000097 OriginalArgWasFloat.clear();
Simon Dardis212cccb2017-06-09 14:37:08 +000098 OriginalArgWasFloatVector.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +000099 CallOperandIsFixed.clear();
100 }
101
102 // The AnalyzeCallOperands in the base class is not usable since we must
103 // provide a means of accessing ArgListEntry::IsFixed. Delete them from this
104 // class. This doesn't stop them being used via the base class though.
105 void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
Aaron Ballmanf9a18972015-02-15 22:54:22 +0000106 CCAssignFn Fn) = delete;
Daniel Sanders0456c152014-11-07 14:24:31 +0000107 void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
108 SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
Aaron Ballmanf9a18972015-02-15 22:54:22 +0000109 CCAssignFn Fn) = delete;
Daniel Sanders0456c152014-11-07 14:24:31 +0000110
111 void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
112 CCAssignFn Fn) {
113 PreAnalyzeFormalArgumentsForF128(Ins);
114 CCState::AnalyzeFormalArguments(Ins, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000115 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000116 OriginalArgWasF128.clear();
Simon Dardis212cccb2017-06-09 14:37:08 +0000117 OriginalArgWasFloatVector.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000118 }
119
120 void AnalyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins,
Simon Dardis70f79252017-04-26 11:10:38 +0000121 CCAssignFn Fn, const Type *RetTy,
122 const char *Func) {
123 PreAnalyzeCallResultForF128(Ins, RetTy, Func);
Simon Dardis212cccb2017-06-09 14:37:08 +0000124 PreAnalyzeCallResultForVectorFloat(Ins, RetTy);
Daniel Sanders0456c152014-11-07 14:24:31 +0000125 CCState::AnalyzeCallResult(Ins, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000126 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000127 OriginalArgWasF128.clear();
Simon Dardis212cccb2017-06-09 14:37:08 +0000128 OriginalArgWasFloatVector.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000129 }
130
131 void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
132 CCAssignFn Fn) {
133 PreAnalyzeReturnForF128(Outs);
Simon Dardis212cccb2017-06-09 14:37:08 +0000134 PreAnalyzeReturnForVectorFloat(Outs);
Daniel Sanders0456c152014-11-07 14:24:31 +0000135 CCState::AnalyzeReturn(Outs, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000136 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000137 OriginalArgWasF128.clear();
Simon Dardis212cccb2017-06-09 14:37:08 +0000138 OriginalArgWasFloatVector.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000139 }
140
141 bool CheckReturn(const SmallVectorImpl<ISD::OutputArg> &ArgsFlags,
142 CCAssignFn Fn) {
143 PreAnalyzeReturnForF128(ArgsFlags);
Simon Dardis212cccb2017-06-09 14:37:08 +0000144 PreAnalyzeReturnForVectorFloat(ArgsFlags);
Daniel Sanders0456c152014-11-07 14:24:31 +0000145 bool Return = CCState::CheckReturn(ArgsFlags, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000146 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000147 OriginalArgWasF128.clear();
Simon Dardis212cccb2017-06-09 14:37:08 +0000148 OriginalArgWasFloatVector.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000149 return Return;
150 }
151
152 bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; }
Daniel Sandersc43cda82014-11-07 16:54:21 +0000153 bool WasOriginalArgFloat(unsigned ValNo) {
154 return OriginalArgWasFloat[ValNo];
155 }
Simon Dardis212cccb2017-06-09 14:37:08 +0000156 bool WasOriginalArgVectorFloat(unsigned ValNo) const {
157 return OriginalArgWasFloatVector[ValNo];
158 }
159 bool WasOriginalRetVectorFloat(unsigned ValNo) const {
160 return OriginalRetWasFloatVector[ValNo];
161 }
Daniel Sanders0456c152014-11-07 14:24:31 +0000162 bool IsCallOperandFixed(unsigned ValNo) { return CallOperandIsFixed[ValNo]; }
163 SpecialCallingConvType getSpecialCallingConv() { return SpecialCallingConv; }
164};
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000165}
Daniel Sanders0456c152014-11-07 14:24:31 +0000166
167#endif