@@ -92,6 +92,7 @@ class AVRExpandPseudo : public MachineFunctionPass {
92
92
// / Specific shift implementation.
93
93
bool expandLSLB7Rd (Block &MBB, BlockIt MBBI);
94
94
bool expandLSRB7Rd (Block &MBB, BlockIt MBBI);
95
+ bool expandASRB6Rd (Block &MBB, BlockIt MBBI);
95
96
bool expandASRB7Rd (Block &MBB, BlockIt MBBI);
96
97
bool expandLSLW4Rd (Block &MBB, BlockIt MBBI);
97
98
bool expandLSRW4Rd (Block &MBB, BlockIt MBBI);
@@ -1921,6 +1922,45 @@ bool AVRExpandPseudo::expand<AVR::LSRBNRd>(Block &MBB, BlockIt MBBI) {
1921
1922
}
1922
1923
}
1923
1924
1925
+ bool AVRExpandPseudo::expandASRB6Rd (Block &MBB, BlockIt MBBI) {
1926
+ MachineInstr &MI = *MBBI;
1927
+ Register DstReg = MI.getOperand (0 ).getReg ();
1928
+ bool DstIsDead = MI.getOperand (0 ).isDead ();
1929
+ bool DstIsKill = MI.getOperand (1 ).isKill ();
1930
+ bool ImpIsDead = MI.getOperand (3 ).isDead ();
1931
+
1932
+ // bst r24, 6
1933
+ // lsl r24
1934
+ // sbc r24, r24
1935
+ // bld r24, 0
1936
+
1937
+ buildMI (MBB, MBBI, AVR::BST)
1938
+ .addReg (DstReg)
1939
+ .addImm (6 )
1940
+ ->getOperand (2 )
1941
+ .setIsUndef (true );
1942
+
1943
+ buildMI (MBB, MBBI, AVR::ADDRdRr) // LSL Rd <==> ADD Rd, Rd
1944
+ .addReg (DstReg, RegState::Define | getDeadRegState (DstIsDead))
1945
+ .addReg (DstReg, getKillRegState (DstIsKill))
1946
+ .addReg (DstReg, getKillRegState (DstIsKill));
1947
+
1948
+ buildMI (MBB, MBBI, AVR::SBCRdRr)
1949
+ .addReg (DstReg, RegState::Define | getDeadRegState (DstIsDead))
1950
+ .addReg (DstReg, getKillRegState (DstIsKill))
1951
+ .addReg (DstReg, getKillRegState (DstIsKill));
1952
+
1953
+ buildMI (MBB, MBBI, AVR::BLD)
1954
+ .addReg (DstReg, RegState::Define | getDeadRegState (DstIsDead))
1955
+ .addReg (DstReg, getKillRegState (DstIsKill))
1956
+ .addImm (0 )
1957
+ ->getOperand (3 )
1958
+ .setIsKill ();
1959
+
1960
+ MI.eraseFromParent ();
1961
+ return true ;
1962
+ }
1963
+
1924
1964
bool AVRExpandPseudo::expandASRB7Rd (Block &MBB, BlockIt MBBI) {
1925
1965
MachineInstr &MI = *MBBI;
1926
1966
Register DstReg = MI.getOperand (0 ).getReg ();
@@ -1957,6 +1997,8 @@ bool AVRExpandPseudo::expand<AVR::ASRBNRd>(Block &MBB, BlockIt MBBI) {
1957
1997
MachineInstr &MI = *MBBI;
1958
1998
unsigned Imm = MI.getOperand (2 ).getImm ();
1959
1999
switch (Imm) {
2000
+ case 6 :
2001
+ return expandASRB6Rd (MBB, MBBI);
1960
2002
case 7 :
1961
2003
return expandASRB7Rd (MBB, MBBI);
1962
2004
default :
0 commit comments