diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/Target/AVR | |
parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
download | src-b60736ec1405bb0a8dd40989f67ef4c93da068ab.tar.gz src-b60736ec1405bb0a8dd40989f67ef4c93da068ab.zip |
Diffstat (limited to 'llvm/lib/Target/AVR')
-rw-r--r-- | llvm/lib/Target/AVR/AVRDevices.td | 21 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp | 147 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRFrameLowering.cpp | 33 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRISelLowering.cpp | 129 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRISelLowering.h | 7 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRInstrInfo.td | 35 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRSubtarget.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRSubtarget.h | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AVRTargetMachine.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h | 6 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h | 1 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp | 2 |
16 files changed, 338 insertions, 79 deletions
diff --git a/llvm/lib/Target/AVR/AVRDevices.td b/llvm/lib/Target/AVR/AVRDevices.td index 6730f2e1673e..9507aa40c3d8 100644 --- a/llvm/lib/Target/AVR/AVRDevices.td +++ b/llvm/lib/Target/AVR/AVRDevices.td @@ -195,7 +195,7 @@ def FamilyAVR6 : Family<"avr6", def FamilyTiny : Family<"avrtiny", [FamilyAVR0, FeatureBREAK, FeatureSRAM, - FeatureTinyEncoding, FeatureMMR]>; + FeatureTinyEncoding]>; def FamilyXMEGA : Family<"xmega", [FamilyAVR0, FeatureLPM, FeatureIJMPCALL, FeatureADDSUBIW, @@ -286,8 +286,10 @@ def : Device<"attiny45", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny85", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny261", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny261a", FamilyAVR25, ELFArchAVR25>; +def : Device<"attiny441", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny461", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny461a", FamilyAVR25, ELFArchAVR25>; +def : Device<"attiny841", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny861", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny861a", FamilyAVR25, ELFArchAVR25>; def : Device<"attiny87", FamilyAVR25, ELFArchAVR25>; @@ -307,19 +309,23 @@ def : Device<"atmega8u2", FamilyAVR35, ELFArchAVR35>; def : Device<"atmega16u2", FamilyAVR35, ELFArchAVR35>; def : Device<"atmega32u2", FamilyAVR35, ELFArchAVR35>; def : Device<"attiny1634", FamilyAVR35, ELFArchAVR35>; -def : Device<"atmega8", FamilyAVR4, ELFArchAVR4>; // FIXME: family may be wrong +def : Device<"atmega8", FamilyAVR2, ELFArchAVR4, + [FeatureMultiplication, FeatureMOVW, FeatureLPMX, FeatureSPM]>; def : Device<"ata6289", FamilyAVR4, ELFArchAVR4>; -def : Device<"atmega8a", FamilyAVR4, ELFArchAVR4>; +def : Device<"atmega8a", FamilyAVR2, ELFArchAVR4, + [FeatureMultiplication, FeatureMOVW, FeatureLPMX, FeatureSPM]>; def : Device<"ata6285", FamilyAVR4, ELFArchAVR4>; def : Device<"ata6286", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega48", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega48a", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega48pa", FamilyAVR4, ELFArchAVR4>; +def : Device<"atmega48pb", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega48p", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega88", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega88a", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega88p", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega88pa", FamilyAVR4, ELFArchAVR4>; +def : Device<"atmega88pb", FamilyAVR4, ELFArchAVR4>; def : Device<"atmega8515", FamilyAVR2, ELFArchAVR4, [FeatureMultiplication, FeatureMOVW, FeatureLPMX, FeatureSPM]>; def : Device<"atmega8535", FamilyAVR2, ELFArchAVR4, @@ -351,6 +357,7 @@ def : Device<"atmega168", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega168a", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega168p", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega168pa", FamilyAVR5, ELFArchAVR5>; +def : Device<"atmega168pb", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega169", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega169a", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega169p", FamilyAVR5, ELFArchAVR5>; @@ -361,6 +368,7 @@ def : Device<"atmega323", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega324a", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega324p", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega324pa", FamilyAVR5, ELFArchAVR5>; +def : Device<"atmega324pb", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega325", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega325a", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega325p", FamilyAVR5, ELFArchAVR5>; @@ -371,6 +379,7 @@ def : Device<"atmega3250p", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega3250pa", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega328", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega328p", FamilyAVR5, ELFArchAVR5>; +def : Device<"atmega328pb", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega329", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega329a", FamilyAVR5, ELFArchAVR5>; def : Device<"atmega329p", FamilyAVR5, ELFArchAVR5>; @@ -451,9 +460,9 @@ def : Device<"atxmega32a4", FamilyXMEGA, ELFArchXMEGA2>; def : Device<"atxmega32a4u", FamilyXMEGAU, ELFArchXMEGA2>; def : Device<"atxmega32c4", FamilyXMEGAU, ELFArchXMEGA2>; def : Device<"atxmega32d4", FamilyXMEGA, ELFArchXMEGA2>; -def : Device<"atxmega32e5", FamilyXMEGA, ELFArchXMEGA2>; -def : Device<"atxmega16e5", FamilyXMEGA, ELFArchXMEGA2>; -def : Device<"atxmega8e5", FamilyXMEGA, ELFArchXMEGA2>; +def : Device<"atxmega32e5", FamilyXMEGAU, ELFArchXMEGA2>; +def : Device<"atxmega16e5", FamilyXMEGAU, ELFArchXMEGA2>; +def : Device<"atxmega8e5", FamilyXMEGAU, ELFArchXMEGA2>; def : Device<"atxmega32x1", FamilyXMEGA, ELFArchXMEGA2>; def : Device<"atxmega64a3", FamilyXMEGA, ELFArchXMEGA4>; def : Device<"atxmega64a3u", FamilyXMEGAU, ELFArchXMEGA4>; diff --git a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp index 8ee69201e932..a48d3d134bb5 100644 --- a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp +++ b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp @@ -416,6 +416,44 @@ bool AVRExpandPseudo::expand<AVR::COMWRd>(Block &MBB, BlockIt MBBI) { } template <> +bool AVRExpandPseudo::expand<AVR::NEGWRd>(Block &MBB, BlockIt MBBI) { + MachineInstr &MI = *MBBI; + Register DstLoReg, DstHiReg; + Register DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + bool DstIsKill = MI.getOperand(1).isKill(); + bool ImpIsDead = MI.getOperand(2).isDead(); + TRI->splitReg(DstReg, DstLoReg, DstHiReg); + + // Do NEG on the upper byte. + auto MIBHI = + buildMI(MBB, MBBI, AVR::NEGRd) + .addReg(DstHiReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstHiReg, getKillRegState(DstIsKill)); + // SREG is always implicitly dead + MIBHI->getOperand(2).setIsDead(); + + // Do NEG on the lower byte. + buildMI(MBB, MBBI, AVR::NEGRd) + .addReg(DstLoReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstLoReg, getKillRegState(DstIsKill)); + + // Do an extra SBCI. + auto MISBCI = + buildMI(MBB, MBBI, AVR::SBCIRdK) + .addReg(DstHiReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstHiReg, getKillRegState(DstIsKill)) + .addImm(0); + if (ImpIsDead) + MISBCI->getOperand(3).setIsDead(); + // SREG is always implicitly killed + MISBCI->getOperand(4).setIsKill(); + + MI.eraseFromParent(); + return true; +} + +template <> bool AVRExpandPseudo::expand<AVR::CPWRdRr>(Block &MBB, BlockIt MBBI) { MachineInstr &MI = *MBBI; Register SrcLoReg, SrcHiReg, DstLoReg, DstHiReg; @@ -1438,6 +1476,111 @@ bool AVRExpandPseudo::expand<AVR::ASRWRd>(Block &MBB, BlockIt MBBI) { return true; } +template <> +bool AVRExpandPseudo::expand<AVR::LSLB7Rd>(Block &MBB, BlockIt MBBI) { + MachineInstr &MI = *MBBI; + Register DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + bool DstIsKill = MI.getOperand(1).isKill(); + bool ImpIsDead = MI.getOperand(2).isDead(); + + // ror r24 + // clr r24 + // ror r24 + + buildMI(MBB, MBBI, AVR::RORRd) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + buildMI(MBB, MBBI, AVR::EORRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + auto MIRRC = + buildMI(MBB, MBBI, AVR::RORRd) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + if (ImpIsDead) + MIRRC->getOperand(2).setIsDead(); + + // SREG is always implicitly killed + MIRRC->getOperand(3).setIsKill(); + + MI.eraseFromParent(); + return true; +} + +template <> +bool AVRExpandPseudo::expand<AVR::LSRB7Rd>(Block &MBB, BlockIt MBBI) { + MachineInstr &MI = *MBBI; + Register DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + bool DstIsKill = MI.getOperand(1).isKill(); + bool ImpIsDead = MI.getOperand(2).isDead(); + + // rol r24 + // clr r24 + // rol r24 + + buildMI(MBB, MBBI, AVR::ADCRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + buildMI(MBB, MBBI, AVR::EORRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + auto MIRRC = + buildMI(MBB, MBBI, AVR::ADCRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + if (ImpIsDead) + MIRRC->getOperand(3).setIsDead(); + + // SREG is always implicitly killed + MIRRC->getOperand(4).setIsKill(); + + MI.eraseFromParent(); + return true; +} + +template <> +bool AVRExpandPseudo::expand<AVR::ASRB7Rd>(Block &MBB, BlockIt MBBI) { + MachineInstr &MI = *MBBI; + Register DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + bool DstIsKill = MI.getOperand(1).isKill(); + bool ImpIsDead = MI.getOperand(2).isDead(); + + // lsl r24 + // sbc r24, r24 + + buildMI(MBB, MBBI, AVR::ADDRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + auto MIRRC = buildMI(MBB, MBBI, AVR::SBCRdRr) + .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) + .addReg(DstReg, getKillRegState(DstIsKill)) + .addReg(DstReg, getKillRegState(DstIsKill)); + + if (ImpIsDead) + MIRRC->getOperand(3).setIsDead(); + + // SREG is always implicitly killed + MIRRC->getOperand(4).setIsKill(); + + MI.eraseFromParent(); + return true; +} + template <> bool AVRExpandPseudo::expand<AVR::SEXT>(Block &MBB, BlockIt MBBI) { MachineInstr &MI = *MBBI; Register DstLoReg, DstHiReg; @@ -1616,6 +1759,7 @@ bool AVRExpandPseudo::expandMI(Block &MBB, BlockIt MBBI) { EXPAND(AVR::ORIWRdK); EXPAND(AVR::EORWRdRr); EXPAND(AVR::COMWRd); + EXPAND(AVR::NEGWRd); EXPAND(AVR::CPWRdRr); EXPAND(AVR::CPCWRdRr); EXPAND(AVR::LDIWRdK); @@ -1658,6 +1802,9 @@ bool AVRExpandPseudo::expandMI(Block &MBB, BlockIt MBBI) { EXPAND(AVR::RORWRd); EXPAND(AVR::ROLWRd); EXPAND(AVR::ASRWRd); + EXPAND(AVR::LSLB7Rd); + EXPAND(AVR::LSRB7Rd); + EXPAND(AVR::ASRB7Rd); EXPAND(AVR::SEXT); EXPAND(AVR::ZEXT); EXPAND(AVR::SPREAD); diff --git a/llvm/lib/Target/AVR/AVRFrameLowering.cpp b/llvm/lib/Target/AVR/AVRFrameLowering.cpp index c95a553b86ac..757b41466c3f 100644 --- a/llvm/lib/Target/AVR/AVRFrameLowering.cpp +++ b/llvm/lib/Target/AVR/AVRFrameLowering.cpp @@ -131,6 +131,26 @@ void AVRFrameLowering::emitPrologue(MachineFunction &MF, .setMIFlag(MachineInstr::FrameSetup); } +static void restoreStatusRegister(MachineFunction &MF, MachineBasicBlock &MBB) { + const AVRMachineFunctionInfo *AFI = MF.getInfo<AVRMachineFunctionInfo>(); + + MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr(); + + DebugLoc DL = MBBI->getDebugLoc(); + const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>(); + const AVRInstrInfo &TII = *STI.getInstrInfo(); + + // Emit special epilogue code to restore R1, R0 and SREG in interrupt/signal + // handlers at the very end of the function, just before reti. + if (AFI->isInterruptOrSignalHandler()) { + BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), AVR::R0); + BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr)) + .addImm(0x3f) + .addReg(AVR::R0, RegState::Kill); + BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R1R0); + } +} + void AVRFrameLowering::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { const AVRMachineFunctionInfo *AFI = MF.getInfo<AVRMachineFunctionInfo>(); @@ -151,18 +171,9 @@ void AVRFrameLowering::emitEpilogue(MachineFunction &MF, const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>(); const AVRInstrInfo &TII = *STI.getInstrInfo(); - // Emit special epilogue code to restore R1, R0 and SREG in interrupt/signal - // handlers at the very end of the function, just before reti. - if (AFI->isInterruptOrSignalHandler()) { - BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), AVR::R0); - BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr)) - .addImm(0x3f) - .addReg(AVR::R0, RegState::Kill); - BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R1R0); - } - // Early exit if there is no need to restore the frame pointer. if (!FrameSize) { + restoreStatusRegister(MF, MBB); return; } @@ -198,6 +209,8 @@ void AVRFrameLowering::emitEpilogue(MachineFunction &MF, // Write back R29R28 to SP and temporarily disable interrupts. BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP) .addReg(AVR::R29R28, RegState::Kill); + + restoreStatusRegister(MF, MBB); } // Return true if the specified function should have a dedicated frame diff --git a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp index fe31fa42c403..df382d553753 100644 --- a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp +++ b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp @@ -242,10 +242,7 @@ bool AVRDAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op, ConstantSDNode *ImmNode = dyn_cast<ConstantSDNode>(ImmOp); unsigned Reg; - bool CanHandleRegImmOpt = true; - - CanHandleRegImmOpt &= ImmNode != 0; - CanHandleRegImmOpt &= ImmNode->getAPIntValue().getZExtValue() < 64; + bool CanHandleRegImmOpt = ImmNode && ImmNode->getAPIntValue().ult(64); if (CopyFromRegOp->getOpcode() == ISD::CopyFromReg) { RegisterSDNode *RegNode = diff --git a/llvm/lib/Target/AVR/AVRISelLowering.cpp b/llvm/lib/Target/AVR/AVRISelLowering.cpp index bf9b32e1278e..3e7c2984655a 100644 --- a/llvm/lib/Target/AVR/AVRISelLowering.cpp +++ b/llvm/lib/Target/AVR/AVRISelLowering.cpp @@ -334,6 +334,36 @@ SDValue AVRTargetLowering::LowerShifts(SDValue Op, SelectionDAG &DAG) const { llvm_unreachable("Invalid shift opcode"); } + // Optimize int8 shifts. + if (VT.getSizeInBits() == 8) { + if (Op.getOpcode() == ISD::SHL && 4 <= ShiftAmount && ShiftAmount < 7) { + // Optimize LSL when 4 <= ShiftAmount <= 6. + Victim = DAG.getNode(AVRISD::SWAP, dl, VT, Victim); + Victim = + DAG.getNode(ISD::AND, dl, VT, Victim, DAG.getConstant(0xf0, dl, VT)); + ShiftAmount -= 4; + } else if (Op.getOpcode() == ISD::SRL && 4 <= ShiftAmount && + ShiftAmount < 7) { + // Optimize LSR when 4 <= ShiftAmount <= 6. + Victim = DAG.getNode(AVRISD::SWAP, dl, VT, Victim); + Victim = + DAG.getNode(ISD::AND, dl, VT, Victim, DAG.getConstant(0x0f, dl, VT)); + ShiftAmount -= 4; + } else if (Op.getOpcode() == ISD::SHL && ShiftAmount == 7) { + // Optimize LSL when ShiftAmount == 7. + Victim = DAG.getNode(AVRISD::LSL7, dl, VT, Victim); + ShiftAmount = 0; + } else if (Op.getOpcode() == ISD::SRL && ShiftAmount == 7) { + // Optimize LSR when ShiftAmount == 7. + Victim = DAG.getNode(AVRISD::LSR7, dl, VT, Victim); + ShiftAmount = 0; + } else if (Op.getOpcode() == ISD::SRA && ShiftAmount == 7) { + // Optimize ASR when ShiftAmount == 7. + Victim = DAG.getNode(AVRISD::ASR7, dl, VT, Victim); + ShiftAmount = 0; + } + } + while (ShiftAmount--) { Victim = DAG.getNode(Opc8, dl, VT, Victim); } @@ -437,6 +467,36 @@ static AVRCC::CondCodes intCCToAVRCC(ISD::CondCode CC) { } } +/// Returns appropriate CP/CPI/CPC nodes code for the given 8/16-bit operands. +SDValue AVRTargetLowering::getAVRCmp(SDValue LHS, SDValue RHS, + SelectionDAG &DAG, SDLoc DL) const { + assert((LHS.getSimpleValueType() == RHS.getSimpleValueType()) && + "LHS and RHS have different types"); + assert(((LHS.getSimpleValueType() == MVT::i16) || + (LHS.getSimpleValueType() == MVT::i8)) && "invalid comparison type"); + + SDValue Cmp; + + if (LHS.getSimpleValueType() == MVT::i16 && dyn_cast<ConstantSDNode>(RHS)) { + // Generate a CPI/CPC pair if RHS is a 16-bit constant. + SDValue LHSlo = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i8, LHS, + DAG.getIntPtrConstant(0, DL)); + SDValue LHShi = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i8, LHS, + DAG.getIntPtrConstant(1, DL)); + SDValue RHSlo = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i8, RHS, + DAG.getIntPtrConstant(0, DL)); + SDValue RHShi = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i8, RHS, + DAG.getIntPtrConstant(1, DL)); + Cmp = DAG.getNode(AVRISD::CMP, DL, MVT::Glue, LHSlo, RHSlo); + Cmp = DAG.getNode(AVRISD::CMPC, DL, MVT::Glue, LHShi, RHShi, Cmp); + } else { + // Generate ordinary 16-bit comparison. + Cmp = DAG.getNode(AVRISD::CMP, DL, MVT::Glue, LHS, RHS); + } + + return Cmp; +} + /// Returns appropriate AVR CMP/CMPC nodes and corresponding condition code for /// the given operands. SDValue AVRTargetLowering::getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, @@ -549,7 +609,7 @@ SDValue AVRTargetLowering::getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, DAG.getIntPtrConstant(1, DL)); Cmp = DAG.getNode(AVRISD::TST, DL, MVT::Glue, Top); } else { - Cmp = DAG.getNode(AVRISD::CMP, DL, MVT::Glue, LHSlo, RHSlo); + Cmp = getAVRCmp(LHSlo, RHSlo, DAG, DL); Cmp = DAG.getNode(AVRISD::CMPC, DL, MVT::Glue, LHShi, RHShi, Cmp); } } else if (VT == MVT::i64) { @@ -587,7 +647,7 @@ SDValue AVRTargetLowering::getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, DAG.getIntPtrConstant(1, DL)); Cmp = DAG.getNode(AVRISD::TST, DL, MVT::Glue, Top); } else { - Cmp = DAG.getNode(AVRISD::CMP, DL, MVT::Glue, LHS0, RHS0); + Cmp = getAVRCmp(LHS0, RHS0, DAG, DL); Cmp = DAG.getNode(AVRISD::CMPC, DL, MVT::Glue, LHS1, RHS1, Cmp); Cmp = DAG.getNode(AVRISD::CMPC, DL, MVT::Glue, LHS2, RHS2, Cmp); Cmp = DAG.getNode(AVRISD::CMPC, DL, MVT::Glue, LHS3, RHS3, Cmp); @@ -601,7 +661,7 @@ SDValue AVRTargetLowering::getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, : DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i8, LHS, DAG.getIntPtrConstant(1, DL))); } else { - Cmp = DAG.getNode(AVRISD::CMP, DL, MVT::Glue, LHS, RHS); + Cmp = getAVRCmp(LHS, RHS, DAG, DL); } } else { llvm_unreachable("Invalid comparison size"); @@ -676,7 +736,7 @@ SDValue AVRTargetLowering::LowerVASTART(SDValue Op, SelectionDAG &DAG) const { SDValue FI = DAG.getFrameIndex(AFI->getVarArgsFrameIndex(), getPointerTy(DL)); return DAG.getStore(Op.getOperand(0), dl, FI, Op.getOperand(1), - MachinePointerInfo(SV), 0); + MachinePointerInfo(SV)); } SDValue AVRTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { @@ -1096,8 +1156,7 @@ SDValue AVRTargetLowering::LowerFormalArguments( // from this parameter. SDValue FIN = DAG.getFrameIndex(FI, getPointerTy(DL)); InVals.push_back(DAG.getLoad(LocVT, dl, Chain, FIN, - MachinePointerInfo::getFixedStack(MF, FI), - 0)); + MachinePointerInfo::getFixedStack(MF, FI))); } } @@ -1230,8 +1289,7 @@ SDValue AVRTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, Chain = DAG.getStore(Chain, DL, Arg, PtrOff, - MachinePointerInfo::getStack(MF, VA.getLocMemOffset()), - 0); + MachinePointerInfo::getStack(MF, VA.getLocMemOffset())); } } @@ -1460,9 +1518,11 @@ MachineBasicBlock *AVRTargetLowering::insertShift(MachineInstr &MI, // Create loop block. MachineBasicBlock *LoopBB = F->CreateMachineBasicBlock(LLVM_BB); + MachineBasicBlock *CheckBB = F->CreateMachineBasicBlock(LLVM_BB); MachineBasicBlock *RemBB = F->CreateMachineBasicBlock(LLVM_BB); F->insert(I, LoopBB); + F->insert(I, CheckBB); F->insert(I, RemBB); // Update machine-CFG edges by transferring all successors of the current @@ -1471,14 +1531,14 @@ MachineBasicBlock *AVRTargetLowering::insertShift(MachineInstr &MI, BB->end()); RemBB->transferSuccessorsAndUpdatePHIs(BB); - // Add adges BB => LoopBB => RemBB, BB => RemBB, LoopBB => LoopBB. - BB->addSuccessor(LoopBB); - BB->addSuccessor(RemBB); - LoopBB->addSuccessor(RemBB); - LoopBB->addSuccessor(LoopBB); + // Add edges BB => LoopBB => CheckBB => RemBB, CheckBB => LoopBB. + BB->addSuccessor(CheckBB); + LoopBB->addSuccessor(CheckBB); + CheckBB->addSuccessor(LoopBB); + CheckBB->addSuccessor(RemBB); - Register ShiftAmtReg = RI.createVirtualRegister(&AVR::LD8RegClass); - Register ShiftAmtReg2 = RI.createVirtualRegister(&AVR::LD8RegClass); + Register ShiftAmtReg = RI.createVirtualRegister(&AVR::GPR8RegClass); + Register ShiftAmtReg2 = RI.createVirtualRegister(&AVR::GPR8RegClass); Register ShiftReg = RI.createVirtualRegister(RC); Register ShiftReg2 = RI.createVirtualRegister(RC); Register ShiftAmtSrcReg = MI.getOperand(2).getReg(); @@ -1486,44 +1546,41 @@ MachineBasicBlock *AVRTargetLowering::insertShift(MachineInstr &MI, Register DstReg = MI.getOperand(0).getReg(); // BB: - // cpi N, 0 - // breq RemBB - BuildMI(BB, dl, TII.get(AVR::CPIRdK)).addReg(ShiftAmtSrcReg).addImm(0); - BuildMI(BB, dl, TII.get(AVR::BREQk)).addMBB(RemBB); + // rjmp CheckBB + BuildMI(BB, dl, TII.get(AVR::RJMPk)).addMBB(CheckBB); // LoopBB: - // ShiftReg = phi [%SrcReg, BB], [%ShiftReg2, LoopBB] - // ShiftAmt = phi [%N, BB], [%ShiftAmt2, LoopBB] // ShiftReg2 = shift ShiftReg + auto ShiftMI = BuildMI(LoopBB, dl, TII.get(Opc), ShiftReg2).addReg(ShiftReg); + if (HasRepeatedOperand) + ShiftMI.addReg(ShiftReg); + + // CheckBB: + // ShiftReg = phi [%SrcReg, BB], [%ShiftReg2, LoopBB] + // ShiftAmt = phi [%N, BB], [%ShiftAmt2, LoopBB] + // DestReg = phi [%SrcReg, BB], [%ShiftReg, LoopBB] // ShiftAmt2 = ShiftAmt - 1; - BuildMI(LoopBB, dl, TII.get(AVR::PHI), ShiftReg) + // if (ShiftAmt2 >= 0) goto LoopBB; + BuildMI(CheckBB, dl, TII.get(AVR::PHI), ShiftReg) .addReg(SrcReg) .addMBB(BB) .addReg(ShiftReg2) .addMBB(LoopBB); - BuildMI(LoopBB, dl, TII.get(AVR::PHI), ShiftAmtReg) + BuildMI(CheckBB, dl, TII.get(AVR::PHI), ShiftAmtReg) .addReg(ShiftAmtSrcReg) .addMBB(BB) .addReg(ShiftAmtReg2) .addMBB(LoopBB); - - auto ShiftMI = BuildMI(LoopBB, dl, TII.get(Opc), ShiftReg2).addReg(ShiftReg); - if (HasRepeatedOperand) - ShiftMI.addReg(ShiftReg); - - BuildMI(LoopBB, dl, TII.get(AVR::SUBIRdK), ShiftAmtReg2) - .addReg(ShiftAmtReg) - .addImm(1); - BuildMI(LoopBB, dl, TII.get(AVR::BRNEk)).addMBB(LoopBB); - - // RemBB: - // DestReg = phi [%SrcReg, BB], [%ShiftReg, LoopBB] - BuildMI(*RemBB, RemBB->begin(), dl, TII.get(AVR::PHI), DstReg) + BuildMI(CheckBB, dl, TII.get(AVR::PHI), DstReg) .addReg(SrcReg) .addMBB(BB) .addReg(ShiftReg2) .addMBB(LoopBB); + BuildMI(CheckBB, dl, TII.get(AVR::DECRd), ShiftAmtReg2) + .addReg(ShiftAmtReg); + BuildMI(CheckBB, dl, TII.get(AVR::BRPLk)).addMBB(LoopBB); + MI.eraseFromParent(); // The pseudo instruction is gone now. return RemBB; } diff --git a/llvm/lib/Target/AVR/AVRISelLowering.h b/llvm/lib/Target/AVR/AVRISelLowering.h index d1eaf53b15e9..7aff4159211b 100644 --- a/llvm/lib/Target/AVR/AVRISelLowering.h +++ b/llvm/lib/Target/AVR/AVRISelLowering.h @@ -38,6 +38,9 @@ enum NodeType { LSL, ///< Logical shift left. LSR, ///< Logical shift right. ASR, ///< Arithmetic shift right. + LSL7, ///< Logical shift left 7 bits. + LSR7, ///< Logical shift right 7 bits. + ASR7, ///< Arithmetic shift right 7 bits. ROR, ///< Bit rotate right. ROL, ///< Bit rotate left. LSLLOOP, ///< A loop of single logical shift left instructions. @@ -56,6 +59,8 @@ enum NodeType { CMPC, /// Test for zero or minus instruction. TST, + /// Swap Rd[7:4] <-> Rd[3:0]. + SWAP, /// Operand 0 and operand 1 are selection variable, operand 2 /// is condition code and operand 3 is flag operand. SELECT_CC @@ -136,6 +141,8 @@ public: private: SDValue getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, SDValue &AVRcc, SelectionDAG &DAG, SDLoc dl) const; + SDValue getAVRCmp(SDValue LHS, SDValue RHS, SelectionDAG &DAG, + SDLoc dl) const; SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const; SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const; SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.td b/llvm/lib/Target/AVR/AVRInstrInfo.td index f03c254382b4..9f7c16fc96d2 100644 --- a/llvm/lib/Target/AVR/AVRInstrInfo.td +++ b/llvm/lib/Target/AVR/AVRInstrInfo.td @@ -59,6 +59,9 @@ def AVRlsr : SDNode<"AVRISD::LSR", SDTIntUnaryOp>; def AVRrol : SDNode<"AVRISD::ROL", SDTIntUnaryOp>; def AVRror : SDNode<"AVRISD::ROR", SDTIntUnaryOp>; def AVRasr : SDNode<"AVRISD::ASR", SDTIntUnaryOp>; +def AVRlsl7 : SDNode<"AVRISD::LSL7", SDTIntUnaryOp>; +def AVRlsr7 : SDNode<"AVRISD::LSR7", SDTIntUnaryOp>; +def AVRasr7 : SDNode<"AVRISD::ASR7", SDTIntUnaryOp>; // Pseudo shift nodes for non-constant shift amounts. def AVRlslLoop : SDNode<"AVRISD::LSLLOOP", SDTIntShiftOp>; @@ -67,6 +70,9 @@ def AVRrolLoop : SDNode<"AVRISD::ROLLOOP", SDTIntShiftOp>; def AVRrorLoop : SDNode<"AVRISD::RORLOOP", SDTIntShiftOp>; def AVRasrLoop : SDNode<"AVRISD::ASRLOOP", SDTIntShiftOp>; +// SWAP node. +def AVRSwap : SDNode<"AVRISD::SWAP", SDTIntUnaryOp>; + //===----------------------------------------------------------------------===// // AVR Operands, Complex Patterns and Transformations Definitions. //===----------------------------------------------------------------------===// @@ -732,13 +738,23 @@ Defs = [SREG] in "comw\t$rd", [(set i16:$rd, (not i16:$src)), (implicit SREG)]>; - //:TODO: optimize NEG for wider types def NEGRd : FRd<0b1001, 0b0100001, (outs GPR8:$rd), (ins GPR8:$src), "neg\t$rd", [(set i8:$rd, (ineg i8:$src)), (implicit SREG)]>; + + // NEGW Rd+1:Rd + // + // Expands to: + // neg Rd+1 + // neg Rd + // sbci Rd+1, 0 + def NEGWRd : Pseudo<(outs DREGS:$rd), + (ins DREGS:$src), + "negw\t$rd", + [(set i16:$rd, (ineg i16:$src)), (implicit SREG)]>; } // TST Rd @@ -1653,6 +1669,11 @@ Defs = [SREG] in "lslw\t$rd", [(set i16:$rd, (AVRlsl i16:$src)), (implicit SREG)]>; + def LSLB7Rd : Pseudo<(outs GPR8:$rd), + (ins GPR8:$src), + "lslb7\t$rd", + [(set i8:$rd, (AVRlsl7 i8:$src)), (implicit SREG)]>; + def LSRRd : FRd<0b1001, 0b0100110, (outs GPR8:$rd), @@ -1660,6 +1681,11 @@ Defs = [SREG] in "lsr\t$rd", [(set i8:$rd, (AVRlsr i8:$src)), (implicit SREG)]>; + def LSRB7Rd : Pseudo<(outs GPR8:$rd), + (ins GPR8:$src), + "lsrb7\t$rd", + [(set i8:$rd, (AVRlsr7 i8:$src)), (implicit SREG)]>; + def LSRWRd : Pseudo<(outs DREGS:$rd), (ins DREGS:$src), "lsrw\t$rd", @@ -1672,6 +1698,11 @@ Defs = [SREG] in "asr\t$rd", [(set i8:$rd, (AVRasr i8:$src)), (implicit SREG)]>; + def ASRB7Rd : Pseudo<(outs GPR8:$rd), + (ins GPR8:$src), + "asrb7\t$rd", + [(set i8:$rd, (AVRasr7 i8:$src)), (implicit SREG)]>; + def ASRWRd : Pseudo<(outs DREGS:$rd), (ins DREGS:$src), "asrw\t$rd", @@ -1719,7 +1750,7 @@ def SWAPRd : FRd<0b1001, (outs GPR8:$rd), (ins GPR8:$src), "swap\t$rd", - [(set i8:$rd, (bswap i8:$src))]>; + [(set i8:$rd, (AVRSwap i8:$src))]>; // IO register bit set/clear operations. //:TODO: add patterns when popcount(imm)==2 to be expanded with 2 sbi/cbi diff --git a/llvm/lib/Target/AVR/AVRSubtarget.cpp b/llvm/lib/Target/AVR/AVRSubtarget.cpp index 195ca95bc3bd..601865120491 100644 --- a/llvm/lib/Target/AVR/AVRSubtarget.cpp +++ b/llvm/lib/Target/AVR/AVRSubtarget.cpp @@ -29,7 +29,7 @@ namespace llvm { AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const AVRTargetMachine &TM) - : AVRGenSubtargetInfo(TT, CPU, FS), ELFArch(0), + : AVRGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), ELFArch(0), // Subtarget features m_hasSRAM(false), m_hasJMPCALL(false), m_hasIJMPCALL(false), @@ -43,14 +43,14 @@ AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU, InstrInfo(), FrameLowering(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS, TM)), TSInfo() { // Parse features string. - ParseSubtargetFeatures(CPU, FS); + ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS); } AVRSubtarget & AVRSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS, const TargetMachine &TM) { // Parse features string. - ParseSubtargetFeatures(CPU, FS); + ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS); return *this; } diff --git a/llvm/lib/Target/AVR/AVRSubtarget.h b/llvm/lib/Target/AVR/AVRSubtarget.h index 81d883eb30d9..7d49e43a83f5 100644 --- a/llvm/lib/Target/AVR/AVRSubtarget.h +++ b/llvm/lib/Target/AVR/AVRSubtarget.h @@ -46,7 +46,7 @@ public: /// Parses a subtarget feature string, setting appropriate options. /// \note Definition of function is auto generated by `tblgen`. - void ParseSubtargetFeatures(StringRef CPU, StringRef FS); + void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); AVRSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS, const TargetMachine &TM); diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp b/llvm/lib/Target/AVR/AVRTargetMachine.cpp index 0c7136e6f77e..0fa8623e2fb7 100644 --- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp +++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp @@ -37,7 +37,7 @@ static StringRef getCPU(StringRef CPU) { } static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) { - return RM.hasValue() ? *RM : Reloc::Static; + return RM.getValueOr(Reloc::Static); } AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT, diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp index 230bc7adc07a..19f769270569 100644 --- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -14,7 +14,6 @@ #include "TargetInfo/AVRTargetInfo.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/StringSwitch.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" @@ -166,13 +165,13 @@ public: assert(N == 1 && "Invalid number of operands!"); // The operand is actually a imm8, but we have its bitwise // negation in the assembly source, so twiddle it here. - const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm()); + const auto *CE = cast<MCConstantExpr>(getImm()); Inst.addOperand(MCOperand::createImm(~(uint8_t)CE->getValue())); } bool isImmCom8() const { if (!isImm()) return false; - const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm()); + const auto *CE = dyn_cast<MCConstantExpr>(getImm()); if (!CE) return false; int64_t Value = CE->getValue(); return isUInt<8>(Value); diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp index ac72abe0d9f6..49840672bf9a 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp @@ -13,12 +13,12 @@ #include "MCTargetDesc/AVRAsmBackend.h" #include "MCTargetDesc/AVRFixupKinds.h" #include "MCTargetDesc/AVRMCTargetDesc.h" - #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCELFObjectWriter.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSubtargetInfo.h" diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h index 9e150f120dd4..46dc914adf78 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h @@ -22,6 +22,7 @@ namespace llvm { class MCAssembler; +class MCContext; struct MCFixupKindInfo; /// Utilities for manipulating generated AVR machine code. @@ -47,11 +48,6 @@ public: return AVR::NumTargetFixupKinds; } - bool mayNeedRelaxation(const MCInst &Inst, - const MCSubtargetInfo &STI) const override { - return false; - } - bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const override { diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h index 910fd3455dee..8976ef28f3dc 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h @@ -45,6 +45,7 @@ private: void printMemri(const MCInst *MI, unsigned OpNo, raw_ostream &O); // Autogenerated by TableGen. + std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O); void printCustomAliasOperand(const MCInst *MI, uint64_t Address, diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp index 0a53e5346779..9eff554a082b 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp @@ -189,9 +189,10 @@ void AVRMCExpr::visitUsedExpr(MCStreamer &Streamer) const { } const char *AVRMCExpr::getName() const { - const auto &Modifier = std::find_if( - std::begin(ModifierNames), std::end(ModifierNames), - [this](ModifierEntry const &Mod) { return Mod.VariantKind == Kind; }); + const auto &Modifier = + llvm::find_if(ModifierNames, [this](ModifierEntry const &Mod) { + return Mod.VariantKind == Kind; + }); if (Modifier != std::end(ModifierNames)) { return Modifier->Spelling; @@ -200,9 +201,10 @@ const char *AVRMCExpr::getName() const { } AVRMCExpr::VariantKind AVRMCExpr::getKindByName(StringRef Name) { - const auto &Modifier = std::find_if( - std::begin(ModifierNames), std::end(ModifierNames), - [&Name](ModifierEntry const &Mod) { return Mod.Spelling == Name; }); + const auto &Modifier = + llvm::find_if(ModifierNames, [&Name](ModifierEntry const &Mod) { + return Mod.Spelling == Name; + }); if (Modifier != std::end(ModifierNames)) { return Modifier->VariantKind; diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp index bfc274d9cdcc..95f4465924cc 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp @@ -53,7 +53,7 @@ static MCRegisterInfo *createAVRMCRegisterInfo(const Triple &TT) { static MCSubtargetInfo *createAVRMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { - return createAVRMCSubtargetInfoImpl(TT, CPU, FS); + return createAVRMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS); } static MCInstPrinter *createAVRMCInstPrinter(const Triple &T, |