1 //===---- MipsCCState.h - CCState with Mips specific extensions -----------===//
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 //===----------------------------------------------------------------------===//
13 #include "MipsISelLowering.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/CodeGen/CallingConvLower.h"
21 class MipsCCState
: public CCState
{
23 enum SpecialCallingConvType
{ Mips16RetHelperConv
, NoSpecialCallingConv
};
25 /// Determine the SpecialCallingConvType for the given callee
26 static SpecialCallingConvType
27 getSpecialCallingConvForCallee(const SDNode
*Callee
,
28 const MipsSubtarget
&Subtarget
);
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
,
34 const Type
*RetTy
, const char * Func
);
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
);
40 /// Identify lowered values that originated from f128 arguments and record
43 PreAnalyzeCallOperands(const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
44 std::vector
<TargetLowering::ArgListEntry
> &FuncArgs
,
47 /// Identify lowered values that originated from f128 arguments and record
48 /// this for use by RetCC_MipsN.
50 PreAnalyzeFormalArgumentsForF128(const SmallVectorImpl
<ISD::InputArg
> &Ins
);
53 PreAnalyzeCallResultForVectorFloat(const SmallVectorImpl
<ISD::InputArg
> &Ins
,
56 void PreAnalyzeFormalArgumentsForVectorFloat(
57 const SmallVectorImpl
<ISD::InputArg
> &Ins
);
60 PreAnalyzeReturnForVectorFloat(const SmallVectorImpl
<ISD::OutputArg
> &Outs
);
62 /// Records whether the value has been lowered from an f128.
63 SmallVector
<bool, 4> OriginalArgWasF128
;
65 /// Records whether the value has been lowered from float.
66 SmallVector
<bool, 4> OriginalArgWasFloat
;
68 /// Records whether the value has been lowered from a floating point vector.
69 SmallVector
<bool, 4> OriginalArgWasFloatVector
;
71 /// Records whether the return value has been lowered from a floating point
73 SmallVector
<bool, 4> OriginalRetWasFloatVector
;
75 /// Records whether the value was a fixed argument.
76 /// See ISD::OutputArg::IsFixed,
77 SmallVector
<bool, 4> CallOperandIsFixed
;
79 // Used to handle MIPS16-specific calling convention tweaks.
80 // FIXME: This should probably be a fully fledged calling convention.
81 SpecialCallingConvType SpecialCallingConv
;
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
) {}
90 AnalyzeCallOperands(const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
92 std::vector
<TargetLowering::ArgListEntry
> &FuncArgs
,
94 PreAnalyzeCallOperands(Outs
, FuncArgs
, Func
);
95 CCState::AnalyzeCallOperands(Outs
, Fn
);
96 OriginalArgWasF128
.clear();
97 OriginalArgWasFloat
.clear();
98 OriginalArgWasFloatVector
.clear();
99 CallOperandIsFixed
.clear();
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
,
106 CCAssignFn Fn
) = delete;
107 void AnalyzeCallOperands(const SmallVectorImpl
<MVT
> &Outs
,
108 SmallVectorImpl
<ISD::ArgFlagsTy
> &Flags
,
109 CCAssignFn Fn
) = delete;
111 void AnalyzeFormalArguments(const SmallVectorImpl
<ISD::InputArg
> &Ins
,
113 PreAnalyzeFormalArgumentsForF128(Ins
);
114 CCState::AnalyzeFormalArguments(Ins
, Fn
);
115 OriginalArgWasFloat
.clear();
116 OriginalArgWasF128
.clear();
117 OriginalArgWasFloatVector
.clear();
120 void AnalyzeCallResult(const SmallVectorImpl
<ISD::InputArg
> &Ins
,
121 CCAssignFn Fn
, const Type
*RetTy
,
123 PreAnalyzeCallResultForF128(Ins
, RetTy
, Func
);
124 PreAnalyzeCallResultForVectorFloat(Ins
, RetTy
);
125 CCState::AnalyzeCallResult(Ins
, Fn
);
126 OriginalArgWasFloat
.clear();
127 OriginalArgWasF128
.clear();
128 OriginalArgWasFloatVector
.clear();
131 void AnalyzeReturn(const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
133 PreAnalyzeReturnForF128(Outs
);
134 PreAnalyzeReturnForVectorFloat(Outs
);
135 CCState::AnalyzeReturn(Outs
, Fn
);
136 OriginalArgWasFloat
.clear();
137 OriginalArgWasF128
.clear();
138 OriginalArgWasFloatVector
.clear();
141 bool CheckReturn(const SmallVectorImpl
<ISD::OutputArg
> &ArgsFlags
,
143 PreAnalyzeReturnForF128(ArgsFlags
);
144 PreAnalyzeReturnForVectorFloat(ArgsFlags
);
145 bool Return
= CCState::CheckReturn(ArgsFlags
, Fn
);
146 OriginalArgWasFloat
.clear();
147 OriginalArgWasF128
.clear();
148 OriginalArgWasFloatVector
.clear();
152 bool WasOriginalArgF128(unsigned ValNo
) { return OriginalArgWasF128
[ValNo
]; }
153 bool WasOriginalArgFloat(unsigned ValNo
) {
154 return OriginalArgWasFloat
[ValNo
];
156 bool WasOriginalArgVectorFloat(unsigned ValNo
) const {
157 return OriginalArgWasFloatVector
[ValNo
];
159 bool WasOriginalRetVectorFloat(unsigned ValNo
) const {
160 return OriginalRetWasFloatVector
[ValNo
];
162 bool IsCallOperandFixed(unsigned ValNo
) { return CallOperandIsFixed
[ValNo
]; }
163 SpecialCallingConvType
getSpecialCallingConv() { return SpecialCallingConv
; }