1 //===---- 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 17 namespace llvm { 18 class SDNode; 19 class MipsSubtarget; 20 21 class MipsCCState : public CCState { 22 public: 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 30 private: 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 55 /// Records whether the value has been lowered from float. 56 SmallVector<bool, 4> OriginalArgWasFloat; 57 58 /// 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 66 public: 67 MipsCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF, 68 const TargetMachine &TM, SmallVectorImpl<CCValAssign> &locs, 69 LLVMContext &C, 70 SpecialCallingConvType SpecialCC = NoSpecialCallingConv) 71 : CCState(CC, isVarArg, MF, TM, locs, C), SpecialCallingConv(SpecialCC) {} 72 73 void 74 AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs, 75 CCAssignFn Fn, 76 std::vector<TargetLowering::ArgListEntry> &FuncArgs, 77 const SDNode *CallNode) { 78 PreAnalyzeCallOperands(Outs, FuncArgs, CallNode); 79 CCState::AnalyzeCallOperands(Outs, Fn); 80 OriginalArgWasF128.clear(); 81 OriginalArgWasFloat.clear(); 82 CallOperandIsFixed.clear(); 83 } 84 85 // The AnalyzeCallOperands in the base class is not usable since we must 86 // provide a means of accessing ArgListEntry::IsFixed. Delete them from this 87 // class. This doesn't stop them being used via the base class though. 88 void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs, 89 CCAssignFn Fn) LLVM_DELETED_FUNCTION; 90 void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs, 91 SmallVectorImpl<ISD::ArgFlagsTy> &Flags, 92 CCAssignFn Fn) LLVM_DELETED_FUNCTION; 93 94 void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins, 95 CCAssignFn Fn) { 96 PreAnalyzeFormalArgumentsForF128(Ins); 97 CCState::AnalyzeFormalArguments(Ins, Fn); 98 OriginalArgWasFloat.clear(); 99 OriginalArgWasF128.clear(); 100 } 101 102 void AnalyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins, 103 CCAssignFn Fn, 104 const TargetLowering::CallLoweringInfo &CLI) { 105 PreAnalyzeCallResultForF128(Ins, CLI); 106 CCState::AnalyzeCallResult(Ins, Fn); 107 OriginalArgWasFloat.clear(); 108 OriginalArgWasF128.clear(); 109 } 110 111 void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs, 112 CCAssignFn Fn) { 113 PreAnalyzeReturnForF128(Outs); 114 CCState::AnalyzeReturn(Outs, Fn); 115 OriginalArgWasFloat.clear(); 116 OriginalArgWasF128.clear(); 117 } 118 119 bool CheckReturn(const SmallVectorImpl<ISD::OutputArg> &ArgsFlags, 120 CCAssignFn Fn) { 121 PreAnalyzeReturnForF128(ArgsFlags); 122 bool Return = CCState::CheckReturn(ArgsFlags, Fn); 123 OriginalArgWasFloat.clear(); 124 OriginalArgWasF128.clear(); 125 return Return; 126 } 127 128 bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; } 129 bool WasOriginalArgFloat(unsigned ValNo) { 130 return OriginalArgWasFloat[ValNo]; 131 } 132 bool IsCallOperandFixed(unsigned ValNo) { return CallOperandIsFixed[ValNo]; } 133 SpecialCallingConvType getSpecialCallingConv() { return SpecialCallingConv; } 134 }; 135 } 136 137 #endif 138