[llvm] r341275 - [AVR] Define the ROL instruction as an alias of ADC
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 1 05:22:08 PDT 2018
Author: dylanmckay
Date: Sat Sep 1 05:22:07 2018
New Revision: 341275
URL: http://llvm.org/viewvc/llvm-project?rev=341275&view=rev
Log:
[AVR] Define the ROL instruction as an alias of ADC
The 'rol Rd' instruction is equivalent to 'adc Rd'.
This caused compile warnings from tablegen because of conflicting bits
shared between each instruction.
Modified:
llvm/trunk/lib/Target/AVR/AVRExpandPseudoInsts.cpp
llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp
llvm/trunk/lib/Target/AVR/AVRInstrInfo.td
llvm/trunk/test/CodeGen/AVR/pseudo/LSLWRd.mir
Modified: llvm/trunk/lib/Target/AVR/AVRExpandPseudoInsts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRExpandPseudoInsts.cpp?rev=341275&r1=341274&r2=341275&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRExpandPseudoInsts.cpp (original)
+++ llvm/trunk/lib/Target/AVR/AVRExpandPseudoInsts.cpp Sat Sep 1 05:22:07 2018
@@ -1252,7 +1252,7 @@ bool AVRExpandPseudo::expand<AVR::LSLWRd
bool DstIsKill = MI.getOperand(1).isKill();
bool ImpIsDead = MI.getOperand(2).isDead();
OpLo = AVR::LSLRd;
- OpHi = AVR::ROLRd;
+ OpHi = AVR::ADCRdRr; // ADC Rd, Rd <==> ROL Rd
TRI->splitReg(DstReg, DstLoReg, DstHiReg);
// Low part
@@ -1262,13 +1262,14 @@ bool AVRExpandPseudo::expand<AVR::LSLWRd
auto MIBHI = buildMI(MBB, MBBI, OpHi)
.addReg(DstHiReg, RegState::Define | getDeadRegState(DstIsDead))
+ .addReg(DstHiReg)
.addReg(DstHiReg, getKillRegState(DstIsKill));
if (ImpIsDead)
- MIBHI->getOperand(2).setIsDead();
+ MIBHI->getOperand(3).setIsDead();
// SREG is always implicitly killed
- MIBHI->getOperand(3).setIsKill();
+ MIBHI->getOperand(4).setIsKill();
MI.eraseFromParent();
return true;
Modified: llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp?rev=341275&r1=341274&r2=341275&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp Sat Sep 1 05:22:07 2018
@@ -1430,6 +1430,7 @@ MachineBasicBlock *AVRTargetLowering::in
MachineBasicBlock *BB) const {
unsigned Opc;
const TargetRegisterClass *RC;
+ bool HasRepeatedOperand = false;
MachineFunction *F = BB->getParent();
MachineRegisterInfo &RI = F->getRegInfo();
const AVRTargetMachine &TM = (const AVRTargetMachine &)getTargetMachine();
@@ -1464,8 +1465,9 @@ MachineBasicBlock *AVRTargetLowering::in
RC = &AVR::DREGSRegClass;
break;
case AVR::Rol8:
- Opc = AVR::ROLRd;
+ Opc = AVR::ADCRdRr; // ROL is an alias of ADC Rd, Rd
RC = &AVR::GPR8RegClass;
+ HasRepeatedOperand = true;
break;
case AVR::Rol16:
Opc = AVR::ROLWRd;
@@ -1535,7 +1537,11 @@ MachineBasicBlock *AVRTargetLowering::in
.addMBB(BB)
.addReg(ShiftAmtReg2)
.addMBB(LoopBB);
- BuildMI(LoopBB, dl, TII.get(Opc), ShiftReg2).addReg(ShiftReg);
+
+ 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);
Modified: llvm/trunk/lib/Target/AVR/AVRInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRInstrInfo.td?rev=341275&r1=341274&r2=341275&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AVR/AVRInstrInfo.td (original)
+++ llvm/trunk/lib/Target/AVR/AVRInstrInfo.td Sat Sep 1 05:22:07 2018
@@ -1671,12 +1671,7 @@ Defs = [SREG] in
// Bit rotate operations.
let Uses = [SREG] in
{
- def ROLRd : FRdRr<0b0001,
- 0b11,
- (outs GPR8:$rd),
- (ins GPR8:$src),
- "rol\t$rd",
- [(set i8:$rd, (AVRrol i8:$src)), (implicit SREG)]>;
+ // 8-bit ROL is an alias of ADC Rd, Rd
def ROLWRd : Pseudo<(outs DREGS:$rd),
(ins DREGS:$src),
@@ -1769,6 +1764,8 @@ Defs = [SREG] in
// Clears all bits in a register.
def CLR : InstAlias<"clr\t$rd", (EORRdRr GPR8:$rd, GPR8:$rd)>;
+def ROL : InstAlias<"rol\t$rd", (ADCRdRr GPR8:$rd, GPR8:$rd)>;
+
// SER Rd
// Alias for LDI Rd, 0xff
// ---------
Modified: llvm/trunk/test/CodeGen/AVR/pseudo/LSLWRd.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AVR/pseudo/LSLWRd.mir?rev=341275&r1=341274&r2=341275&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AVR/pseudo/LSLWRd.mir (original)
+++ llvm/trunk/test/CodeGen/AVR/pseudo/LSLWRd.mir Sat Sep 1 05:22:07 2018
@@ -16,7 +16,7 @@ body: |
; CHECK-LABEL: test
; CHECK: $r14 = LSLRd $r14, implicit-def $sreg
- ; CHECK-NEXT: $r15 = ROLRd $r15, implicit-def $sreg, implicit killed $sreg
+ ; CHECK-NEXT: $r15 = ADCRdRr $r15, $r15, implicit-def $sreg, implicit killed $sreg
$r15r14 = LSLWRd $r15r14, implicit-def $sreg
...
More information about the llvm-commits
mailing list