LLVM 22.0.0git
XtensaISelLowering.h
Go to the documentation of this file.
1//===- XtensaISelLowering.h - Xtensa 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 Xtensa uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H
15#define LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H
16
20
21namespace llvm {
22
23namespace XtensaISD {
24enum {
27
28 // Calls a function. Operand 0 is the chain operand and operand 1
29 // is the target address. The arguments start at operand 2.
30 // There is an optional glue operand at the end.
32 // Call with rotation window by 8 registers
34
35 // Extract unsigned immediate. Operand 0 is value, operand 1
36 // is bit position of the field [0..31], operand 2 is bit size
37 // of the field [1..16]
39
41
42 // Wraps a TargetGlobalAddress that should be loaded using PC-relative
43 // accesses. Operand 0 is the address.
47
49
50 // Select with condition operator - This selects between a true value and
51 // a false value (ops #2 and #3) based on the boolean result of comparing
52 // the lhs and rhs (ops #0 and #1) of a conditional expression with the
53 // condition code in op #4
55 // Select with condition operator - This selects between a true value and
56 // a false value (ops #2 and #3) based on the boolean result of comparing
57 // f32 operands lhs and rhs (ops #0 and #1) of a conditional expression
58 // with the condition code in op #4 and boolean branch kind in op #5
60
61 // SRCL(R) performs shift left(right) of the concatenation of 2 registers
62 // and returns high(low) 32-bit part of 64-bit result
64 // Shift Right Combined
66
67 // Floating point unordered compare conditions
72 // Floating point compare conditions
76 // FP multipy-add/sub
79 // FP move
81};
82}
83
84class XtensaSubtarget;
85
87public:
88 explicit XtensaTargetLowering(const TargetMachine &TM,
89 const XtensaSubtarget &STI);
90
91 MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override {
92 return LHSTy.getSizeInBits() <= 32 ? MVT::i32 : MVT::i64;
93 }
94
96 EVT VT) const override;
97
99 EVT VT) const override {
100 if (!VT.isVector())
101 return MVT::i32;
103 }
104
105 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
106
107 const char *getTargetNodeName(unsigned Opcode) const override;
108
109 bool isFPImmLegal(const APFloat &Imm, EVT VT,
110 bool ForCodeSize) const override;
111
112 std::pair<unsigned, const TargetRegisterClass *>
114 StringRef Constraint, MVT VT) const override;
115
117 getConstraintType(StringRef Constraint) const override;
118
120 getSingleConstraintMatchWeight(AsmOperandInfo &Info,
121 const char *Constraint) const override;
122
124 std::vector<SDValue> &Ops,
125 SelectionDAG &DAG) const override;
126
127 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
128
130 bool isVarArg,
132 const SDLoc &DL, SelectionDAG &DAG,
133 SmallVectorImpl<SDValue> &InVals) const override;
134
135 SDValue LowerCall(CallLoweringInfo &CLI,
136 SmallVectorImpl<SDValue> &InVals) const override;
137
139 bool isVarArg,
141 LLVMContext &Context, const Type *RetTy) const override;
142
143 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
145 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
146 SelectionDAG &DAG) const override;
147
148 bool shouldInsertFencesForAtomic(const Instruction *I) const override {
149 return true;
150 }
151
153
154 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
155 SDValue C) const override;
156
157 const XtensaSubtarget &getSubtarget() const { return Subtarget; }
158
161 MachineBasicBlock *BB) const override;
162
163private:
164 const XtensaSubtarget &Subtarget;
165
166 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
167
168 SDValue LowerImmediate(SDValue Op, SelectionDAG &DAG) const;
169
170 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
171
172 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
173
174 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
175
176 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
177
178 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
179
180 SDValue LowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
181
182 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
183
184 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
185
186 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
187
188 SDValue LowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
189
190 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
191
192 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
193
194 SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
195
196 SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
197
198 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
199
200 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
201
202 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
203
204 SDValue getAddrPCRel(SDValue Op, SelectionDAG &DAG) const;
205
206 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
207
208 MachineBasicBlock *emitSelectCC(MachineInstr &MI,
209 MachineBasicBlock *BB) const;
210};
211
212} // end namespace llvm
213
214#endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
return RetTy
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
Register const TargetRegisterInfo * TRI
This file describes how to lower LLVM code to machine code.
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:709
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
Machine Value Type.
Representation of each machine instruction.
Definition: MachineInstr.h:72
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
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...
Definition: SelectionDAG.h:229
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
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.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
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
bool shouldInsertFencesForAtomic(const Instruction *I) const override
Whether AtomicExpandPass should automatically insert fences and reduce ordering for this atomic.
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...
TargetLowering::ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &Info, const char *Constraint) const override
Examine constraint string and operand type and determine a weight value.
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
bool decomposeMulByConstant(LLVMContext &Context, EVT VT, SDValue C) const override
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override
Return the type to use for a scalar shift opcode, given the shifted amount type.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
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,...
EVT getSetCCResultType(const DataLayout &, LLVMContext &, EVT VT) const override
Return the ValueType of the result of SETCC operations.
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
const XtensaSubtarget & getSubtarget() const
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
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,...
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Return the register type for a given MVT.
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...
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1574
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
Extended Value Type.
Definition: ValueTypes.h:35
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
Definition: ValueTypes.h:94
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition: ValueTypes.h:368
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:168