This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add comments to the end of FMA3 instructions to make the operation clear
ClosedPublic

Authored by craig.topper on Mar 9 2018, 5:44 PM.

Details

Summary

There are 3 different operand orders for FMA instructions so figuring out the exact operation being performed requires a lot of thought.

This patch adds a comment to the end of the assembly line to print the exact operation.

I think I've got all the instructions in here except the ones with builtin rounding.

I didn't update all tests, but I assume we can get them as we regenerate tests in the future.

Diff Detail

Event Timeline

craig.topper created this revision.

Once more with context

spatel added inline comments.Mar 10 2018, 7:54 AM
lib/Target/X86/InstPrinter/X86InstComments.cpp
453

OpStr -> AccStr ?

465

A comment to explain the operand array would be helpful. IIUC, we're hardcoding getOperand(1) in all cases, so can we just hardcode the rest to simplify the code?

So we'd have something like:

CASE_FMA_SCALAR_REG(FMADD132)
  Mul2Name = getRegName(MI->getOperand(3).getReg());
  LLVM_FALLTHROUGH;
CASE_FMA_PACKED_MEM(FMADD132)
CASE_FMA_SCALAR_MEM(FMADD132)
  AccName = getRegName(MI->getOperand(2).getReg());
  Mul1Name = getRegName(MI->getOperand(1).getReg());
  break;

Add comment about the operand locations. Rename OpStr->AccStr.

spatel accepted this revision.Mar 10 2018, 12:00 PM

LGTM.

This revision is now accepted and ready to land.Mar 10 2018, 12:00 PM
This revision was automatically updated to reflect the committed changes.