27 #include "llvm/IR/IntrinsicsXCore.h"
50 return CurDAG->getTargetConstant(
Imm, dl,
MVT::i32);
53 inline bool immMskBitp(
SDNode *inN)
const {
60 return (msksize >= 1 && msksize <= 8) ||
61 msksize == 16 || msksize == 24 || msksize == 32;
67 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
unsigned ConstraintID,
68 std::vector<SDValue> &OutOps)
override;
71 return "XCore DAG->DAG Pattern Instruction Selection";
75 #include "XCoreGenDAGISel.inc"
84 return new XCoreDAGToDAGISel(
TM, OptLevel);
90 if ((FIN = dyn_cast<FrameIndexSDNode>(
Addr))) {
97 if ((FIN = dyn_cast<FrameIndexSDNode>(
Addr.getOperand(0)))
98 && (CN = dyn_cast<ConstantSDNode>(
Addr.getOperand(1)))
110 bool XCoreDAGToDAGISel::
111 SelectInlineAsmMemoryOperand(
const SDValue &
Op,
unsigned ConstraintID,
112 std::vector<SDValue> &OutOps) {
114 switch (ConstraintID) {
115 default:
return true;
117 switch (
Op.getOpcode()) {
118 default:
return true;
127 OutOps.push_back(
Reg);
128 OutOps.push_back(
Op.getOperand(0));
134 switch (
N->getOpcode()) {
137 uint64_t Val = cast<ConstantSDNode>(
N)->getZExtValue();
142 ReplaceNode(
N, CurDAG->getMachineNode(XCore::MKMSK_rus, dl,
147 SDValue CPIdx = CurDAG->getTargetConstantPool(
149 getTargetLowering()->getPointerTy(CurDAG->getDataLayout()));
152 CurDAG->getEntryNode());
156 CurDAG->setNodeMemRefs(cast<MachineSDNode>(
node), {
MemOp});
157 ReplaceNode(
N,
node);
163 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
165 ReplaceNode(
N, CurDAG->getMachineNode(XCore::LADD_l5r, dl,
MVT::i32,
170 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
172 ReplaceNode(
N, CurDAG->getMachineNode(XCore::LSUB_l5r, dl,
MVT::i32,
177 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
178 N->getOperand(2),
N->getOperand(3) };
179 ReplaceNode(
N, CurDAG->getMachineNode(XCore::MACCU_l4r, dl,
MVT::i32,
184 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
185 N->getOperand(2),
N->getOperand(3) };
186 ReplaceNode(
N, CurDAG->getMachineNode(XCore::MACCS_l4r, dl,
MVT::i32,
191 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
192 N->getOperand(2),
N->getOperand(3) };
193 ReplaceNode(
N, CurDAG->getMachineNode(XCore::LMUL_l6r, dl,
MVT::i32,
198 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1),
N->getOperand(2) };
199 ReplaceNode(
N, CurDAG->getMachineNode(XCore::CRC8_l4r, dl,
MVT::i32,
238 bool XCoreDAGToDAGISel::tryBRIND(
SDNode *
N) {
245 unsigned IntNo = cast<ConstantSDNode>(
Addr->getOperand(1))->getZExtValue();
246 if (IntNo != Intrinsic::xcore_checkevent)
250 if (!CheckEventChainOut.use_empty()) {
266 SDValue constOne = getI32Imm(1, dl);
269 constOne, Chain), 0);
275 CurDAG->SelectNodeTo(
N, XCore::BRFU_lu6,
MVT::Other,
279 CurDAG->SelectNodeTo(
N, XCore::BAU_1r,
MVT::Other, nextAddr, Glue);