LLVM  8.0.1
MipsCCState.h
Go to the documentation of this file.
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 "MipsISelLowering.h"
14 #include "llvm/ADT/SmallVector.h"
16 
17 namespace llvm {
18 class SDNode;
19 class MipsSubtarget;
20 
21 class MipsCCState : public CCState {
22 public:
24 
25  /// Determine the SpecialCallingConvType for the given 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 Type *RetTy, const char * Func);
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 char *Func);
46 
47  /// Identify lowered values that originated from f128 arguments and record
48  /// this for use by RetCC_MipsN.
49  void
50  PreAnalyzeFormalArgumentsForF128(const SmallVectorImpl<ISD::InputArg> &Ins);
51 
52  void
53  PreAnalyzeCallResultForVectorFloat(const SmallVectorImpl<ISD::InputArg> &Ins,
54  const Type *RetTy);
55 
56  void PreAnalyzeFormalArgumentsForVectorFloat(
58 
59  void
60  PreAnalyzeReturnForVectorFloat(const SmallVectorImpl<ISD::OutputArg> &Outs);
61 
62  /// Records whether the value has been lowered from an f128.
63  SmallVector<bool, 4> OriginalArgWasF128;
64 
65  /// Records whether the value has been lowered from float.
66  SmallVector<bool, 4> OriginalArgWasFloat;
67 
68  /// 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 
75  /// 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 
83 public:
86  SpecialCallingConvType SpecialCC = NoSpecialCallingConv)
87  : CCState(CC, isVarArg, MF, locs, C), SpecialCallingConv(SpecialCC) {}
88 
89  void
91  CCAssignFn Fn,
92  std::vector<TargetLowering::ArgListEntry> &FuncArgs,
93  const char *Func) {
94  PreAnalyzeCallOperands(Outs, FuncArgs, Func);
96  OriginalArgWasF128.clear();
97  OriginalArgWasFloat.clear();
98  OriginalArgWasFloatVector.clear();
99  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.
106  CCAssignFn Fn) = delete;
107  void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
109  CCAssignFn Fn) = delete;
110 
112  CCAssignFn Fn) {
113  PreAnalyzeFormalArgumentsForF128(Ins);
115  OriginalArgWasFloat.clear();
116  OriginalArgWasF128.clear();
117  OriginalArgWasFloatVector.clear();
118  }
119 
121  CCAssignFn Fn, const Type *RetTy,
122  const char *Func) {
123  PreAnalyzeCallResultForF128(Ins, RetTy, Func);
124  PreAnalyzeCallResultForVectorFloat(Ins, RetTy);
126  OriginalArgWasFloat.clear();
127  OriginalArgWasF128.clear();
128  OriginalArgWasFloatVector.clear();
129  }
130 
132  CCAssignFn Fn) {
133  PreAnalyzeReturnForF128(Outs);
134  PreAnalyzeReturnForVectorFloat(Outs);
135  CCState::AnalyzeReturn(Outs, Fn);
136  OriginalArgWasFloat.clear();
137  OriginalArgWasF128.clear();
138  OriginalArgWasFloatVector.clear();
139  }
140 
142  CCAssignFn Fn) {
143  PreAnalyzeReturnForF128(ArgsFlags);
144  PreAnalyzeReturnForVectorFloat(ArgsFlags);
145  bool Return = CCState::CheckReturn(ArgsFlags, Fn);
146  OriginalArgWasFloat.clear();
147  OriginalArgWasF128.clear();
148  OriginalArgWasFloatVector.clear();
149  return Return;
150  }
151 
152  bool WasOriginalArgF128(unsigned ValNo) { return OriginalArgWasF128[ValNo]; }
153  bool WasOriginalArgFloat(unsigned ValNo) {
154  return OriginalArgWasFloat[ValNo];
155  }
156  bool WasOriginalArgVectorFloat(unsigned ValNo) const {
157  return OriginalArgWasFloatVector[ValNo];
158  }
159  bool WasOriginalRetVectorFloat(unsigned ValNo) const {
160  return OriginalRetWasFloatVector[ValNo];
161  }
162  bool IsCallOperandFixed(unsigned ValNo) { return CallOperandIsFixed[ValNo]; }
163  SpecialCallingConvType getSpecialCallingConv() { return SpecialCallingConv; }
164 };
165 }
166 
167 #endif
uint64_t CallInst * C
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
Definition: MipsCCState.h:111
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
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...
bool WasOriginalArgFloat(unsigned ValNo)
Definition: MipsCCState.h:153
bool WasOriginalArgVectorFloat(unsigned ValNo) const
Definition: MipsCCState.h:156
bool WasOriginalRetVectorFloat(unsigned ValNo) const
Definition: MipsCCState.h:159
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
static SpecialCallingConvType getSpecialCallingConvForCallee(const SDNode *Callee, const MipsSubtarget &Subtarget)
Determine the SpecialCallingConvType for the given callee.
Definition: MipsCCState.cpp:71
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn, const Type *RetTy, const char *Func)
Definition: MipsCCState.h:120
bool WasOriginalArgF128(unsigned ValNo)
Definition: MipsCCState.h:152
amdgpu Simplify well known AMD library false Value * Callee
MipsCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &locs, LLVMContext &C, SpecialCallingConvType SpecialCC=NoSpecialCallingConv)
Definition: MipsCCState.h:84
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
SpecialCallingConvType getSpecialCallingConv()
Definition: MipsCCState.h:163
CCState - This class holds information needed while lowering arguments and return values...
bool isVarArg() const
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn, std::vector< TargetLowering::ArgListEntry > &FuncArgs, const char *Func)
Definition: MipsCCState.h:90
Represents one node in the SelectionDAG.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
bool IsCallOperandFixed(unsigned ValNo)
Definition: MipsCCState.h:162
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
Definition: MipsCCState.h:131
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 ...
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &ArgsFlags, CCAssignFn Fn)
Definition: MipsCCState.h:141