This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Add Thumb2 ADD with SP narrowing from 3 operand to 2
ClosedPublic

Authored by scott-0 on Jul 13 2015, 1:33 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

scott-0 updated this revision to Diff 29530.Jul 13 2015, 1:33 AM
scott-0 retitled this revision from to [ARM] Add Thumb2 ADD with SP narrowing from 3 operand to 2.
scott-0 updated this object.
scott-0 added a subscriber: llvm-commits.

What about the new immediate range tests? Are they covered somewhere else?

Thanks for the review!

There is 'add sp, sp, #4' in basic-thumb-instructions.s and 'add sp, sp, #0x1fe0000' in basic-thumb2-instructions.s

I'm also going to make thumb_rewrites.s pass for Thumb2, too; but it requires an additional fix.

[By the way, I considered writing the 'TryTransform' logic as just one 'if':

if (Mnemonic != "add" ||
    !(Op3Reg == ARM::PC || Op4Reg == ARM::PC ||
      (Op5.isReg() && Op5.getReg() == ARM::PC) ||
      ((Op3Reg == ARM::SP || Op4Reg == ARM::SP ||
        (Op5.isReg() && Op5.getReg() == ARM::SP)) &&
       !(Op3Reg == ARM::SP && Op4Reg == ARM::SP &&
         Op5.isImm() && !Op5.isImm0_1020s4()))))
  return;

but I thought it was a bit easier to follow with the intermediate steps.]

Thanks for the review!

There is 'add sp, sp, #4' in basic-thumb-instructions.s and 'add sp, sp, #0x1fe0000' in basic-thumb2-instructions.s

Just about the transformation, in this test-file, if you had the allowed imm for SP transformed and the not-allowed not transformed, that'd be enough, I think.

but I thought it was a bit easier to follow with the intermediate steps.

It is. :)

scott-0 updated this revision to Diff 29570.Jul 13 2015, 8:19 AM

Yes, that's a good idea; added.

rengolin accepted this revision.Jul 13 2015, 8:20 AM
rengolin added a reviewer: rengolin.
This revision is now accepted and ready to land.Jul 13 2015, 8:20 AM
This revision was automatically updated to reflect the committed changes.