LLVM 20.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
33 // Extract unsigned immediate. Operand 0 is value, operand 1
34 // is bit position of the field [0..31], operand 2 is bit size
35 // of the field [1..16]
37
38 // Wraps a TargetGlobalAddress that should be loaded using PC-relative
39 // accesses. Operand 0 is the address.
42
43 // Select with condition operator - This selects between a true value and
44 // a false value (ops #2 and #3) based on the boolean result of comparing
45 // the lhs and rhs (ops #0 and #1) of a conditional expression with the
46 // condition code in op #4
48
49 // SRCL(R) performs shift left(right) of the concatenation of 2 registers
50 // and returns high(low) 32-bit part of 64-bit result
52 // Shift Right Combined
54};
55}
56
57class XtensaSubtarget;
58
60public:
61 explicit XtensaTargetLowering(const TargetMachine &TM,
62 const XtensaSubtarget &STI);
63
64 MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override {
65 return LHSTy.getSizeInBits() <= 32 ? MVT::i32 : MVT::i64;
66 }
67
69 EVT VT) const override {
70 if (!VT.isVector())
71 return MVT::i32;
73 }
74
75 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
76
77 const char *getTargetNodeName(unsigned Opcode) const override;
78
79 std::pair<unsigned, const TargetRegisterClass *>
81 StringRef Constraint, MVT VT) const override;
82
84 getConstraintType(StringRef Constraint) const override;
85
88 const char *Constraint) const override;
89
91 std::vector<SDValue> &Ops,
92 SelectionDAG &DAG) const override;
93
94 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
95
97 bool isVarArg,
99 const SDLoc &DL, SelectionDAG &DAG,
100 SmallVectorImpl<SDValue> &InVals) const override;
101
102 SDValue LowerCall(CallLoweringInfo &CLI,
103 SmallVectorImpl<SDValue> &InVals) const override;
104
106 bool isVarArg,
108 LLVMContext &Context) const override;
109
110 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
112 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
113 SelectionDAG &DAG) const override;
114
115 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
116 SDValue C) const override;
117
118 const XtensaSubtarget &getSubtarget() const { return Subtarget; }
119
122 MachineBasicBlock *BB) const override;
123
124private:
125 const XtensaSubtarget &Subtarget;
126
127 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
128
129 SDValue LowerImmediate(SDValue Op, SelectionDAG &DAG) const;
130
131 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
132
133 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
134
135 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
136
137 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
138
139 SDValue LowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
140
141 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
142
143 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
144
145 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
146
147 SDValue LowerSTACKSAVE(SDValue Op, SelectionDAG &DAG) const;
148
149 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const;
150
151 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
152
153 SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
154
155 SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
156
157 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
158
159 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
160
161 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
162
163 SDValue getAddrPCRel(SDValue Op, SelectionDAG &DAG) const;
164
165 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
166
167 MachineBasicBlock *emitSelectCC(MachineInstr &MI,
168 MachineBasicBlock *BB) const;
169};
170
171} // end namespace llvm
172
173#endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
IRTranslator LLVM IR MI
unsigned const TargetRegisterInfo * TRI
This file describes how to lower LLVM code to machine code.
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:67
Machine Value Type.
Representation of each machine instruction.
Definition: MachineInstr.h:69
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:228
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
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:77
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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.
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,...
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
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:1490
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, 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