25#define DEBUG_TYPE "xtensa-isel"
45 std::vector<SDValue> &OutOps)
override;
51 EVT ValTy =
Addr.getValueType();
55 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
61 if (TM.isPositionIndependent()) {
63 "PIC relocations are not supported ",
65 CurDAG->getContext()->diagnose(Diag);
74 if (CurDAG->isBaseWithConstantOffset(
Addr)) {
83 dyn_cast<FrameIndexSDNode>(
Addr.getOperand(0)))
84 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
113#include "XtensaGenDAGISel.inc"
122 ID, std::make_unique<XtensaDAGToDAGISel>(TM, OptLevel)) {}
125 return "Xtensa DAG->DAG Pattern Instruction Selection";
130char XtensaDAGToDAGISelLegacy::ID = 0;
134 return new XtensaDAGToDAGISelLegacy(TM, OptLevel);
137void XtensaDAGToDAGISel::Select(
SDNode *
Node) {
139 EVT VT =
Node->getValueType(0);
142 if (
Node->isMachineOpcode()) {
147 switch (
Node->getOpcode()) {
151 auto *
C = dyn_cast<ConstantSDNode>(N1);
154 if (!
C ||
C->isZero()) {
155 SDNode *SSL = CurDAG->getMachineNode(Xtensa::SSL,
DL, MVT::Glue, N1);
157 CurDAG->getMachineNode(Xtensa::SLL,
DL, VT, N0,
SDValue(SSL, 0));
158 ReplaceNode(
Node, SLL);
166 auto *
C = dyn_cast<ConstantSDNode>(N1);
171 if (isUInt<4>(
C->getZExtValue()))
173 unsigned ShAmt =
C->getZExtValue();
175 Xtensa::EXTUI,
DL, VT, N0, CurDAG->getTargetConstant(ShAmt,
DL, VT),
176 CurDAG->getTargetConstant(32 - ShAmt,
DL, VT));
177 ReplaceNode(
Node, EXTUI);
181 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N1);
183 CurDAG->getMachineNode(Xtensa::SRL,
DL, VT, N0,
SDValue(SSR, 0));
184 ReplaceNode(
Node, SRL);
190 auto *
C = dyn_cast<ConstantSDNode>(N1);
194 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N1);
196 CurDAG->getMachineNode(Xtensa::SRA,
DL, VT, N0,
SDValue(SSR, 0));
197 ReplaceNode(
Node, SRA);
206 SDNode *SSL = CurDAG->getMachineNode(Xtensa::SSL,
DL, MVT::Glue, N2);
208 CurDAG->getMachineNode(Xtensa::SRC,
DL, VT, N0, N1,
SDValue(SSL, 0));
209 ReplaceNode(
Node, SRC);
216 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N2);
218 CurDAG->getMachineNode(Xtensa::SRC,
DL, VT, N0, N1,
SDValue(SSR, 0));
219 ReplaceNode(
Node, SRC);
227bool XtensaDAGToDAGISel::SelectInlineAsmMemoryOperand(
229 std::vector<SDValue> &OutOps) {
230 switch (ConstraintID) {
233 case InlineAsm::ConstraintCode::m: {
237 OutOps.push_back(
Base);
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
uint64_t getZExtValue() const
int64_t getSExtValue() const
This class represents an Operation in the Expression.
Diagnostic information for unsupported feature in backend.
FunctionPass class - This class is used to implement most global optimizations.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode,...
virtual bool runOnMachineFunction(MachineFunction &mf)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ SHL
Shift and rotation operations.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createXtensaISelDag(XtensaTargetMachine &TM, CodeGenOptLevel OptLevel)
CodeGenOptLevel
Code generation optimization level.
bool isValidAddrOffset(int Scale, int64_t OffsetVal)