26#define DEBUG_TYPE "xtensa-isel"
44 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
46 std::vector<SDValue> &OutOps)
override;
56 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
57 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr), ValTy);
64 CurDAG->getMachineFunction().getFunction(),
65 "PIC relocations are not supported", Addr.
getDebugLoc()));
74 if (CurDAG->isBaseWithConstantOffset(Addr)) {
84 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
101 return selectMemRegAddr(Addr,
Base,
Offset, 1);
105 return selectMemRegAddr(Addr,
Base,
Offset, 2);
109 return selectMemRegAddr(Addr,
Base,
Offset, 4);
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()) {
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);
173 unsigned ShAmt =
C->getZExtValue();
174 SDNode *EXTUI = CurDAG->getMachineNode(
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);
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);
202 case XtensaISD::SRCL: {
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);
212 case XtensaISD::SRCR: {
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
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.
bool isPositionIndependent() const
#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