This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Introduce distinction between the jg/jl family of mnemonics for GNU as vs HLASM
ClosedPublic

Authored by anirudhp on Feb 26 2021, 2:42 PM.

Details

Summary
  • This patch adds in the distinction between jg[*] and jl[*] pc-relative mnemonics based on the variant/dialect.
  • Under the hlasm variant, we use the jl[*] family of mnemonics and under the att (GNU as) variant, we use the jg[*] family of mnemonics.
  • jgnop which was added in https://reviews.llvm.org/D92185, is now restricted to att variant. jlnop is introduced and restricted to hlasm variant.
  • The br[*]l additional mnemonics are mapped to either jl[*]/jg[*] based on the variant.

Diff Detail

Event Timeline

anirudhp created this revision.Feb 26 2021, 2:42 PM
anirudhp requested review of this revision.Feb 26 2021, 2:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2021, 2:42 PM

Looks good in general. Just as a cosmetic issue, it would be nicer to be able to simply write:

def BRUAsm#V  : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
def BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#", "att">;
def BRUL_HLASMAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jl#", "hlasm">;

and have the additional assembler dialect constraint based on the mnemonic handled within MnemonicCondBranchAlias. Completely untested, but would something along the following lines work?

class MnemonicCondBranchAlias<CondVariant V, string from, string to,
                              string asmvariant = V.asmvariant> {
  if !or(!eq(V.asmvariant, ""), !eq(V.asmvariant, asmvariant)) then
    def "" : MnemonicAlias<!subst("#", V.suffix, from), !subst("#", V.suffix, to),
                           asmvariant>;
}

(It might have to be a multiclass instead of class, possibly.)

anirudhp updated this revision to Diff 327132.Mar 1 2021, 8:56 AM
  • Improved the implementation of MnemonicCondBranch by abstracting away details from SystemZInstrInfo.td
  • For this, a multi-class had to be used.
anirudhp updated this revision to Diff 327135.Mar 1 2021, 9:02 AM

Looks good in general. Just as a cosmetic issue, it would be nicer to be able to simply write:

def BRUAsm#V  : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
def BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#", "att">;
def BRUL_HLASMAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jl#", "hlasm">;

and have the additional assembler dialect constraint based on the mnemonic handled within MnemonicCondBranchAlias. Completely untested, but would something along the following lines work?

class MnemonicCondBranchAlias<CondVariant V, string from, string to,
                              string asmvariant = V.asmvariant> {
  if !or(!eq(V.asmvariant, ""), !eq(V.asmvariant, asmvariant)) then
    def "" : MnemonicAlias<!subst("#", V.suffix, from), !subst("#", V.suffix, to),
                           asmvariant>;
}

(It might have to be a multiclass instead of class, possibly.)

I abstracted away the implementation into SystemZInstrFormats.td. As you pointed out, it should be a multiclass.

uweigand accepted this revision.Mar 1 2021, 9:06 AM
  • Improved the implementation of MnemonicCondBranch by abstracting away details from SystemZInstrInfo.td
  • For this, a multi-class had to be used.

Excellent, thank you! This LGTM now.

This revision is now accepted and ready to land.Mar 1 2021, 9:06 AM