LLVM 22.0.0git
SparcISelLowering.h
Go to the documentation of this file.
1//===-- SparcISelLowering.h - Sparc DAG Lowering Interface ------*- C++ -*-===//
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// This file defines the interfaces that Sparc uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H
15#define LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H
16
17#include "Sparc.h"
19
20namespace llvm {
21 class SparcSubtarget;
22
24 const SparcSubtarget *Subtarget;
25 public:
27 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
28
29 bool useSoftFloat() const override;
30
31 /// computeKnownBitsForTargetNode - Determine which of the bits specified
32 /// in Mask are known to be either zero or one and return them in the
33 /// KnownZero/KnownOne bitsets.
35 KnownBits &Known,
36 const APInt &DemandedElts,
37 const SelectionDAG &DAG,
38 unsigned Depth = 0) const override;
39
42 MachineBasicBlock *MBB) const override;
43
44 ConstraintType getConstraintType(StringRef Constraint) const override;
47 const char *constraint) const override;
49 std::vector<SDValue> &Ops,
50 SelectionDAG &DAG) const override;
51
52 std::pair<unsigned, const TargetRegisterClass *>
54 StringRef Constraint, MVT VT) const override;
55
56 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
57 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
58 return MVT::i32;
59 }
60
61 Register getRegisterByName(const char* RegName, LLT VT,
62 const MachineFunction &MF) const override;
63
64 /// If a physical register, this returns the register that receives the
65 /// exception address on entry to an EH pad.
67 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
68 return SP::I0;
69 }
70
71 /// If a physical register, this returns the register that receives the
72 /// exception typeid on entry to a landing pad.
74 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
75 return SP::I1;
76 }
77
78 /// Override to support customized stack guard loading.
79 bool useLoadStackGuardNode(const Module &M) const override;
80
81 /// getSetCCResultType - Return the ISD::SETCC ValueType
83 EVT VT) const override;
84
86 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
88 const SDLoc &dl, SelectionDAG &DAG,
89 SmallVectorImpl<SDValue> &InVals) const override;
91 bool isVarArg,
93 const SDLoc &dl, SelectionDAG &DAG,
94 SmallVectorImpl<SDValue> &InVals) const;
96 bool isVarArg,
98 const SDLoc &dl, SelectionDAG &DAG,
99 SmallVectorImpl<SDValue> &InVals) const;
100
101 SDValue
103 SmallVectorImpl<SDValue> &InVals) const override;
105 SmallVectorImpl<SDValue> &InVals) const;
107 SmallVectorImpl<SDValue> &InVals) const;
108
110 bool isVarArg,
112 LLVMContext &Context, const Type *RetTy) const override;
113
114 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
116 const SmallVectorImpl<SDValue> &OutVals,
117 const SDLoc &dl, SelectionDAG &DAG) const override;
119 bool IsVarArg,
121 const SmallVectorImpl<SDValue> &OutVals,
122 const SDLoc &DL, SelectionDAG &DAG) const;
124 bool IsVarArg,
126 const SmallVectorImpl<SDValue> &OutVals,
127 const SDLoc &DL, SelectionDAG &DAG) const;
128
133
134 SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const;
135 SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF,
136 SelectionDAG &DAG) const;
138
139 SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args, SDValue Arg,
140 const SDLoc &DL, SelectionDAG &DAG) const;
142 const char *LibFuncName,
143 unsigned numArgs) const;
145 const SDLoc &DL, SelectionDAG &DAG) const;
146
148
149 SDValue PerformBITCASTCombine(SDNode *N, DAGCombinerInfo &DCI) const;
150
152 SelectionDAG &DAG) const;
153
154 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
155
157 CallLoweringInfo &CLI,
158 MachineFunction &MF) const;
159
160 bool ShouldShrinkFPConstant(EVT VT) const override {
161 // Do not shrink FP constpool if VT == MVT::f128.
162 // (ldd, call _Q_fdtoq) is more expensive than two ldds.
163 return VT != MVT::f128;
164 }
165
166 bool isFNegFree(EVT VT) const override;
167
168 bool isFPImmLegal(const APFloat &Imm, EVT VT,
169 bool ForCodeSize) const override;
170
171 bool isCtlzFast() const override;
172
173 bool isCheapToSpeculateCtlz(Type *Ty) const override {
174 return isCtlzFast();
175 }
176
177 bool isCheapToSpeculateCttz(Type *Ty) const override;
178
179 bool enableAggressiveFMAFusion(EVT VT) const override { return true; };
180
182 EVT VT) const override;
183
185 AtomicOrdering Ord) const override;
187 AtomicOrdering Ord) const override;
188
189 bool shouldInsertFencesForAtomic(const Instruction *I) const override {
190 // FIXME: We insert fences for each atomics and generate
191 // sub-optimal code for PSO/TSO. (Approximately nobody uses any
192 // mode but TSO, which makes this even more silly)
193 return true;
194 }
195
197
200 SelectionDAG &DAG) const override;
201
203 unsigned BROpcode) const;
204
206 SDNode *Node) const override;
207 };
208} // end namespace llvm
209
210#endif // LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define RegName(no)
lazy value info
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
This file describes how to lower LLVM code to machine code.
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
an instruction that atomically reads a memory location, combines it with another value,...
CCState - This class holds information needed while lowering arguments and return values.
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Machine Value Type.
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool shouldInsertFencesForAtomic(const Instruction *I) const override
Whether AtomicExpandPass should automatically insert fences and reduce ordering for this atomic.
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
bool useSoftFloat() const override
SDValue bitcastConstantFPToInt(ConstantFPSDNode *C, const SDLoc &DL, SelectionDAG &DAG) const
MachineBasicBlock * expandSelectCC(MachineInstr &MI, MachineBasicBlock *BB, unsigned BROpcode) const
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
bool isCtlzFast() const override
Return true if ctlz instruction is fast.
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array,...
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint letter, return the type of constraint it is for this target.
SDValue LowerFormalArguments_32(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
LowerFormalArguments32 - V8 uses a very simple ABI, where all values are passed in either one or two ...
bool isCheapToSpeculateCtlz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool isCheapToSpeculateCttz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
bool IsEligibleForTailCallOptimization(CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF) const
IsEligibleForTailCallOptimization - Check whether the call is eligible for tail call optimization.
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
bool isFNegFree(EVT VT) const override
Return true if an fneg operation is free to the point where it is never worthwhile to replace it with...
SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args, SDValue Arg, const SDLoc &DL, SelectionDAG &DAG) const
SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF, SelectionDAG &DAG) const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
Instruction * emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
Inserts in the IR a target-specific intrinsic specifying a fence.
void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const override
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag.
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
computeKnownBitsForTargetNode - Determine which of the bits specified in Mask are known to be either ...
SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
Instruction * emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
SDValue LowerF128Op(SDValue Op, SelectionDAG &DAG, const char *LibFuncName, unsigned numArgs) const
SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
SDValue LowerReturn_32(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override
Return the type to use for a scalar shift opcode, given the shifted amount type.
SDValue PerformBITCASTCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerReturn_64(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
getSetCCResultType - Return the ISD::SETCC ValueType
SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const
bool useLoadStackGuardNode(const Module &M) const override
Override to support customized stack guard loading.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFormalArguments_64(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
bool ShouldShrinkFPConstant(EVT VT) const override
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
SparcTargetLowering(const TargetMachine &TM, const SparcSubtarget &STI)
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
LowerAsmOperandForConstraint - Lower the specified operand into the Ops vector.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
SDValue LowerF128Compare(SDValue LHS, SDValue RHS, unsigned &SPCC, const SDLoc &DL, SelectionDAG &DAG) const
bool enableAggressiveFMAFusion(EVT VT) const override
Return true if target always benefits from combining into FMA for a given value type.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
#define N
Extended Value Type.
Definition ValueTypes.h:35
This contains information for each constraint that we are lowering.
This structure contains all information that is necessary for lowering calls.