23#include "llvm/IR/IntrinsicsXCore.h"
28#define DEBUG_TYPE "xcore-isel"
29#define PASS_NAME "XCore DAG->DAG Pattern Instruction Selection"
38 XCoreDAGToDAGISel() =
delete;
48 inline SDValue getI32Imm(
unsigned Imm,
const SDLoc &dl) {
49 return CurDAG->getTargetConstant(Imm, dl, MVT::i32);
52 inline bool immMskBitp(
SDNode *inN)
const {
59 return (msksize >= 1 && msksize <= 8) ||
60 msksize == 16 || msksize == 24 || msksize == 32;
68 std::vector<SDValue> &OutOps)
override;
71 #include "XCoreGenDAGISel.inc"
80 ID, std::make_unique<XCoreDAGToDAGISel>(TM, OptLevel)) {}
84char XCoreDAGToDAGISelLegacy::ID = 0;
93 return new XCoreDAGToDAGISelLegacy(TM, OptLevel);
99 if ((FIN = dyn_cast<FrameIndexSDNode>(
Addr))) {
100 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
106 if ((FIN = dyn_cast<FrameIndexSDNode>(
Addr.getOperand(0)))
107 && (CN = dyn_cast<ConstantSDNode>(
Addr.getOperand(1)))
110 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
119bool XCoreDAGToDAGISel::SelectInlineAsmMemoryOperand(
121 std::vector<SDValue> &OutOps) {
123 switch (ConstraintID) {
124 default:
return true;
125 case InlineAsm::ConstraintCode::m:
126 switch (
Op.getOpcode()) {
127 default:
return true;
129 Reg = CurDAG->getRegister(XCore::CP, MVT::i32);
132 Reg = CurDAG->getRegister(XCore::DP, MVT::i32);
136 OutOps.push_back(Reg);
137 OutOps.push_back(
Op.getOperand(0));
141void XCoreDAGToDAGISel::Select(
SDNode *
N) {
143 switch (
N->getOpcode()) {
152 N, CurDAG->getMachineNode(XCore::MKMSK_rus, dl, MVT::i32, MskSize));
155 else if (!isUInt<16>(Val)) {
156 SDValue CPIdx = CurDAG->getTargetConstantPool(
158 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
159 SDNode *node = CurDAG->getMachineNode(XCore::LDWCP_lru6, dl, MVT::i32,
161 CurDAG->getEntryNode());
165 CurDAG->setNodeMemRefs(cast<MachineSDNode>(node), {
MemOp});
166 ReplaceNode(
N, node);
206bool XCoreDAGToDAGISel::tryBRIND(
SDNode *
N) {
213 unsigned IntNo =
Addr->getConstantOperandVal(1);
214 if (IntNo != Intrinsic::xcore_checkevent)
218 if (!CheckEventChainOut.use_empty()) {
234 SDValue constOne = getI32Imm(1, dl);
236 SDValue(CurDAG->getMachineNode(XCore::SETSR_branch_u6, dl, MVT::Glue,
237 constOne, Chain), 0);
239 SDValue(CurDAG->getMachineNode(XCore::CLRSR_branch_u6, dl, MVT::Glue,
243 CurDAG->SelectNodeTo(
N, XCore::BRFU_lu6, MVT::Other,
247 CurDAG->SelectNodeTo(
N, XCore::BAU_1r, MVT::Other, nextAddr, Glue);
AMDGPU Register Bank Select
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Given that RA is a live value
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file describes how to lower LLVM code to machine code.
static SDValue replaceInChain(SelectionDAG *CurDAG, SDValue Chain, SDValue Old, SDValue New)
Given a chain return a new chain where any appearance of Old is replaced by New.
int64_t getSExtValue() const
This class represents an Operation in the Expression.
FunctionPass class - This class is used to implement most global optimizations.
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, std::vector< SDValue > &OutOps)
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode,...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ ADD
Simple integer binary arithmetic operators.
@ BRIND
BRIND - Indirect branch.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isMask_32(uint32_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
CodeGenOptLevel
Code generation optimization level.
FunctionPass * createXCoreISelDag(XCoreTargetMachine &TM, CodeGenOptLevel OptLevel)
createXCoreISelDag - This pass converts a legalized DAG into a XCore-specific DAG,...
This struct is a compact representation of a valid (non-zero power of two) alignment.
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.