This is an archive of the discontinued LLVM Phabricator instance.

[PPC] Add a new register XER aliased to CARRY
ClosedPublic

Authored by Carrot on Jan 11 2018, 2:55 PM.

Details

Summary

When "xer" is specified as clobbered register in inline assembler, clang can accept it, but llvm simply ignore it when lowered to machine instructions. It may cause problems later in scheduler.

This patch adds a new register XER aliased to CARRY, and adds it to register class CARRYRC. Now PPCTargetLowering::getRegForInlineAsmConstraint can return correct register number for inline asm constraint "{xer}", and scheduler behave correctly.

Diff Detail

Repository
rL LLVM

Event Timeline

Carrot created this revision.Jan 11 2018, 2:55 PM

I think instead you want to add an alias in PPC similar to this:

def XER: SPR<1, "xer">, DwarfRegNum<[76]>;

Carry bit. In the architecture this is really bit 0 of the XER register
(which really is SPR register 1); this is the only bit interesting to a
// compiler.
def CARRY: SPR<1, "xer">, DwarfRegNum<[76]> {

let Aliases = [XER];

}

Does this work on your testcase?

-eric

I think instead you want to add an alias in PPC similar to this:

def XER: SPR<1, "xer">, DwarfRegNum<[76]>;

Carry bit. In the architecture this is really bit 0 of the XER register
(which really is SPR register 1); this is the only bit interesting to a
// compiler.
def CARRY: SPR<1, "xer">, DwarfRegNum<[76]> {

let Aliases = [XER];

}

Does this work on your testcase?

Unfortunately it doesn't work. When comparing register name

if (RegName.equals_lower(RI->getRegAsmName(*I)))

Instead of "xer" or "ca", RI->getRegAsmName(*I) returns "CARRY" for unknown reason.

Carrot updated this revision to Diff 129700.Jan 12 2018, 2:12 PM
Carrot retitled this revision from [PPC] Return PPC::CARRY for inline asm constraint "{xer}" to [PPC] Add a new register XER aliased to CARRY.
Carrot edited the summary of this revision. (Show Details)

The aliased register XER should also be put into register class CARRYRC, then getRegForInlineAsmConstraint can find it.

echristo accepted this revision.Jan 12 2018, 2:17 PM

Aha. I missed something. :)

And LGTM, thanks for the change!

-eric

This revision is now accepted and ready to land.Jan 12 2018, 2:17 PM
This revision was automatically updated to reflect the committed changes.