25#define DEBUG_TYPE "xtensa-isel"
43 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
45 std::vector<SDValue> &OutOps)
override;
55 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
56 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr), ValTy);
61 if (TM.isPositionIndependent()) {
63 CurDAG->getMachineFunction().getFunction(),
64 "PIC relocations are not supported", Addr.
getDebugLoc()));
73 if (CurDAG->isBaseWithConstantOffset(Addr)) {
83 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
100 return selectMemRegAddr(Addr,
Base,
Offset, 1);
104 return selectMemRegAddr(Addr,
Base,
Offset, 2);
108 return selectMemRegAddr(Addr,
Base,
Offset, 4);
112#include "XtensaGenDAGISel.inc"
121 ID, std::make_unique<XtensaDAGToDAGISel>(TM, OptLevel)) {}
124 return "Xtensa DAG->DAG Pattern Instruction Selection";
129char XtensaDAGToDAGISelLegacy::ID = 0;
133 return new XtensaDAGToDAGISelLegacy(TM, OptLevel);
136void XtensaDAGToDAGISel::Select(
SDNode *
Node) {
138 EVT VT =
Node->getValueType(0);
141 if (
Node->isMachineOpcode()) {
146 switch (
Node->getOpcode()) {
153 if (!
C ||
C->isZero()) {
154 SDNode *SSL = CurDAG->getMachineNode(Xtensa::SSL,
DL, MVT::Glue, N1);
156 CurDAG->getMachineNode(Xtensa::SLL,
DL, VT, N0,
SDValue(SSL, 0));
157 ReplaceNode(Node, SLL);
172 unsigned ShAmt =
C->getZExtValue();
173 SDNode *
EXTUI = CurDAG->getMachineNode(
174 Xtensa::EXTUI,
DL, VT, N0, CurDAG->getTargetConstant(ShAmt,
DL, VT),
175 CurDAG->getTargetConstant(32 - ShAmt,
DL, VT));
176 ReplaceNode(Node, EXTUI);
180 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N1);
182 CurDAG->getMachineNode(Xtensa::SRL,
DL, VT, N0,
SDValue(SSR, 0));
183 ReplaceNode(Node, SRL);
193 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N1);
195 CurDAG->getMachineNode(Xtensa::SRA,
DL, VT, N0,
SDValue(SSR, 0));
196 ReplaceNode(Node, SRA);
205 SDNode *SSL = CurDAG->getMachineNode(Xtensa::SSL,
DL, MVT::Glue, N2);
207 CurDAG->getMachineNode(Xtensa::SRC,
DL, VT, N0, N1,
SDValue(SSL, 0));
208 ReplaceNode(Node, SRC);
215 SDNode *SSR = CurDAG->getMachineNode(Xtensa::SSR,
DL, MVT::Glue, N2);
217 CurDAG->getMachineNode(Xtensa::SRC,
DL, VT, N0, N1,
SDValue(SSR, 0));
218 ReplaceNode(Node, SRC);
226bool XtensaDAGToDAGISel::SelectInlineAsmMemoryOperand(
228 std::vector<SDValue> &OutOps) {
229 switch (ConstraintID) {
232 case InlineAsm::ConstraintCode::m: {
236 OutOps.push_back(
Base);
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
uint64_t getZExtValue() const
int64_t getSExtValue() const
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.
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.
EVT getValueType() const
Return the ValueType of the referenced return value.
const DebugLoc & getDebugLoc() const
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ SHL
Shift and rotation operations.
bool isValidAddrOffset(int Scale, int64_t OffsetVal)
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createXtensaISelDag(XtensaTargetMachine &TM, CodeGenOptLevel OptLevel)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
CodeGenOptLevel
Code generation optimization level.
DWARFExpression::Operation Op