LLVM  14.0.0git
MipsCCState.h
Go to the documentation of this file.
1 //===---- MipsCCState.h - CCState with Mips specific extensions -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MIPSCCSTATE_H
10 #define MIPSCCSTATE_H
11 
12 #include "MipsISelLowering.h"
13 #include "llvm/ADT/SmallVector.h"
15 
16 namespace llvm {
17 class SDNode;
18 class MipsSubtarget;
19 
20 class MipsCCState : public CCState {
21 public:
23 
24  /// Determine the SpecialCallingConvType for the given callee
27  const MipsSubtarget &Subtarget);
28 
29  /// This function returns true if CallSym is a long double emulation routine.
30  ///
31  /// FIXME: Changing the ABI based on the callee name is unsound. The lib func
32  /// address could be captured.
33  static bool isF128SoftLibCall(const char *CallSym);
34 
35  static bool originalTypeIsF128(const Type *Ty, const char *Func);
36  static bool originalEVTTypeIsVectorFloat(EVT Ty);
37  static bool originalTypeIsVectorFloat(const Type *Ty);
38 
39  void PreAnalyzeCallOperand(const Type *ArgTy, bool IsFixed, const char *Func);
40 
41  void PreAnalyzeFormalArgument(const Type *ArgTy, ISD::ArgFlagsTy Flags);
42  void PreAnalyzeReturnValue(EVT ArgVT);
43 
44 private:
45  /// Identify lowered values that originated from f128 arguments and record
46  /// this for use by RetCC_MipsN.
47  void PreAnalyzeCallResultForF128(const SmallVectorImpl<ISD::InputArg> &Ins,
48  const Type *RetTy, const char * Func);
49 
50  /// Identify lowered values that originated from f128 arguments and record
51  /// this for use by RetCC_MipsN.
52  void PreAnalyzeReturnForF128(const SmallVectorImpl<ISD::OutputArg> &Outs);
53 
54  /// Identify lowered values that originated from f128 arguments and record
55  /// this.
56  void
57  PreAnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
58  std::vector<TargetLowering::ArgListEntry> &FuncArgs,
59  const char *Func);
60 
61  /// Identify lowered values that originated from f128 arguments and record
62  /// this for use by RetCC_MipsN.
63  void
64  PreAnalyzeFormalArgumentsForF128(const SmallVectorImpl<ISD::InputArg> &Ins);
65 
66  void
67  PreAnalyzeCallResultForVectorFloat(const SmallVectorImpl<ISD::InputArg> &Ins,
68  const Type *RetTy);
69 
70  void PreAnalyzeFormalArgumentsForVectorFloat(
72 
73  void
74  PreAnalyzeReturnForVectorFloat(const SmallVectorImpl<ISD::OutputArg> &Outs);
75 
76  /// Records whether the value has been lowered from an f128.
77  SmallVector<bool, 4> OriginalArgWasF128;
78 
79  /// Records whether the value has been lowered from float.
80  SmallVector<bool, 4> OriginalArgWasFloat;
81 
82  /// Records whether the value has been lowered from a floating point vector.
83  SmallVector<bool, 4> OriginalArgWasFloatVector;
84 
85  /// Records whether the return value has been lowered from a floating point
86  /// vector.
87  SmallVector<bool, 4> OriginalRetWasFloatVector;
88 
89  /// Records whether the value was a fixed argument.
90  /// See ISD::OutputArg::IsFixed,
91  SmallVector<bool, 4> CallOperandIsFixed;
92 
93  // Used to handle MIPS16-specific calling convention tweaks.
94  // FIXME: This should probably be a fully fledged calling convention.
95  SpecialCallingConvType SpecialCallingConv;
96 
97 public:
101  : CCState(CC, isVarArg, MF, locs, C), SpecialCallingConv(SpecialCC) {}
102 
105  std::vector<TargetLowering::ArgListEntry> &FuncArgs, const char *Func) {
106  OriginalArgWasF128.clear();
107  OriginalArgWasFloat.clear();
108  OriginalArgWasFloatVector.clear();
109  CallOperandIsFixed.clear();
110  PreAnalyzeCallOperands(Outs, FuncArgs, Func);
111  }
112 
113  void
115  CCAssignFn Fn,
116  std::vector<TargetLowering::ArgListEntry> &FuncArgs,
117  const char *Func) {
118  PreAnalyzeCallOperands(Outs, Fn, FuncArgs, Func);
120  }
121 
122  // The AnalyzeCallOperands in the base class is not usable since we must
123  // provide a means of accessing ArgListEntry::IsFixed. Delete them from this
124  // class. This doesn't stop them being used via the base class though.
126  CCAssignFn Fn) = delete;
127  void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
129  CCAssignFn Fn) = delete;
130 
132  CCAssignFn Fn) {
133  OriginalArgWasFloat.clear();
134  OriginalArgWasF128.clear();
135  OriginalArgWasFloatVector.clear();
136  PreAnalyzeFormalArgumentsForF128(Ins);
137  }
138 
140  CCAssignFn Fn) {
143  }
144 
145  void PreAnalyzeCallResult(const Type *RetTy, const char *Func) {
146  OriginalArgWasF128.push_back(originalTypeIsF128(RetTy, Func));
147  OriginalArgWasFloat.push_back(RetTy->isFloatingPointTy());
148  OriginalRetWasFloatVector.push_back(originalTypeIsVectorFloat(RetTy));
149  }
150 
152  CCAssignFn Fn, const Type *RetTy,
153  const char *Func) {
154  OriginalArgWasFloat.clear();
155  OriginalArgWasF128.clear();
156  OriginalArgWasFloatVector.clear();
157  PreAnalyzeCallResultForF128(Ins, RetTy, Func);
158  PreAnalyzeCallResultForVectorFloat(Ins, RetTy);
159  }
160 
162  CCAssignFn Fn, const Type *RetTy,
163  const char *Func) {
164  PreAnalyzeCallResult(Ins, Fn, RetTy, Func);
166  }
167 
169  CCAssignFn Fn) {
170  OriginalArgWasFloat.clear();
171  OriginalArgWasF128.clear();
172  OriginalArgWasFloatVector.clear();
173  PreAnalyzeReturnForF128(Outs);
174  PreAnalyzeReturnForVectorFloat(Outs);
175  }
176 
178  CCAssignFn Fn) {
179  PreAnalyzeReturn(Outs, Fn);
180  CCState::AnalyzeReturn(Outs, Fn);
181  }
182 
184  CCAssignFn Fn) {
185  PreAnalyzeReturnForF128(ArgsFlags);
186  PreAnalyzeReturnForVectorFloat(ArgsFlags);
187  bool Return = CCState::CheckReturn(ArgsFlags, Fn);
188  OriginalArgWasFloat.clear();
189  OriginalArgWasF128.clear();
190  OriginalArgWasFloatVector.clear();
191  return Return;
192  }
193 
194  bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; }
195  bool WasOriginalArgFloat(unsigned ValNo) {
196  return OriginalArgWasFloat[ValNo];
197  }
198  bool WasOriginalArgVectorFloat(unsigned ValNo) const {
199  return OriginalArgWasFloatVector[ValNo];
200  }
201  bool WasOriginalRetVectorFloat(unsigned ValNo) const {
202  return OriginalRetWasFloatVector[ValNo];
203  }
204  bool IsCallOperandFixed(unsigned ValNo) { return CallOperandIsFixed[ValNo]; }
205  SpecialCallingConvType getSpecialCallingConv() { return SpecialCallingConv; }
206 };
207 }
208 
209 #endif
llvm::MipsCCState::originalEVTTypeIsVectorFloat
static bool originalEVTTypeIsVectorFloat(EVT Ty)
Return true if the original type was vXfXX.
Definition: MipsCCState.cpp:54
llvm::MipsCCState::NoSpecialCallingConv
@ NoSpecialCallingConv
Definition: MipsCCState.h:22
llvm::MipsCCState::PreAnalyzeReturnValue
void PreAnalyzeReturnValue(EVT ArgVT)
Definition: MipsCCState.cpp:129
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::MipsCCState::AnalyzeCallOperands
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn, std::vector< TargetLowering::ArgListEntry > &FuncArgs, const char *Func)
Definition: MipsCCState.h:114
llvm::MipsCCState::PreAnalyzeFormalArgument
void PreAnalyzeFormalArgument(const Type *ArgTy, ISD::ArgFlagsTy Flags)
Definition: MipsCCState.cpp:157
llvm::CCState
CCState - This class holds information needed while lowering arguments and return values.
Definition: CallingConvLower.h:191
llvm::MipsCCState::PreAnalyzeCallResult
void PreAnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn, const Type *RetTy, const char *Func)
Definition: MipsCCState.h:151
llvm::SmallVector< bool, 4 >
llvm::SDNode
Represents one node in the SelectionDAG.
Definition: SelectionDAGNodes.h:455
llvm::MipsCCState::CheckReturn
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &ArgsFlags, CCAssignFn Fn)
Definition: MipsCCState.h:183
llvm::MipsCCState::SpecialCallingConvType
SpecialCallingConvType
Definition: MipsCCState.h:22
llvm::CCState::AnalyzeFormalArguments
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
Definition: CallingConvLower.cpp:90
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Type::isFloatingPointTy
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
Definition: Type.h:162
llvm::MipsCCState::originalTypeIsVectorFloat
static bool originalTypeIsVectorFloat(const Type *Ty)
Return true if the original type was vXfXX / vXfXX.
Definition: MipsCCState.cpp:62
llvm::CCState::AnalyzeCallOperands
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
Definition: CallingConvLower.cpp:131
llvm::MipsCCState::getSpecialCallingConvForCallee
static SpecialCallingConvType getSpecialCallingConvForCallee(const SDNode *Callee, const MipsSubtarget &Subtarget)
Determine the SpecialCallingConvType for the given callee.
Definition: MipsCCState.cpp:70
llvm::MipsCCState::WasOriginalRetVectorFloat
bool WasOriginalRetVectorFloat(unsigned ValNo) const
Definition: MipsCCState.h:201
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:35
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MipsCCState::originalTypeIsF128
static bool originalTypeIsF128(const Type *Ty, const char *Func)
This function returns true if Ty is fp128, {f128} or i128 which was originally a fp128.
Definition: MipsCCState.cpp:39
llvm::CCState::AnalyzeReturn
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
Definition: CallingConvLower.cpp:118
llvm::MipsCCState::getSpecialCallingConv
SpecialCallingConvType getSpecialCallingConv()
Definition: MipsCCState.h:205
llvm::MipsCCState::PreAnalyzeFormalArguments
void PreAnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
Definition: MipsCCState.h:131
llvm::MipsCCState::PreAnalyzeCallResult
void PreAnalyzeCallResult(const Type *RetTy, const char *Func)
Definition: MipsCCState.h:145
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::MipsCCState::AnalyzeFormalArguments
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
Definition: MipsCCState.h:139
llvm::CCAssignFn
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
Definition: CallingConvLower.h:177
llvm::MipsCCState::WasOriginalArgF128
bool WasOriginalArgF128(unsigned ValNo)
Definition: MipsCCState.h:194
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::MipsCCState::Mips16RetHelperConv
@ Mips16RetHelperConv
Definition: MipsCCState.h:22
llvm::MipsCCState::WasOriginalArgFloat
bool WasOriginalArgFloat(unsigned ValNo)
Definition: MipsCCState.h:195
llvm::MachineFunction
Definition: MachineFunction.h:234
llvm::CCState::isVarArg
bool isVarArg() const
Definition: CallingConvLower.h:260
llvm::MipsCCState::AnalyzeCallResult
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn, const Type *RetTy, const char *Func)
Definition: MipsCCState.h:161
llvm::MipsCCState::PreAnalyzeCallOperands
void PreAnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn, std::vector< TargetLowering::ArgListEntry > &FuncArgs, const char *Func)
Definition: MipsCCState.h:103
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
llvm::MipsSubtarget
Definition: MipsSubtarget.h:39
llvm::CCState::CheckReturn
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
Definition: CallingConvLower.cpp:104
llvm::MipsCCState::MipsCCState
MipsCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &locs, LLVMContext &C, SpecialCallingConvType SpecialCC=NoSpecialCallingConv)
Definition: MipsCCState.h:98
llvm::CCState::AnalyzeCallResult
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
Definition: CallingConvLower.cpp:167
MipsISelLowering.h
CallingConvLower.h
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:585
llvm::MipsCCState::AnalyzeReturn
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
Definition: MipsCCState.h:177
llvm::MipsCCState::PreAnalyzeReturn
void PreAnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
Definition: MipsCCState.h:168
SmallVector.h
llvm::MipsISD::Ins
@ Ins
Definition: MipsISelLowering.h:157
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::MipsCCState::isF128SoftLibCall
static bool isF128SoftLibCall(const char *CallSym)
This function returns true if CallSym is a long double emulation routine.
Definition: MipsCCState.cpp:15
llvm::MipsCCState
Definition: MipsCCState.h:20
llvm::MipsCCState::WasOriginalArgVectorFloat
bool WasOriginalArgVectorFloat(unsigned ValNo) const
Definition: MipsCCState.h:198
llvm::MipsCCState::PreAnalyzeCallOperand
void PreAnalyzeCallOperand(const Type *ArgTy, bool IsFixed, const char *Func)
Definition: MipsCCState.cpp:133
llvm::MipsCCState::IsCallOperandFixed
bool IsCallOperandFixed(unsigned ValNo)
Definition: MipsCCState.h:204