This is an archive of the discontinued LLVM Phabricator instance.

[mips][microMIPS] Add CodeGen support for DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions
ClosedPublic

Authored by zbuljan on Feb 11 2016, 6:01 AM.

Details

Summary

The patch adds CodeGen support for microMIPSr6 DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions:

  • fixed order of registers in encoding definition class for microMIPS64 DDIV, DMOD, DDIVU and DMODU instructions
  • updated tests for the standard encodings of DDIV, DMOD, DDIVU and DMODU instructions
  • changed description class for microMIPSr6 DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions:
    • enabled insert of "teq $divisor_reg, $zero, 7" instruction in case of division by zero
  • added DAG patterns for proper selection of instructions
  • separated microMIPSr6 instructions from equivalent MIPS instructions using NotInMicroMips predicate
  • added microMIPS pseudo DIV and DIVU instructions with explicit accumulator register operands
  • updated .ll files with tests for microMIPSr6 DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions
  • fixed "Cannot copy registers" assertion:
    • added GPRMM16_64 register class and updated selection of register class for microMIPS64

Diff Detail

Repository
rL LLVM

Event Timeline

zbuljan updated this revision to Diff 47635.Feb 11 2016, 6:01 AM
zbuljan retitled this revision from to [mips][microMIPS] Add CodeGen support for DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions.
zbuljan updated this object.
zbuljan added subscribers: petarj, llvm-commits.
sdardis added a subscriber: sdardis.

Some nits. You're checking for nops in some cases. Checking for these in my view renders these tests fragile as microMIPS has the 'jrc' instruction which does not have a delay slot and hence a nop would not be required.

lib/Target/Mips/MipsISelLowering.cpp
912 ↗(On Diff #47635)

Nit: should be IsMicromips.

sdardis requested changes to this revision.Feb 18 2016, 4:48 AM
sdardis edited edge metadata.
This revision now requires changes to proceed.Feb 18 2016, 4:48 AM

Also, this patch should a diff relevant to http://reviews.llvm.org/D17068 .

zbuljan updated this revision to Diff 49157.Feb 26 2016, 1:15 AM
zbuljan edited edge metadata.
  • rebased to work with top of the tree
  • removed fix for "Cannot copy registers" as this patch depends on D17068 (rebased on D17068 patch)
  • removed checkings for nop instructions (they are not needed for microMIPS)
sdardis accepted this revision.Mar 3 2016, 6:06 AM
sdardis edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Mar 3 2016, 6:06 AM
This revision was automatically updated to reflect the committed changes.