27#define AVR_EXPAND_PSEUDO_NAME "AVR pseudo instruction expansion pass"
52 bool expandMBB(Block &
MBB);
53 bool expandMI(Block &
MBB, BlockIt
MBBI);
69 bool expandArith(
unsigned OpLo,
unsigned OpHi, Block &
MBB, BlockIt
MBBI);
70 bool expandLogic(
unsigned Op, Block &
MBB, BlockIt
MBBI);
71 bool expandLogicImm(
unsigned Op, Block &
MBB, BlockIt
MBBI);
72 bool isLogicImmOpRedundant(
unsigned Op,
unsigned ImmVal)
const;
74 template <
typename Func>
bool expandAtomic(Block &
MBB, BlockIt
MBBI, Func f);
76 template <
typename Func>
77 bool expandAtomicBinaryOp(
unsigned Opcode, Block &
MBB, BlockIt
MBBI, Func f);
79 bool expandAtomicBinaryOp(
unsigned Opcode, Block &
MBB, BlockIt
MBBI);
82 bool expandLSLB7Rd(Block &
MBB, BlockIt
MBBI);
83 bool expandLSRB7Rd(Block &
MBB, BlockIt
MBBI);
84 bool expandASRB6Rd(Block &
MBB, BlockIt
MBBI);
85 bool expandASRB7Rd(Block &
MBB, BlockIt
MBBI);
88 bool expandLSLW4Rd(Block &
MBB, BlockIt
MBBI);
89 bool expandLSRW4Rd(Block &
MBB, BlockIt
MBBI);
90 bool expandASRW7Rd(Block &
MBB, BlockIt
MBBI);
91 bool expandLSLW8Rd(Block &
MBB, BlockIt
MBBI);
92 bool expandLSRW8Rd(Block &
MBB, BlockIt
MBBI);
93 bool expandASRW8Rd(Block &
MBB, BlockIt
MBBI);
94 bool expandLSLW12Rd(Block &
MBB, BlockIt
MBBI);
95 bool expandLSRW12Rd(Block &
MBB, BlockIt
MBBI);
96 bool expandASRW14Rd(Block &
MBB, BlockIt
MBBI);
97 bool expandASRW15Rd(Block &
MBB, BlockIt
MBBI);
100 bool expandLPMWELPMW(Block &
MBB, BlockIt
MBBI,
bool IsExt);
103char AVRExpandPseudo::ID = 0;
110 BlockIt NMBBI = std::next(
MBBI);
125 for (Block &
MBB : MF) {
126 bool ContinueExpanding =
true;
127 unsigned ExpandCount = 0;
131 assert(ExpandCount < 10 &&
"pseudo expand limit reached");
134 bool BlockModified = expandMBB(
MBB);
138 ContinueExpanding = BlockModified;
139 }
while (ContinueExpanding);
145bool AVRExpandPseudo::expandArith(
unsigned OpLo,
unsigned OpHi, Block &
MBB,
148 Register SrcLoReg, SrcHiReg, DstLoReg, DstHiReg;
151 bool DstIsDead =
MI.getOperand(0).isDead();
152 bool DstIsKill =
MI.getOperand(1).isKill();
153 bool SrcIsKill =
MI.getOperand(2).isKill();
154 bool ImpIsDead =
MI.getOperand(3).isDead();
155 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
156 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
170 MIBHI->getOperand(3).setIsDead();
173 MIBHI->getOperand(4).setIsKill();
175 MI.eraseFromParent();
179bool AVRExpandPseudo::expandLogic(
unsigned Op, Block &
MBB, BlockIt
MBBI) {
181 Register SrcLoReg, SrcHiReg, DstLoReg, DstHiReg;
184 bool DstIsDead =
MI.getOperand(0).isDead();
185 bool DstIsKill =
MI.getOperand(1).isKill();
186 bool SrcIsKill =
MI.getOperand(2).isKill();
187 bool ImpIsDead =
MI.getOperand(3).isDead();
188 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
189 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
198 MIBLO->getOperand(3).setIsDead();
207 MIBHI->getOperand(3).setIsDead();
209 MI.eraseFromParent();
213bool AVRExpandPseudo::isLogicImmOpRedundant(
unsigned Op,
214 unsigned ImmVal)
const {
217 if (Op == AVR::ANDIRdK && ImmVal == 0xff)
221 if (Op == AVR::ORIRdK && ImmVal == 0x0)
227bool AVRExpandPseudo::expandLogicImm(
unsigned Op, Block &
MBB, BlockIt
MBBI) {
231 bool DstIsDead =
MI.getOperand(0).isDead();
232 bool SrcIsKill =
MI.getOperand(1).isKill();
233 bool ImpIsDead =
MI.getOperand(3).isDead();
234 unsigned Imm =
MI.getOperand(2).getImm();
235 unsigned Lo8 = Imm & 0xff;
236 unsigned Hi8 = (Imm >> 8) & 0xff;
237 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
239 if (!isLogicImmOpRedundant(Op, Lo8)) {
247 MIBLO->getOperand(3).setIsDead();
250 if (!isLogicImmOpRedundant(Op, Hi8)) {
258 MIBHI->getOperand(3).setIsDead();
261 MI.eraseFromParent();
266bool AVRExpandPseudo::expand<AVR::ADDWRdRr>(Block &
MBB, BlockIt
MBBI) {
267 return expandArith(AVR::ADDRdRr, AVR::ADCRdRr,
MBB,
MBBI);
271bool AVRExpandPseudo::expand<AVR::ADCWRdRr>(Block &
MBB, BlockIt
MBBI) {
272 return expandArith(AVR::ADCRdRr, AVR::ADCRdRr,
MBB,
MBBI);
276bool AVRExpandPseudo::expand<AVR::SUBWRdRr>(Block &
MBB, BlockIt
MBBI) {
277 return expandArith(AVR::SUBRdRr, AVR::SBCRdRr,
MBB,
MBBI);
281bool AVRExpandPseudo::expand<AVR::SUBIWRdK>(Block &
MBB, BlockIt
MBBI) {
285 bool DstIsDead =
MI.getOperand(0).isDead();
286 bool SrcIsKill =
MI.getOperand(1).isKill();
287 bool ImpIsDead =
MI.getOperand(3).isDead();
288 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
291 buildMI(
MBB,
MBBI, AVR::SUBIRdK)
296 buildMI(
MBB,
MBBI, AVR::SBCIRdK)
300 switch (
MI.getOperand(2).getType()) {
303 int64_t Offs =
MI.getOperand(2).getOffset();
304 unsigned TF =
MI.getOperand(2).getTargetFlags();
310 unsigned Imm =
MI.getOperand(2).getImm();
311 MIBLO.addImm(Imm & 0xff);
312 MIBHI.addImm((Imm >> 8) & 0xff);
320 MIBHI->getOperand(3).setIsDead();
323 MIBHI->getOperand(4).setIsKill();
325 MI.eraseFromParent();
330bool AVRExpandPseudo::expand<AVR::SBCWRdRr>(Block &
MBB, BlockIt
MBBI) {
331 return expandArith(AVR::SBCRdRr, AVR::SBCRdRr,
MBB,
MBBI);
335bool AVRExpandPseudo::expand<AVR::SBCIWRdK>(Block &
MBB, BlockIt
MBBI) {
339 bool DstIsDead =
MI.getOperand(0).isDead();
340 bool SrcIsKill =
MI.getOperand(1).isKill();
341 bool ImpIsDead =
MI.getOperand(3).isDead();
342 unsigned Imm =
MI.getOperand(2).getImm();
343 unsigned Lo8 = Imm & 0xff;
344 unsigned Hi8 = (Imm >> 8) & 0xff;
345 unsigned OpLo = AVR::SBCIRdK;
346 unsigned OpHi = AVR::SBCIRdK;
347 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
356 MIBLO->getOperand(4).setIsKill();
365 MIBHI->getOperand(3).setIsDead();
368 MIBHI->getOperand(4).setIsKill();
370 MI.eraseFromParent();
375bool AVRExpandPseudo::expand<AVR::ANDWRdRr>(Block &
MBB, BlockIt
MBBI) {
376 return expandLogic(AVR::ANDRdRr,
MBB,
MBBI);
380bool AVRExpandPseudo::expand<AVR::ANDIWRdK>(Block &
MBB, BlockIt
MBBI) {
381 return expandLogicImm(AVR::ANDIRdK,
MBB,
MBBI);
385bool AVRExpandPseudo::expand<AVR::ORWRdRr>(Block &
MBB, BlockIt
MBBI) {
386 return expandLogic(AVR::ORRdRr,
MBB,
MBBI);
390bool AVRExpandPseudo::expand<AVR::ORIWRdK>(Block &
MBB, BlockIt
MBBI) {
391 return expandLogicImm(AVR::ORIRdK,
MBB,
MBBI);
395bool AVRExpandPseudo::expand<AVR::EORWRdRr>(Block &
MBB, BlockIt
MBBI) {
396 return expandLogic(AVR::EORRdRr,
MBB,
MBBI);
400bool AVRExpandPseudo::expand<AVR::COMWRd>(Block &
MBB, BlockIt
MBBI) {
404 bool DstIsDead =
MI.getOperand(0).isDead();
405 bool DstIsKill =
MI.getOperand(1).isKill();
406 bool ImpIsDead =
MI.getOperand(2).isDead();
407 unsigned OpLo = AVR::COMRd;
408 unsigned OpHi = AVR::COMRd;
409 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
417 MIBLO->getOperand(2).setIsDead();
425 MIBHI->getOperand(2).setIsDead();
427 MI.eraseFromParent();
432bool AVRExpandPseudo::expand<AVR::NEGWRd>(Block &
MBB, BlockIt
MBBI) {
437 bool DstIsDead =
MI.getOperand(0).isDead();
438 bool DstIsKill =
MI.getOperand(1).isKill();
439 bool ImpIsDead =
MI.getOperand(2).isDead();
440 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
448 MIBHI->getOperand(2).setIsDead();
457 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
462 MISBCI->getOperand(3).setIsDead();
464 MISBCI->getOperand(4).setIsKill();
466 MI.eraseFromParent();
471bool AVRExpandPseudo::expand<AVR::CPWRdRr>(Block &
MBB, BlockIt
MBBI) {
473 Register SrcLoReg, SrcHiReg, DstLoReg, DstHiReg;
476 bool DstIsKill =
MI.getOperand(0).isKill();
477 bool SrcIsKill =
MI.getOperand(1).isKill();
478 bool ImpIsDead =
MI.getOperand(2).isDead();
479 unsigned OpLo = AVR::CPRdRr;
480 unsigned OpHi = AVR::CPCRdRr;
481 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
482 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
489 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
494 MIBHI->getOperand(2).setIsDead();
497 MIBHI->getOperand(3).setIsKill();
499 MI.eraseFromParent();
504bool AVRExpandPseudo::expand<AVR::CPCWRdRr>(Block &
MBB, BlockIt
MBBI) {
506 Register SrcLoReg, SrcHiReg, DstLoReg, DstHiReg;
509 bool DstIsKill =
MI.getOperand(0).isKill();
510 bool SrcIsKill =
MI.getOperand(1).isKill();
511 bool ImpIsDead =
MI.getOperand(2).isDead();
512 unsigned OpLo = AVR::CPCRdRr;
513 unsigned OpHi = AVR::CPCRdRr;
514 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
515 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
517 auto MIBLO = buildMI(
MBB,
MBBI, OpLo)
522 MIBLO->getOperand(3).setIsKill();
524 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
529 MIBHI->getOperand(2).setIsDead();
532 MIBHI->getOperand(3).setIsKill();
534 MI.eraseFromParent();
539bool AVRExpandPseudo::expand<AVR::LDIWRdK>(Block &
MBB, BlockIt
MBBI) {
543 bool DstIsDead =
MI.getOperand(0).isDead();
544 unsigned OpLo = AVR::LDIRdK;
545 unsigned OpHi = AVR::LDIRdK;
546 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
556 switch (
MI.getOperand(1).getType()) {
559 int64_t Offs =
MI.getOperand(1).getOffset();
560 unsigned TF =
MI.getOperand(1).getTargetFlags();
568 unsigned TF =
MI.getOperand(1).getTargetFlags();
575 unsigned Imm =
MI.getOperand(1).getImm();
577 MIBLO.addImm(Imm & 0xff);
578 MIBHI.addImm((Imm >> 8) & 0xff);
585 MI.eraseFromParent();
590bool AVRExpandPseudo::expand<AVR::LDSWRdK>(Block &
MBB, BlockIt
MBBI) {
594 bool DstIsDead =
MI.getOperand(0).isDead();
595 unsigned OpLo = AVR::LDSRdK;
596 unsigned OpHi = AVR::LDSRdK;
597 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
607 switch (
MI.getOperand(1).getType()) {
610 int64_t Offs =
MI.getOperand(1).getOffset();
611 unsigned TF =
MI.getOperand(1).getTargetFlags();
613 MIBLO.addGlobalAddress(GV, Offs, TF);
614 MIBHI.addGlobalAddress(GV, Offs + 1, TF);
618 unsigned Imm =
MI.getOperand(1).getImm();
621 MIBHI.addImm(Imm + 1);
628 MIBLO.setMemRefs(
MI.memoperands());
629 MIBHI.setMemRefs(
MI.memoperands());
631 MI.eraseFromParent();
636bool AVRExpandPseudo::expand<AVR::LDWRdPtr>(Block &
MBB, BlockIt
MBBI) {
640 bool DstIsKill =
MI.getOperand(0).isKill();
641 bool SrcIsKill =
MI.getOperand(1).isKill();
646 assert(DstReg != SrcReg &&
"Dst and Src registers are the same!");
651 buildMI(
MBB,
MBBI, AVR::LDDWRdPtrQ)
655 .setMemRefs(
MI.memoperands());
659 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
662 buildMI(
MBB,
MBBI, AVR::LDRdPtr)
665 .setMemRefs(
MI.memoperands());
668 buildMI(
MBB,
MBBI, AVR::LDDRdPtrQ)
672 .setMemRefs(
MI.memoperands());
675 MI.eraseFromParent();
680bool AVRExpandPseudo::expand<AVR::LDWRdPtrPi>(Block &
MBB, BlockIt
MBBI) {
685 bool DstIsDead =
MI.getOperand(0).isDead();
686 bool SrcIsDead =
MI.getOperand(1).isKill();
687 unsigned OpLo = AVR::LDRdPtrPi;
688 unsigned OpHi = AVR::LDRdPtrPi;
689 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
691 assert(DstReg != SrcReg &&
"SrcReg and DstReg cannot be the same");
705 MIBLO.setMemRefs(
MI.memoperands());
706 MIBHI.setMemRefs(
MI.memoperands());
708 MI.eraseFromParent();
713bool AVRExpandPseudo::expand<AVR::LDWRdPtrPd>(Block &
MBB, BlockIt
MBBI) {
718 bool DstIsDead =
MI.getOperand(0).isDead();
719 bool SrcIsDead =
MI.getOperand(1).isKill();
720 unsigned OpLo = AVR::LDRdPtrPd;
721 unsigned OpHi = AVR::LDRdPtrPd;
722 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
724 assert(DstReg != SrcReg &&
"SrcReg and DstReg cannot be the same");
738 MIBLO.setMemRefs(
MI.memoperands());
739 MIBHI.setMemRefs(
MI.memoperands());
741 MI.eraseFromParent();
746bool AVRExpandPseudo::expand<AVR::LDDWRdPtrQ>(Block &
MBB, BlockIt
MBBI) {
750 unsigned Imm =
MI.getOperand(2).getImm();
751 bool DstIsKill =
MI.getOperand(0).isKill();
752 bool SrcIsKill =
MI.getOperand(1).isKill();
757 assert(Imm <= 62 &&
"Offset is out of range");
761 assert(DstReg != SrcReg &&
"Dst and Src registers are the same!");
771 buildMI(
MBB,
MBBI, AVR::SUBIWRdK, SrcReg)
773 .addImm(0x10000 - Imm);
778 buildMI(
MBB,
MBBI, AVR::LDWRdPtrPi)
782 .setMemRefs(
MI.memoperands());
788 buildMI(
MBB,
MBBI, AVR::SUBIWRdK, SrcReg).addReg(SrcReg).addImm(Imm + 2);
792 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
795 buildMI(
MBB,
MBBI, AVR::LDDRdPtrQ)
799 .setMemRefs(
MI.memoperands());
802 buildMI(
MBB,
MBBI, AVR::LDDRdPtrQ)
806 .setMemRefs(
MI.memoperands());
809 MI.eraseFromParent();
813bool AVRExpandPseudo::expandLPMWELPMW(Block &
MBB, BlockIt
MBBI,
bool IsExt) {
818 bool SrcIsKill =
MI.getOperand(1).isKill();
819 unsigned OpLo = IsExt ? AVR::ELPMRdZPi : AVR::LPMRdZPi;
820 unsigned OpHi = IsExt ? AVR::ELPMRdZ : AVR::LPMRdZ;
821 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
832 assert(DstReg != SrcReg &&
"SrcReg and DstReg cannot be the same");
835 auto MIBLO = buildMI(
MBB,
MBBI, OpLo)
840 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
844 MIBLO.setMemRefs(
MI.memoperands());
845 MIBHI.setMemRefs(
MI.memoperands());
847 MI.eraseFromParent();
852bool AVRExpandPseudo::expand<AVR::LPMWRdZ>(Block &
MBB, BlockIt
MBBI) {
853 return expandLPMWELPMW(
MBB,
MBBI,
false);
857bool AVRExpandPseudo::expand<AVR::ELPMWRdZ>(Block &
MBB, BlockIt
MBBI) {
858 return expandLPMWELPMW(
MBB,
MBBI,
true);
862bool AVRExpandPseudo::expand<AVR::ELPMBRdZ>(Block &
MBB, BlockIt
MBBI) {
867 bool SrcIsKill =
MI.getOperand(1).isKill();
875 auto MILB = buildMI(
MBB,
MBBI, AVR::ELPMRdZ)
878 MILB.setMemRefs(
MI.memoperands());
882 auto MILB = buildMI(
MBB,
MBBI, AVR::ELPM);
883 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
886 MILB.setMemRefs(
MI.memoperands());
889 MI.eraseFromParent();
894bool AVRExpandPseudo::expand<AVR::LPMWRdZPi>(Block &
MBB, BlockIt
MBBI) {
899bool AVRExpandPseudo::expand<AVR::ELPMBRdZPi>(Block &
MBB, BlockIt
MBBI) {
904bool AVRExpandPseudo::expand<AVR::ELPMWRdZPi>(Block &
MBB, BlockIt
MBBI) {
908template <
typename Func>
909bool AVRExpandPseudo::expandAtomic(Block &
MBB, BlockIt
MBBI, Func f) {
919 buildMI(
MBB,
MBBI, AVR::BCLRs).addImm(7);
924 buildMI(
MBB,
MBBI, AVR::OUTARr)
928 MI.eraseFromParent();
932template <
typename Func>
933bool AVRExpandPseudo::expandAtomicBinaryOp(
unsigned Opcode, Block &
MBB,
934 BlockIt
MBBI, Func f) {
936 auto Op1 =
MI.getOperand(0);
937 auto Op2 =
MI.getOperand(1);
940 *buildMI(
MBB,
MBBI, Opcode).add(Op1).add(Op2).getInstr();
945bool AVRExpandPseudo::expandAtomicBinaryOp(
unsigned Opcode, Block &
MBB,
951bool AVRExpandPseudo::expand<AVR::AtomicLoad8>(Block &
MBB, BlockIt
MBBI) {
952 return expandAtomicBinaryOp(AVR::LDRdPtr,
MBB,
MBBI);
956bool AVRExpandPseudo::expand<AVR::AtomicLoad16>(Block &
MBB, BlockIt
MBBI) {
957 return expandAtomicBinaryOp(AVR::LDWRdPtr,
MBB,
MBBI);
961bool AVRExpandPseudo::expand<AVR::AtomicStore8>(Block &
MBB, BlockIt
MBBI) {
962 return expandAtomicBinaryOp(AVR::STPtrRr,
MBB,
MBBI);
966bool AVRExpandPseudo::expand<AVR::AtomicStore16>(Block &
MBB, BlockIt
MBBI) {
967 return expandAtomicBinaryOp(AVR::STWPtrRr,
MBB,
MBBI);
971bool AVRExpandPseudo::expand<AVR::AtomicFence>(Block &
MBB, BlockIt
MBBI) {
978bool AVRExpandPseudo::expand<AVR::STSWKRr>(Block &
MBB, BlockIt
MBBI) {
982 bool SrcIsKill =
MI.getOperand(1).isKill();
983 unsigned OpLo = AVR::STSKRr;
984 unsigned OpHi = AVR::STSKRr;
985 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
989 auto MIBHI = buildMI(
MBB,
MBBI, OpHi);
990 auto MIBLO = buildMI(
MBB,
MBBI, OpLo);
992 switch (
MI.getOperand(0).getType()) {
995 int64_t Offs =
MI.getOperand(0).getOffset();
996 unsigned TF =
MI.getOperand(0).getTargetFlags();
998 MIBLO.addGlobalAddress(GV, Offs, TF);
999 MIBHI.addGlobalAddress(GV, Offs + 1, TF);
1003 unsigned Imm =
MI.getOperand(0).getImm();
1006 MIBHI.addImm(Imm + 1);
1016 MIBLO.setMemRefs(
MI.memoperands());
1017 MIBHI.setMemRefs(
MI.memoperands());
1019 MI.eraseFromParent();
1024bool AVRExpandPseudo::expand<AVR::STWPtrRr>(Block &
MBB, BlockIt
MBBI) {
1028 bool DstIsKill =
MI.getOperand(0).isKill();
1029 bool DstIsUndef =
MI.getOperand(0).isUndef();
1030 bool SrcIsKill =
MI.getOperand(1).isKill();
1038 buildMI(
MBB,
MBBI, AVR::STDWPtrQRr)
1043 .setMemRefs(
MI.memoperands());
1047 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1048 buildMI(
MBB,
MBBI, AVR::STPtrRr)
1051 .setMemRefs(
MI.memoperands());
1053 buildMI(
MBB,
MBBI, AVR::STDPtrQRr)
1057 .setMemRefs(
MI.memoperands());
1060 MI.eraseFromParent();
1065bool AVRExpandPseudo::expand<AVR::STWPtrPiRr>(Block &
MBB, BlockIt
MBBI) {
1070 unsigned Imm =
MI.getOperand(3).getImm();
1071 bool DstIsDead =
MI.getOperand(0).isDead();
1072 bool SrcIsKill =
MI.getOperand(2).isKill();
1073 unsigned OpLo = AVR::STPtrPiRr;
1074 unsigned OpHi = AVR::STPtrPiRr;
1075 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1077 assert(DstReg != SrcReg &&
"SrcReg and DstReg cannot be the same");
1079 auto MIBLO = buildMI(
MBB,
MBBI, OpLo)
1092 MIBLO.setMemRefs(
MI.memoperands());
1093 MIBHI.setMemRefs(
MI.memoperands());
1095 MI.eraseFromParent();
1100bool AVRExpandPseudo::expand<AVR::STWPtrPdRr>(Block &
MBB, BlockIt
MBBI) {
1105 unsigned Imm =
MI.getOperand(3).getImm();
1106 bool DstIsDead =
MI.getOperand(0).isDead();
1107 bool SrcIsKill =
MI.getOperand(2).isKill();
1108 unsigned OpLo = AVR::STPtrPdRr;
1109 unsigned OpHi = AVR::STPtrPdRr;
1110 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1112 assert(DstReg != SrcReg &&
"SrcReg and DstReg cannot be the same");
1114 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
1127 MIBLO.setMemRefs(
MI.memoperands());
1128 MIBHI.setMemRefs(
MI.memoperands());
1130 MI.eraseFromParent();
1135bool AVRExpandPseudo::expand<AVR::STDWPtrQRr>(Block &
MBB, BlockIt
MBBI) {
1140 bool DstIsKill =
MI.getOperand(0).isKill();
1141 unsigned Imm =
MI.getOperand(1).getImm();
1143 bool SrcIsKill =
MI.getOperand(2).isKill();
1153 buildMI(
MBB,
MBBI, AVR::SUBIWRdK, DstReg)
1155 .addImm(0x10000 - Imm);
1159 buildMI(
MBB,
MBBI, AVR::STWPtrPiRr, DstReg)
1163 .setMemRefs(
MI.memoperands());
1169 buildMI(
MBB,
MBBI, AVR::SUBIWRdK, DstReg)
1174 unsigned OpLo = AVR::STDPtrQRr;
1175 unsigned OpHi = AVR::STDPtrQRr;
1177 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1179 auto MIBLO = buildMI(
MBB,
MBBI, OpLo)
1184 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
1189 MIBLO.setMemRefs(
MI.memoperands());
1190 MIBHI.setMemRefs(
MI.memoperands());
1193 MI.eraseFromParent();
1198bool AVRExpandPseudo::expand<AVR::STDSPQRr>(Block &
MBB, BlockIt
MBBI) {
1203 assert(
MI.getOperand(0).getReg() == AVR::SP &&
1204 "SP is expected as base pointer");
1207 "unexpected STDSPQRr pseudo instruction");
1210 MI.setDesc(
TII->get(AVR::STDPtrQRr));
1211 MI.getOperand(0).setReg(AVR::R29R28);
1217bool AVRExpandPseudo::expand<AVR::STDWSPQRr>(Block &
MBB, BlockIt
MBBI) {
1222 assert(
MI.getOperand(0).getReg() == AVR::SP &&
1223 "SP is expected as base pointer");
1226 "unexpected STDWSPQRr pseudo instruction");
1229 MI.setDesc(
TII->get(AVR::STDWPtrQRr));
1230 MI.getOperand(0).setReg(AVR::R29R28);
1236bool AVRExpandPseudo::expand<AVR::INWRdA>(Block &
MBB, BlockIt
MBBI) {
1239 unsigned Imm =
MI.getOperand(1).getImm();
1241 bool DstIsDead =
MI.getOperand(0).isDead();
1242 unsigned OpLo = AVR::INRdA;
1243 unsigned OpHi = AVR::INRdA;
1244 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1248 assert(Imm <= 62 &&
"Address is out of range");
1260 MIBLO.setMemRefs(
MI.memoperands());
1261 MIBHI.setMemRefs(
MI.memoperands());
1263 MI.eraseFromParent();
1268bool AVRExpandPseudo::expand<AVR::OUTWARr>(Block &
MBB, BlockIt
MBBI) {
1271 unsigned Imm =
MI.getOperand(0).getImm();
1273 bool SrcIsKill =
MI.getOperand(1).isKill();
1274 unsigned OpLo = AVR::OUTARr;
1275 unsigned OpHi = AVR::OUTARr;
1276 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1280 assert(Imm <= 62 &&
"Address is out of range");
1283 auto MIBHI = buildMI(
MBB,
MBBI, OpHi)
1287 auto MIBLO = buildMI(
MBB,
MBBI, OpLo)
1291 MIBLO.setMemRefs(
MI.memoperands());
1292 MIBHI.setMemRefs(
MI.memoperands());
1294 MI.eraseFromParent();
1299bool AVRExpandPseudo::expand<AVR::PUSHWRr>(Block &
MBB, BlockIt
MBBI) {
1303 bool SrcIsKill =
MI.getOperand(0).isKill();
1304 unsigned Flags =
MI.getFlags();
1305 unsigned OpLo = AVR::PUSHRr;
1306 unsigned OpHi = AVR::PUSHRr;
1307 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
1319 MI.eraseFromParent();
1324bool AVRExpandPseudo::expand<AVR::POPWRd>(Block &
MBB, BlockIt
MBBI) {
1328 unsigned Flags =
MI.getFlags();
1329 unsigned OpLo = AVR::POPRd;
1330 unsigned OpHi = AVR::POPRd;
1331 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1336 MI.eraseFromParent();
1341bool AVRExpandPseudo::expand<AVR::ROLBRd>(Block &
MBB, BlockIt
MBBI) {
1349 unsigned OpShift, OpCarry;
1351 Register ZeroReg =
MI.getOperand(2).getReg();
1352 bool DstIsDead =
MI.getOperand(0).isDead();
1353 bool DstIsKill =
MI.getOperand(1).isKill();
1354 OpShift = AVR::ADDRdRr;
1355 OpCarry = AVR::ADCRdRr;
1367 auto MIB = buildMI(
MBB,
MBBI, OpCarry)
1372 MIB->getOperand(3).setIsDead();
1373 MIB->getOperand(4).setIsKill();
1375 MI.eraseFromParent();
1380bool AVRExpandPseudo::expand<AVR::RORBRd>(Block &
MBB, BlockIt
MBBI) {
1395 buildMI(
MBB,
MBBI, AVR::BST).addReg(DstReg).addImm(0);
1398 buildMI(
MBB,
MBBI, AVR::RORRd, DstReg).addReg(DstReg);
1401 buildMI(
MBB,
MBBI, AVR::BLD, DstReg).addReg(DstReg).addImm(7);
1403 MI.eraseFromParent();
1408bool AVRExpandPseudo::expand<AVR::LSLWRd>(Block &
MBB, BlockIt
MBBI) {
1412 bool DstIsDead =
MI.getOperand(0).isDead();
1413 bool DstIsKill =
MI.getOperand(1).isKill();
1414 bool ImpIsDead =
MI.getOperand(2).isDead();
1415 unsigned OpLo = AVR::ADDRdRr;
1416 unsigned OpHi = AVR::ADCRdRr;
1417 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1432 MIBHI->getOperand(3).setIsDead();
1435 MIBHI->getOperand(4).setIsKill();
1437 MI.eraseFromParent();
1442bool AVRExpandPseudo::expand<AVR::LSLWHiRd>(Block &
MBB, BlockIt
MBBI) {
1446 bool DstIsDead =
MI.getOperand(0).isDead();
1447 bool DstIsKill =
MI.getOperand(1).isKill();
1448 bool ImpIsDead =
MI.getOperand(2).isDead();
1449 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1453 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
1459 MILSL->getOperand(3).setIsDead();
1461 MI.eraseFromParent();
1465bool AVRExpandPseudo::expandLSLW4Rd(Block &
MBB, BlockIt
MBBI) {
1469 bool DstIsDead =
MI.getOperand(0).isDead();
1470 bool DstIsKill =
MI.getOperand(1).isKill();
1471 bool ImpIsDead =
MI.getOperand(3).isDead();
1472 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1476 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1479 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1485 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1490 MI0->getOperand(3).setIsDead();
1494 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1499 MI1->getOperand(3).setIsDead();
1503 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1508 MI2->getOperand(3).setIsDead();
1512 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1517 MI3->getOperand(3).setIsDead();
1519 MI.eraseFromParent();
1523bool AVRExpandPseudo::expandLSLW8Rd(Block &
MBB, BlockIt
MBBI) {
1527 bool DstIsDead =
MI.getOperand(0).isDead();
1528 bool DstIsKill =
MI.getOperand(1).isKill();
1529 bool ImpIsDead =
MI.getOperand(3).isDead();
1530 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1533 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1539 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1544 MIBLO->getOperand(3).setIsDead();
1546 MI.eraseFromParent();
1550bool AVRExpandPseudo::expandLSLW12Rd(Block &
MBB, BlockIt
MBBI) {
1554 bool DstIsDead =
MI.getOperand(0).isDead();
1555 bool DstIsKill =
MI.getOperand(1).isKill();
1556 bool ImpIsDead =
MI.getOperand(3).isDead();
1557 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1560 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1565 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1571 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1576 MI0->getOperand(3).setIsDead();
1580 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1585 MI1->getOperand(3).setIsDead();
1587 MI.eraseFromParent();
1592bool AVRExpandPseudo::expand<AVR::LSLWNRd>(Block &
MBB, BlockIt
MBBI) {
1594 unsigned Imm =
MI.getOperand(2).getImm();
1597 return expandLSLW4Rd(
MBB,
MBBI);
1599 return expandLSLW8Rd(
MBB,
MBBI);
1601 return expandLSLW12Rd(
MBB,
MBBI);
1609bool AVRExpandPseudo::expand<AVR::LSRWRd>(Block &
MBB, BlockIt
MBBI) {
1613 bool DstIsDead =
MI.getOperand(0).isDead();
1614 bool DstIsKill =
MI.getOperand(1).isKill();
1615 bool ImpIsDead =
MI.getOperand(2).isDead();
1616 unsigned OpLo = AVR::RORRd;
1617 unsigned OpHi = AVR::LSRRd;
1618 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1631 MIBLO->getOperand(2).setIsDead();
1634 MIBLO->getOperand(3).setIsKill();
1636 MI.eraseFromParent();
1641bool AVRExpandPseudo::expand<AVR::LSRWLoRd>(Block &
MBB, BlockIt
MBBI) {
1645 bool DstIsDead =
MI.getOperand(0).isDead();
1646 bool DstIsKill =
MI.getOperand(1).isKill();
1647 bool ImpIsDead =
MI.getOperand(2).isDead();
1648 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1652 buildMI(
MBB,
MBBI, AVR::LSRRd)
1657 MILSR->getOperand(2).setIsDead();
1659 MI.eraseFromParent();
1663bool AVRExpandPseudo::expandLSRW4Rd(Block &
MBB, BlockIt
MBBI) {
1667 bool DstIsDead =
MI.getOperand(0).isDead();
1668 bool DstIsKill =
MI.getOperand(1).isKill();
1669 bool ImpIsDead =
MI.getOperand(3).isDead();
1670 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1674 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1677 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1683 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1688 MI0->getOperand(3).setIsDead();
1692 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1697 MI1->getOperand(3).setIsDead();
1701 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1706 MI2->getOperand(3).setIsDead();
1710 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1715 MI3->getOperand(3).setIsDead();
1717 MI.eraseFromParent();
1721bool AVRExpandPseudo::expandLSRW8Rd(Block &
MBB, BlockIt
MBBI) {
1725 bool DstIsDead =
MI.getOperand(0).isDead();
1726 bool DstIsKill =
MI.getOperand(1).isKill();
1727 bool ImpIsDead =
MI.getOperand(3).isDead();
1728 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1731 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1737 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1742 MIBHI->getOperand(3).setIsDead();
1744 MI.eraseFromParent();
1748bool AVRExpandPseudo::expandLSRW12Rd(Block &
MBB, BlockIt
MBBI) {
1752 bool DstIsDead =
MI.getOperand(0).isDead();
1753 bool DstIsKill =
MI.getOperand(1).isKill();
1754 bool ImpIsDead =
MI.getOperand(3).isDead();
1755 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1758 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1763 buildMI(
MBB,
MBBI, AVR::SWAPRd)
1769 buildMI(
MBB,
MBBI, AVR::ANDIRdK)
1774 MI0->getOperand(3).setIsDead();
1778 buildMI(
MBB,
MBBI, AVR::EORRdRr)
1783 MIBHI->getOperand(3).setIsDead();
1785 MI.eraseFromParent();
1790bool AVRExpandPseudo::expand<AVR::LSRWNRd>(Block &
MBB, BlockIt
MBBI) {
1792 unsigned Imm =
MI.getOperand(2).getImm();
1795 return expandLSRW4Rd(
MBB,
MBBI);
1797 return expandLSRW8Rd(
MBB,
MBBI);
1799 return expandLSRW12Rd(
MBB,
MBBI);
1807bool AVRExpandPseudo::expand<AVR::RORWRd>(Block &
MBB, BlockIt
MBBI) {
1813bool AVRExpandPseudo::expand<AVR::ROLWRd>(Block &
MBB, BlockIt
MBBI) {
1819bool AVRExpandPseudo::expand<AVR::ASRWRd>(Block &
MBB, BlockIt
MBBI) {
1823 bool DstIsDead =
MI.getOperand(0).isDead();
1824 bool DstIsKill =
MI.getOperand(1).isKill();
1825 bool ImpIsDead =
MI.getOperand(2).isDead();
1826 unsigned OpLo = AVR::RORRd;
1827 unsigned OpHi = AVR::ASRRd;
1828 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1841 MIBLO->getOperand(2).setIsDead();
1844 MIBLO->getOperand(3).setIsKill();
1846 MI.eraseFromParent();
1851bool AVRExpandPseudo::expand<AVR::ASRWLoRd>(Block &
MBB, BlockIt
MBBI) {
1855 bool DstIsDead =
MI.getOperand(0).isDead();
1856 bool DstIsKill =
MI.getOperand(1).isKill();
1857 bool ImpIsDead =
MI.getOperand(2).isDead();
1858 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1862 buildMI(
MBB,
MBBI, AVR::ASRRd)
1867 MIASR->getOperand(2).setIsDead();
1869 MI.eraseFromParent();
1873bool AVRExpandPseudo::expandASRW7Rd(Block &
MBB, BlockIt
MBBI) {
1877 bool DstIsDead =
MI.getOperand(0).isDead();
1878 bool DstIsKill =
MI.getOperand(1).isKill();
1879 bool ImpIsDead =
MI.getOperand(3).isDead();
1880 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1888 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
1894 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1899 buildMI(
MBB,
MBBI, AVR::ADCRdRr)
1906 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
1912 MISBC->getOperand(3).setIsDead();
1914 MISBC->getOperand(4).setIsKill();
1916 MI.eraseFromParent();
1920bool AVRExpandPseudo::expandASRW8Rd(Block &
MBB, BlockIt
MBBI) {
1924 bool DstIsDead =
MI.getOperand(0).isDead();
1925 bool DstIsKill =
MI.getOperand(1).isKill();
1926 bool ImpIsDead =
MI.getOperand(3).isDead();
1927 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1930 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1935 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
1942 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
1948 MIBHI->getOperand(3).setIsDead();
1950 MIBHI->getOperand(4).setIsKill();
1952 MI.eraseFromParent();
1955bool AVRExpandPseudo::expandASRW14Rd(Block &
MBB, BlockIt
MBBI) {
1959 bool DstIsDead =
MI.getOperand(0).isDead();
1960 bool DstIsKill =
MI.getOperand(1).isKill();
1961 bool ImpIsDead =
MI.getOperand(3).isDead();
1962 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
1971 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
1977 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
1983 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
1989 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
1995 buildMI(
MBB,
MBBI, AVR::ADCRdRr)
2001 MIROL->getOperand(3).setIsDead();
2003 MIROL->getOperand(4).setIsKill();
2005 MI.eraseFromParent();
2009bool AVRExpandPseudo::expandASRW15Rd(Block &
MBB, BlockIt
MBBI) {
2013 bool DstIsDead =
MI.getOperand(0).isDead();
2014 bool ImpIsDead =
MI.getOperand(3).isDead();
2015 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
2022 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
2029 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
2034 MISBC->getOperand(3).setIsDead();
2036 MISBC->getOperand(4).setIsKill();
2039 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
2043 MI.eraseFromParent();
2048bool AVRExpandPseudo::expand<AVR::ASRWNRd>(Block &
MBB, BlockIt
MBBI) {
2050 unsigned Imm =
MI.getOperand(2).getImm();
2053 return expandASRW7Rd(
MBB,
MBBI);
2055 return expandASRW8Rd(
MBB,
MBBI);
2057 return expandASRW14Rd(
MBB,
MBBI);
2059 return expandASRW15Rd(
MBB,
MBBI);
2066bool AVRExpandPseudo::expandLSLB7Rd(Block &
MBB, BlockIt
MBBI) {
2069 bool DstIsDead =
MI.getOperand(0).isDead();
2070 bool DstIsKill =
MI.getOperand(1).isKill();
2071 bool ImpIsDead =
MI.getOperand(3).isDead();
2077 buildMI(
MBB,
MBBI, AVR::RORRd)
2083 buildMI(
MBB,
MBBI, AVR::EORRdRr)
2089 buildMI(
MBB,
MBBI, AVR::RORRd)
2094 MIRRC->getOperand(2).setIsDead();
2097 MIRRC->getOperand(3).setIsKill();
2099 MI.eraseFromParent();
2104bool AVRExpandPseudo::expand<AVR::LSLBNRd>(Block &
MBB, BlockIt
MBBI) {
2106 unsigned Imm =
MI.getOperand(2).getImm();
2109 return expandLSLB7Rd(
MBB,
MBBI);
2116bool AVRExpandPseudo::expandLSRB7Rd(Block &
MBB, BlockIt
MBBI) {
2119 bool DstIsDead =
MI.getOperand(0).isDead();
2120 bool DstIsKill =
MI.getOperand(1).isKill();
2121 bool ImpIsDead =
MI.getOperand(3).isDead();
2127 buildMI(
MBB,
MBBI, AVR::ADCRdRr)
2134 buildMI(
MBB,
MBBI, AVR::EORRdRr)
2140 buildMI(
MBB,
MBBI, AVR::ADCRdRr)
2146 MIRRC->getOperand(3).setIsDead();
2149 MIRRC->getOperand(4).setIsKill();
2151 MI.eraseFromParent();
2156bool AVRExpandPseudo::expand<AVR::LSRBNRd>(Block &
MBB, BlockIt
MBBI) {
2158 unsigned Imm =
MI.getOperand(2).getImm();
2161 return expandLSRB7Rd(
MBB,
MBBI);
2168bool AVRExpandPseudo::expandASRB6Rd(Block &
MBB, BlockIt
MBBI) {
2171 bool DstIsDead =
MI.getOperand(0).isDead();
2172 bool DstIsKill =
MI.getOperand(1).isKill();
2185 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
2190 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
2202 MI.eraseFromParent();
2206bool AVRExpandPseudo::expandASRB7Rd(Block &
MBB, BlockIt
MBBI) {
2209 bool DstIsDead =
MI.getOperand(0).isDead();
2210 bool DstIsKill =
MI.getOperand(1).isKill();
2211 bool ImpIsDead =
MI.getOperand(3).isDead();
2216 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
2222 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
2228 MIRRC->getOperand(3).setIsDead();
2231 MIRRC->getOperand(4).setIsKill();
2233 MI.eraseFromParent();
2238bool AVRExpandPseudo::expand<AVR::ASRBNRd>(Block &
MBB, BlockIt
MBBI) {
2240 unsigned Imm =
MI.getOperand(2).getImm();
2243 return expandASRB6Rd(
MBB,
MBBI);
2245 return expandASRB7Rd(
MBB,
MBBI);
2252template <>
bool AVRExpandPseudo::expand<AVR::SEXT>(Block &
MBB, BlockIt
MBBI) {
2270 bool DstIsDead =
MI.getOperand(0).isDead();
2271 bool SrcIsKill =
MI.getOperand(1).isKill();
2272 bool ImpIsDead =
MI.getOperand(2).isDead();
2273 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
2275 if (SrcReg != DstLoReg)
2276 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
2280 if (SrcReg != DstHiReg) {
2281 auto MOV = buildMI(
MBB,
MBBI, AVR::MOVRdRr)
2284 if (SrcReg != DstLoReg && SrcIsKill)
2285 MOV->getOperand(1).setIsKill();
2288 buildMI(
MBB,
MBBI, AVR::ADDRdRr)
2294 buildMI(
MBB,
MBBI, AVR::SBCRdRr)
2300 SBC->getOperand(3).setIsDead();
2303 SBC->getOperand(4).setIsKill();
2305 MI.eraseFromParent();
2309template <>
bool AVRExpandPseudo::expand<AVR::ZEXT>(Block &
MBB, BlockIt
MBBI) {
2322 bool DstIsDead =
MI.getOperand(0).isDead();
2323 bool SrcIsKill =
MI.getOperand(1).isKill();
2324 bool ImpIsDead =
MI.getOperand(2).isDead();
2325 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
2327 if (SrcReg != DstLoReg) {
2328 buildMI(
MBB,
MBBI, AVR::MOVRdRr)
2334 buildMI(
MBB,
MBBI, AVR::EORRdRr)
2340 EOR->getOperand(3).setIsDead();
2342 MI.eraseFromParent();
2347bool AVRExpandPseudo::expand<AVR::SPREAD>(Block &
MBB, BlockIt
MBBI) {
2351 bool DstIsDead =
MI.getOperand(0).isDead();
2352 unsigned Flags =
MI.getFlags();
2353 unsigned OpLo = AVR::INRdA;
2354 unsigned OpHi = AVR::INRdA;
2355 TRI->splitReg(DstReg, DstLoReg, DstHiReg);
2369 MI.eraseFromParent();
2374bool AVRExpandPseudo::expand<AVR::SPWRITE>(Block &
MBB, BlockIt
MBBI) {
2379 bool SrcIsKill =
MI.getOperand(1).isKill();
2380 unsigned Flags =
MI.getFlags();
2381 TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
2383 buildMI(
MBB,
MBBI, AVR::INRdA)
2388 buildMI(
MBB,
MBBI, AVR::BCLRs).addImm(0x07).setMIFlags(
Flags);
2390 buildMI(
MBB,
MBBI, AVR::OUTARr)
2395 buildMI(
MBB,
MBBI, AVR::OUTARr)
2400 buildMI(
MBB,
MBBI, AVR::OUTARr)
2405 MI.eraseFromParent();
2409bool AVRExpandPseudo::expandMI(Block &
MBB, BlockIt
MBBI) {
2411 int Opcode =
MBBI->getOpcode();
2415 return expand<Op>(MBB, MI)
2446 EXPAND(AVR::AtomicLoad8);
2447 EXPAND(AVR::AtomicLoad16);
2448 EXPAND(AVR::AtomicStore8);
2449 EXPAND(AVR::AtomicStore16);
2450 EXPAND(AVR::AtomicFence);
MachineBasicBlock MachineBasicBlock::iterator MBBI
#define AVR_EXPAND_PSEUDO_NAME
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static Expected< BitVector > expand(StringRef S, StringRef Original)
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Utilities relating to AVR registers.
A specific AVR target MCU.
Register getTmpRegister() const
bool hasTinyEncoding() const
const TargetFrameLowering * getFrameLowering() const override
int getIORegRAMPZ() const
Get I/O register addresses.
const AVRInstrInfo * getInstrInfo() const override
const AVRRegisterInfo * getRegisterInfo() const override
The address of a basic block.
FunctionPass class - This class is used to implement most global optimizations.
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
@ MO_Immediate
Immediate operand.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
TargetInstrInfo - Interface to description of machine instruction set.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ MO_HI
On a symbol operand, this represents the hi part.
@ MO_NEG
On a symbol operand, this represents it has to be negated.
@ MO_LO
On a symbol operand, this represents the lo part.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Define
Register definition.
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
This is an optimization pass for GlobalISel generic memory operations.
void initializeAVRExpandPseudoPass(PassRegistry &)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getDeadRegState(bool B)
FunctionPass * createAVRExpandPseudoPass()
unsigned getUndefRegState(bool B)
unsigned getKillRegState(bool B)