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
23class XtensaSubtarget;
24
26public:
27 explicit XtensaTargetLowering(const TargetMachine &TM,
28 const XtensaSubtarget &STI);
29
30 MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override {
31 return LHSTy.getSizeInBits() <= 32 ? MVT::i32 : MVT::i64;
32 }
33
35 EVT VT) const override;
36
38 EVT VT) const override {
39 if (!VT.isVector())
40 return MVT::i32;
42 }
43
44 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
45
46 bool isFPImmLegal(const APFloat &Imm, EVT VT,
47 bool ForCodeSize) const override;
48
49 std::pair<unsigned, const TargetRegisterClass *>
51 StringRef Constraint, MVT VT) const override;
52
54 getConstraintType(StringRef Constraint) const override;
55
58 const char *Constraint) const override;
59
61 std::vector<SDValue> &Ops,
62 SelectionDAG &DAG) const override;
63
64 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
65
67 bool isVarArg,
69 const SDLoc &DL, SelectionDAG &DAG,
70 SmallVectorImpl<SDValue> &InVals) const override;
71
72 SDValue LowerCall(CallLoweringInfo &CLI,
73 SmallVectorImpl<SDValue> &InVals) const override;
74
76 bool isVarArg,
78 LLVMContext &Context, const Type *RetTy) const override;
79
80 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
82 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
83 SelectionDAG &DAG) const override;
84
85 bool shouldInsertFencesForAtomic(const Instruction *I) const override {
86 return true;
87 }
88
90
91 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
92 SDValue C) const override;
93
94 const XtensaSubtarget &getSubtarget() const { return Subtarget; }
95
98 MachineBasicBlock *BB) const override;
99
100private:
101 const XtensaSubtarget &Subtarget;
102
103 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
104
105 SDValue LowerImmediate(SDValue Op, SelectionDAG &DAG) const;
106
107 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
108
109 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
110
111 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
112
113 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
114
115 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
116
118
120
122
124
125 SDValue LowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
126
127 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
128
130
132
134
136
137 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
138
139 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
140
141 SDValue getAddrPCRel(SDValue Op, SelectionDAG &DAG) const;
142
143 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
144
145 MachineBasicBlock *emitSelectCC(MachineInstr &MI,
146 MachineBasicBlock *BB) const;
147};
148
149} // end namespace llvm
150
151#endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Definition CSEInfo.cpp:27
IRTranslator LLVM IR MI
static Value * LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP)
Emit the code to lower ctpop of V before the specified instruction IP.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
static SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
static SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, bool hasHardQuad, bool isV9, bool is64Bit)
static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG)
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
This file describes how to lower LLVM code to machine code.
static SDValue LowerVACOPY(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
an instruction that atomically reads a memory location, combines it with another value,...
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.
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...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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
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.
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.
XtensaTargetLowering(const TargetMachine &TM, const XtensaSubtarget &STI)
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...
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.
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.
DWARFExpression::Operation Op
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:373
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:168