36#define DEBUG_TYPE "lanai-isel"
37#define PASS_NAME "Lanai DAG->DAG Pattern Instruction Selection"
53 LanaiDAGToDAGISel() =
delete;
63 std::vector<SDValue> &OutOps)
override;
67#include "LanaiGenDAGISel.inc"
74 void selectFrameIndex(
SDNode *
N);
86 return CurDAG->getTargetConstant(Imm,
DL,
MVT::i32);
101char LanaiDAGToDAGISel::ID = 0;
111 if (canBeRepresentedAsSls(*CN)) {
112 int32_t
Imm = CN->getSExtValue();
113 Offset = CurDAG->getTargetConstant(Imm,
DL, CN->getValueType(0));
133 if (isInt<16>(CN->getSExtValue())) {
134 int16_t
Imm = CN->getSExtValue();
135 Offset = CurDAG->getTargetConstant(Imm,
DL, CN->getValueType(0));
136 Base = CurDAG->getRegister(Lanai::R0, CN->getValueType(0));
142 if (canBeRepresentedAsSls(*CN))
146 if (isInt<10>(CN->getSExtValue())) {
147 int16_t
Imm = CN->getSExtValue();
148 Offset = CurDAG->getTargetConstant(Imm,
DL, CN->getValueType(0));
149 Base = CurDAG->getRegister(Lanai::R0, CN->getValueType(0));
158 Base = CurDAG->getTargetFrameIndex(
160 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
177 if ((RiMode && isInt<16>(CN->getSExtValue())) ||
178 (!RiMode && isInt<10>(CN->getSExtValue()))) {
181 dyn_cast<FrameIndexSDNode>(
Addr.getOperand(0))) {
182 Base = CurDAG->getTargetFrameIndex(
184 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
195 if (AluOperator ==
ISD::OR && RiMode &&
232 if (isInt<16>(CN->getSExtValue()))
245 R1 =
Addr.getOperand(0);
255bool LanaiDAGToDAGISel::SelectInlineAsmMemoryOperand(
256 const SDValue &Op,
unsigned ConstraintCode, std::vector<SDValue> &OutOps) {
258 switch (ConstraintCode) {
262 if (!selectAddrRr(Op, Op0, Op1, AluOp) &&
263 !selectAddrRi(Op, Op0, Op1, AluOp))
268 OutOps.push_back(Op0);
269 OutOps.push_back(Op1);
270 OutOps.push_back(AluOp);
277 unsigned Opcode =
Node->getOpcode();
280 if (
Node->isMachineOpcode()) {
287 EVT VT =
Node->getValueType(0);
294 if (ConstNode->
isZero()) {
295 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
297 return ReplaceNode(
Node,
New.getNode());
302 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
304 return ReplaceNode(
Node,
New.getNode());
309 selectFrameIndex(
Node);
319void LanaiDAGToDAGISel::selectFrameIndex(
SDNode *
Node) {
322 int FI = cast<FrameIndexSDNode>(
Node)->getIndex();
323 EVT VT =
Node->getValueType(0);
324 SDValue TFI = CurDAG->getTargetFrameIndex(FI, VT);
325 unsigned Opc = Lanai::ADD_I_LO;
326 if (
Node->hasOneUse()) {
327 CurDAG->SelectNodeTo(
Node, Opc, VT, TFI, Imm);
330 ReplaceNode(
Node, CurDAG->getMachineNode(Opc,
DL, VT, TFI, Imm));
336 return new LanaiDAGToDAGISel(
TM);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
amdgpu AMDGPU Register Bank Select
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const char LLVMTargetMachineRef TM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
DEMANGLE_DUMP_METHOD void dump() const
int64_t getSExtValue() const
FunctionPass class - This class is used to implement most global optimizations.
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...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode,...
Primary interface to the complete machine description for the target machine.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ ADD
Simple integer binary arithmetic operators.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
static AluCode isdToLanaiAluCode(ISD::NodeType Node_type)
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createLanaiISelDag(LanaiTargetMachine &TM)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.