LLVM 23.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
45 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
46
48 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
49
50 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
51
52 bool isFPImmLegal(const APFloat &Imm, EVT VT,
53 bool ForCodeSize) const override;
54
55 std::pair<unsigned, const TargetRegisterClass *>
57 StringRef Constraint, MVT VT) const override;
58
60 getConstraintType(StringRef Constraint) const override;
61
63 getSingleConstraintMatchWeight(AsmOperandInfo &Info,
64 const char *Constraint) const override;
65
67 std::vector<SDValue> &Ops,
68 SelectionDAG &DAG) const override;
69
70 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
71
73 bool isVarArg,
75 const SDLoc &DL, SelectionDAG &DAG,
76 SmallVectorImpl<SDValue> &InVals) const override;
77
78 SDValue LowerCall(CallLoweringInfo &CLI,
79 SmallVectorImpl<SDValue> &InVals) const override;
80
82 bool isVarArg,
84 LLVMContext &Context, const Type *RetTy) const override;
85
86 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
88 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
89 SelectionDAG &DAG) const override;
90
91 bool shouldInsertFencesForAtomic(const Instruction *I) const override {
92 return true;
93 }
94
96 shouldExpandAtomicRMWInIR(const AtomicRMWInst *) const override;
97
98 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
99 SDValue C) const override;
100
101 const XtensaSubtarget &getSubtarget() const { return Subtarget; }
102
105 MachineBasicBlock *BB) const override;
106
107private:
108 const XtensaSubtarget &Subtarget;
109
110 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
111
112 SDValue LowerImmediate(SDValue Op, SelectionDAG &DAG) const;
113
114 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
115
116 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
117
118 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
119
120 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
121
122 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
123
125
127
129
131
132 SDValue LowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
133
134 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
135
137
139
141
143
144 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
145
146 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
147
148 SDValue getAddrPCRel(SDValue Op, SelectionDAG &DAG) const;
149
150 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
151
152 MachineBasicBlock *emitSelectCC(MachineInstr &MI,
153 MachineBasicBlock *BB) const;
154};
155
156} // end namespace llvm
157
158#endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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,...
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
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 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...
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...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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:46
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.
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
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)
const XtensaSubtarget & getSubtarget() 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 ...
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...
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...
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:90
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition ValueTypes.h:396
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:176