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;
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;
66 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
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);
104 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
105 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr), MVT::i32);
114 Base = CurDAG->getTargetFrameIndex(FIN->
getIndex(), MVT::i32);
123bool XCoreDAGToDAGISel::SelectInlineAsmMemoryOperand(
125 std::vector<SDValue> &OutOps) {
127 switch (ConstraintID) {
128 default:
return true;
130 switch (
Op.getOpcode()) {
131 default:
return true;
132 case XCoreISD::CPRelativeWrapper:
133 Reg = CurDAG->getRegister(XCore::CP, MVT::i32);
135 case XCoreISD::DPRelativeWrapper:
136 Reg = CurDAG->getRegister(XCore::DP, MVT::i32);
140 OutOps.push_back(
Reg);
141 OutOps.push_back(
Op.getOperand(0));
145void XCoreDAGToDAGISel::Select(
SDNode *
N) {
147 switch (
N->getOpcode()) {
156 N, CurDAG->getMachineNode(XCore::MKMSK_rus, dl, MVT::i32, MskSize));
160 SDValue CPIdx = CurDAG->getTargetConstantPool(
162 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
163 SDNode *node = CurDAG->getMachineNode(XCore::LDWCP_lru6, dl, MVT::i32,
165 CurDAG->getEntryNode());
170 ReplaceNode(
N, node);
210bool XCoreDAGToDAGISel::tryBRIND(
SDNode *
N) {
218 if (IntNo != Intrinsic::xcore_checkevent)
222 if (!CheckEventChainOut.use_empty()) {
238 SDValue constOne = getI32Imm(1, dl);
240 SDValue(CurDAG->getMachineNode(XCore::SETSR_branch_u6, dl, MVT::Glue,
241 constOne, Chain), 0);
243 SDValue(CurDAG->getMachineNode(XCore::CLRSR_branch_u6, dl, MVT::Glue,
245 if (nextAddr->
getOpcode() == XCoreISD::PCRelativeWrapper &&
247 CurDAG->SelectNodeTo(
N, XCore::BRFU_lu6, MVT::Other,
251 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...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#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
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
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
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
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
SelectionDAGISelPass(std::unique_ptr< SelectionDAGISel > Selector)
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
XCoreISelDAGToDAGPass(XCoreTargetMachine &TM, CodeGenOptLevel OptLevel)
@ 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...
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
FunctionPass * createXCoreISelDagLegacyPass(XCoreTargetMachine &TM, CodeGenOptLevel OptLevel)
createXCoreISelDagLegacyPass - This pass converts a legalized DAG into a XCore-specific DAG,...
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
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.