blob: cc4531d879719b4dd9dfbc47a632687dbbfc6046 [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
13#include "llvm/ADT/SmallVector.h"
14#include "llvm/CodeGen/CallingConvLower.h"
15#include "MipsISelLowering.h"
16
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,
34 const TargetLowering::CallLoweringInfo &CLI);
35
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,
45 const SDNode *CallNode);
46
47 /// Identify lowered values that originated from f128 arguments and record
48 /// this.
49 void
50 PreAnalyzeFormalArgumentsForF128(const SmallVectorImpl<ISD::InputArg> &Ins);
51
52 /// Records whether the value has been lowered from an f128.
53 SmallVector<bool, 4> OriginalArgWasF128;
54
Daniel Sandersc43cda82014-11-07 16:54:21 +000055 /// Records whether the value has been lowered from float.
56 SmallVector<bool, 4> OriginalArgWasFloat;
57
Daniel Sanders0456c152014-11-07 14:24:31 +000058 /// Records whether the value was a fixed argument.
59 /// See ISD::OutputArg::IsFixed,
60 SmallVector<bool, 4> CallOperandIsFixed;
61
62 // Used to handle MIPS16-specific calling convention tweaks.
63 // FIXME: This should probably be a fully fledged calling convention.
64 SpecialCallingConvType SpecialCallingConv;
65
66public:
67 MipsCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
68 SmallVectorImpl<CCValAssign> &locs, LLVMContext &C,
69 SpecialCallingConvType SpecialCC = NoSpecialCallingConv)
70 : CCState(CC, isVarArg, MF, locs, C), SpecialCallingConv(SpecialCC) {}
71
72 void
73 AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
74 CCAssignFn Fn,
75 std::vector<TargetLowering::ArgListEntry> &FuncArgs,
76 const SDNode *CallNode) {
77 PreAnalyzeCallOperands(Outs, FuncArgs, CallNode);
78 CCState::AnalyzeCallOperands(Outs, Fn);
79 OriginalArgWasF128.clear();
Daniel Sandersc43cda82014-11-07 16:54:21 +000080 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +000081 CallOperandIsFixed.clear();
82 }
83
84 // The AnalyzeCallOperands in the base class is not usable since we must
85 // provide a means of accessing ArgListEntry::IsFixed. Delete them from this
86 // class. This doesn't stop them being used via the base class though.
87 void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
NAKAMURA Takumi0ebd0712014-11-07 14:56:31 +000088 CCAssignFn Fn) LLVM_DELETED_FUNCTION;
Daniel Sanders0456c152014-11-07 14:24:31 +000089 void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
90 SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
NAKAMURA Takumi0ebd0712014-11-07 14:56:31 +000091 CCAssignFn Fn) LLVM_DELETED_FUNCTION;
Daniel Sanders0456c152014-11-07 14:24:31 +000092
93 void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
94 CCAssignFn Fn) {
95 PreAnalyzeFormalArgumentsForF128(Ins);
96 CCState::AnalyzeFormalArguments(Ins, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +000097 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +000098 OriginalArgWasF128.clear();
99 }
100
101 void AnalyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins,
102 CCAssignFn Fn,
103 const TargetLowering::CallLoweringInfo &CLI) {
104 PreAnalyzeCallResultForF128(Ins, CLI);
105 CCState::AnalyzeCallResult(Ins, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000106 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000107 OriginalArgWasF128.clear();
108 }
109
110 void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
111 CCAssignFn Fn) {
112 PreAnalyzeReturnForF128(Outs);
113 CCState::AnalyzeReturn(Outs, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000114 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000115 OriginalArgWasF128.clear();
116 }
117
118 bool CheckReturn(const SmallVectorImpl<ISD::OutputArg> &ArgsFlags,
119 CCAssignFn Fn) {
120 PreAnalyzeReturnForF128(ArgsFlags);
121 bool Return = CCState::CheckReturn(ArgsFlags, Fn);
Daniel Sandersc43cda82014-11-07 16:54:21 +0000122 OriginalArgWasFloat.clear();
Daniel Sanders0456c152014-11-07 14:24:31 +0000123 OriginalArgWasF128.clear();
124 return Return;
125 }
126
127 bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; }
Daniel Sandersc43cda82014-11-07 16:54:21 +0000128 bool WasOriginalArgFloat(unsigned ValNo) {
129 return OriginalArgWasFloat[ValNo];
130 }
Daniel Sanders0456c152014-11-07 14:24:31 +0000131 bool IsCallOperandFixed(unsigned ValNo) { return CallOperandIsFixed[ValNo]; }
132 SpecialCallingConvType getSpecialCallingConv() { return SpecialCallingConv; }
133};
134}
135
136#endif