37 #define DEBUG_TYPE "lanai-isel" 60 return "Lanai DAG->DAG Pattern Instruction Selection";
63 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
unsigned ConstraintCode,
64 std::vector<SDValue> &OutOps)
override;
68 #include "LanaiGenDAGISel.inc" 75 void selectFrameIndex(
SDNode *N);
86 inline SDValue getI32Imm(
unsigned Imm,
const SDLoc &DL) {
87 return CurDAG->getTargetConstant(Imm, DL,
MVT::i32);
108 if (canBeRepresentedAsSls(*CN)) {
109 int32_t Imm = CN->getSExtValue();
110 Offset = CurDAG->getTargetConstant(Imm, DL, CN->getValueType(0));
131 int16_t Imm = CN->getSExtValue();
132 Offset = CurDAG->getTargetConstant(Imm, DL, CN->getValueType(0));
133 Base = CurDAG->getRegister(Lanai::R0, CN->getValueType(0));
139 if (canBeRepresentedAsSls(*CN))
143 if (isInt<10>(CN->getSExtValue())) {
144 int16_t Imm = CN->getSExtValue();
145 Offset = CurDAG->getTargetConstant(Imm, DL, CN->getValueType(0));
146 Base = CurDAG->getRegister(Lanai::R0, CN->getValueType(0));
155 Base = CurDAG->getTargetFrameIndex(
157 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
158 Offset = CurDAG->getTargetConstant(0, DL,
MVT::i32);
174 if ((RiMode &&
isInt<16>(CN->getSExtValue())) ||
175 (!RiMode && isInt<10>(CN->getSExtValue()))) {
178 dyn_cast<FrameIndexSDNode>(Addr.
getOperand(0))) {
179 Base = CurDAG->getTargetFrameIndex(
181 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
186 Offset = CurDAG->getTargetConstant(CN->getSExtValue(), DL,
MVT::i32);
192 if (AluOperator ==
ISD::OR && RiMode &&
197 Offset = CurDAG->getTargetConstant(0, DL,
MVT::i32);
204 return selectAddrRiSpls(Addr, Base, Offset, AluOp,
true);
207 bool LanaiDAGToDAGISel::selectAddrSpls(
SDValue Addr,
SDValue &Base,
209 return selectAddrRiSpls(Addr, Base, Offset, AluOp,
false);
244 AluOp = CurDAG->getTargetConstant(AluCode,
SDLoc(Addr),
MVT::i32);
252 bool LanaiDAGToDAGISel::SelectInlineAsmMemoryOperand(
253 const SDValue &
Op,
unsigned ConstraintCode, std::vector<SDValue> &OutOps) {
255 switch (ConstraintCode) {
259 if (!selectAddrRr(Op, Op0, Op1, AluOp) &&
260 !selectAddrRi(Op, Op0, Op1, AluOp))
265 OutOps.push_back(Op0);
266 OutOps.push_back(Op1);
267 OutOps.push_back(AluOp);
292 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
294 return ReplaceNode(Node, New.
getNode());
299 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
301 return ReplaceNode(Node, New.
getNode());
306 selectFrameIndex(Node);
316 void LanaiDAGToDAGISel::selectFrameIndex(
SDNode *Node) {
319 int FI = cast<FrameIndexSDNode>(Node)->getIndex();
321 SDValue TFI = CurDAG->getTargetFrameIndex(FI, VT);
322 unsigned Opc = Lanai::ADD_I_LO;
324 CurDAG->SelectNodeTo(Node, Opc, VT, TFI, Imm);
327 ReplaceNode(Node, CurDAG->getMachineNode(Opc, DL, VT, TFI, Imm));
333 return new LanaiDAGToDAGISel(TM);
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents lattice values for constants.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
constexpr bool isInt< 16 >(int64_t x)
SDNode * getNode() const
get the SDNode which holds the desired result
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
bool isAllOnesValue() const
bool hasOneUse() const
Return true if there is exactly one use of this node.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
int64_t getSExtValue() const
Simple integer binary arithmetic operators.
FunctionPass class - This class is used to implement most global optimizations.
FunctionPass * createLanaiISelDag(LanaiTargetMachine &TM)
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
void dump() const
Dump this node, for debugging.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
unsigned getOpcode() const
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
const SDValue & getOperand(unsigned i) const
static AluCode isdToLanaiAluCode(ISD::NodeType Node_type)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...