36#define DEBUG_TYPE "arc-isel"
37#define PASS_NAME "ARC DAG->DAG Pattern Instruction Selection"
45 ARCDAGToDAGISel() =
delete;
59#include "ARCGenDAGISel.inc"
67 ID, std::make_unique<ARCDAGToDAGISel>(TM, OptLevel)) {}
70char ARCDAGToDAGISelLegacy::ID;
80 return new ARCDAGToDAGISelLegacy(TM, OptLevel);
85 if (Addr.
getOpcode() == ARCISD::GAWRAPPER) {
87 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr), MVT::i32);
95 if (Addr.
getOpcode() == ARCISD::GAWRAPPER) {
100 !CurDAG->isBaseWithConstantOffset(Addr)) {
104 Base = CurDAG->getTargetFrameIndex(
105 FI, TLI->getPointerTy(CurDAG->getDataLayout()));
109 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
114 int32_t RHSC =
RHS->getSExtValue();
124 Base = CurDAG->getTargetFrameIndex(
125 FI, TLI->getPointerTy(CurDAG->getDataLayout()));
127 Offset = CurDAG->getTargetConstant(RHSC, SDLoc(Addr), MVT::i32);
131 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
139 if (Addr.
getOpcode() == ARCISD::GAWRAPPER) {
143 int32_t RHSC =
RHS->getSExtValue();
147 Offset = CurDAG->getTargetConstant(RHSC, SDLoc(Addr), MVT::i32);
156 FrameIndexSDNode *FIN =
nullptr;
158 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
159 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
163 ConstantSDNode *CN =
nullptr;
168 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
170 CurDAG->getTargetConstant(CN->
getSExtValue(), SDLoc(Addr), MVT::i32);
177void ARCDAGToDAGISel::Select(SDNode *
N) {
178 switch (
N->getOpcode()) {
180 uint64_t CVal =
N->getAsZExtVal();
181 ReplaceNode(
N, CurDAG->getMachineNode(
182 isInt<12>(CVal) ? ARC::MOV_rs12 : ARC::MOV_rlimm,
184 CurDAG->getTargetConstant(CVal, SDLoc(
N), MVT::i32)));
AMDGPU Register Bank Select
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file describes how to lower LLVM code to machine code.
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.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ ADD
Simple integer binary arithmetic operators.
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FunctionPass * createARCISelDag(ARCTargetMachine &TM, CodeGenOptLevel OptLevel)
This pass converts a legalized DAG into a ARC-specific DAG, ready for instruction scheduling.
CodeGenOptLevel
Code generation optimization level.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.