This is an archive of the discontinued LLVM Phabricator instance.

[mips] Added support for the div, divu, ddiv and ddivu macros using traps and breaks in the integrated assembler.
ClosedPublic

Authored by s.egerton on Jul 31 2015, 3:54 AM.

Diff Detail

Event Timeline

s.egerton updated this revision to Diff 31112.Jul 31 2015, 3:54 AM
s.egerton retitled this revision from to Added support for the div, divu, ddiv and ddivu macros using traps and breaks in the integrated assembler..
s.egerton updated this object.
s.egerton added reviewers: dsanders, vkalintiris.
s.egerton added a subscriber: llvm-commits.
s.egerton retitled this revision from Added support for the div, divu, ddiv and ddivu macros using traps and breaks in the integrated assembler. to [mips] Added support for the div, divu, ddiv and ddivu macros using traps and breaks in the integrated assembler..Jul 31 2015, 4:00 AM
dsanders edited edge metadata.Aug 11 2015, 6:10 AM

Mostly a few style and spelling nits.

Regarding the magic numbers for branch targets: I definitely want to eliminate these (they are unlikely to be correct for microMIPS) but I can't think of a way to do so in the current implementation for macros. The problem is that we need to drop private labels at a future point in the instruction stream but we can't arrange this since we are buffering the instructions before emitting them all at once. We need to move to a mechanism where we emit the instructions directly as we build them. For now, could you make them named constants and mark them with a FIXME?

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
2773

The '|| hasMips64r6()' is redundant. The predicates are cumulative.

2805–2809

Style nit:

if (UseTraps) {
  emitRRI(...);
  return false;
}

emitII(...);
return false;
2811

Style nit: Avoid else after return

2820–2824

Style nit:

if (UseTraps) {
  emitRRI(...);
  return false;
}

emitII(...);
return false;
2831

Magic number for offset: 2*4

2849

Magic number for offset: 3*4
Magic number for offset: 5*4

2853

Magic number for offset: 2*4
Magic number for offset: 4*4

2860

Magic number for offset: 2*4

lib/Target/Mips/Mips.td
166–168

The names and strings here are a little confusing.

In both cases, the div macros trap division by zero. We're only picking between the conditional trap instructions ('teq' and similar) and the unconditional 'break' instruction (with a conditional branch over it), both of which are kinds of trap.

I'm not sure what to suggest for the spelling since most names fall into the same problem. Maybe 'use-tcc-in-div'?

s.egerton updated this revision to Diff 32151.Aug 14 2015, 6:17 AM
s.egerton marked 8 inline comments as done.
s.egerton edited edge metadata.

Responded to reviewers comments.

dsanders accepted this revision.Aug 21 2015, 6:08 AM
dsanders edited edge metadata.

Ignoring the magic number issue (see below): LGTM with some formatting nits.

Regarding the magic number issue: I still don't have a good solution to eliminate these hard coded offsets so we should go ahead for now and eliminate them when we refactor the way expansions are handled (which we need to do so sort out other relocation-related issues).

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
2811

I know why you've skipped this comment because we spoke face to face but you should also mention it on list.

The reason is that it isn't an else after return. Only two of the three paths in the if-statements true case end in a return.

2832

Nit: Space after //

2838–2841

Nit: Use ternary operator

2844–2847

Nit: Use ternary operator

2849

Nit: 80cols? and space after //.

2868

Nit: 80cols? and space after //.

2872

Nit: 80cols? and space after //.

2879

Nit: 80cols? and space after //.

lib/Target/Mips/Mips.td
166–168

Nit: First argument should be hanging too.

The same is true of FeatureCnMips above but that's not for this patch.

lib/Target/Mips/MipsInstrInfo.td
1738

Nit: Indentation.

Likewise for the other 3.

This revision is now accepted and ready to land.Aug 21 2015, 6:08 AM
s.egerton updated this revision to Diff 33406.Aug 28 2015, 2:50 AM
s.egerton marked 9 inline comments as done.
s.egerton edited edge metadata.

Responded to reviewer comments. Made a few minor changes to emit functions to account for changes on the trunk. Also fixed last upload which accidentally removed a significant amount of code.

dsanders closed this revision.Sep 3 2015, 5:32 AM