Skip to content

Commit 5cb4175

Browse files
Anirudh Prasadredstar
Anirudh Prasad
authored andcommitted
[SystemZ] Introduce distinction between the jg/jl family of mnemonics for GNU as vs HLASM
- 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. Reviewed By: uweigand Differential Revision: https://reviews.llvm.org/D97581
1 parent 5cf2a37 commit 5cb4175

File tree

3 files changed

+80
-9
lines changed

3 files changed

+80
-9
lines changed

llvm/lib/Target/SystemZ/SystemZInstrFormats.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,13 @@ class ICV<string name>
19211921

19221922
// Defines a class that makes it easier to define
19231923
// a MnemonicAlias when CondVariant's are involved.
1924-
class MnemonicCondBranchAlias<CondVariant V, string from, string to>
1925-
: MnemonicAlias<!subst("#", V.suffix, from), !subst("#", V.suffix, to),
1926-
V.asmvariant>;
1924+
multiclass MnemonicCondBranchAlias<CondVariant V, string from, string to,
1925+
string asmvariant = V.asmvariant> {
1926+
if !or(!eq(V.asmvariant, ""), !eq(V.asmvariant, asmvariant)) then
1927+
def "" : MnemonicAlias<!subst("#", V.suffix, from),
1928+
!subst("#", V.suffix, to),
1929+
asmvariant>;
1930+
}
19271931

19281932
//===----------------------------------------------------------------------===//
19291933
// Instruction definitions with semantics

llvm/lib/Target/SystemZ/SystemZInstrInfo.td

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let isBranch = 1, isTerminator = 1, Uses = [CC] in {
8181
foreach V = [ "E", "NE", "H", "NH", "L", "NL", "HE", "NHE", "LE", "NLE",
8282
"Z", "NZ", "P", "NP", "M", "NM", "LH", "NLH", "O", "NO" ] in {
8383
def JAsm#V : FixedCondBranchRI <CV<V>, "j#", 0xA74>;
84-
def JGAsm#V : FixedCondBranchRIL<CV<V>, "jg#", 0xC04>;
84+
def JGAsm#V : FixedCondBranchRIL<CV<V>, "j{g|l}#", 0xC04>;
8585
let isIndirectBranch = 1 in {
8686
def BAsm#V : FixedCondBranchRX <CV<V>, "b#", 0x47>;
8787
def BRAsm#V : FixedCondBranchRR <CV<V>, "b#r", 0x07>;
@@ -95,7 +95,7 @@ let isBranch = 1, isTerminator = 1, Uses = [CC] in {
9595
// conditional branches with the condition mask set to "always".
9696
let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
9797
def J : FixedCondBranchRI <CondAlways, "j", 0xA74, br>;
98-
def JG : FixedCondBranchRIL<CondAlways, "jg", 0xC04>;
98+
def JG : FixedCondBranchRIL<CondAlways, "j{g|lu}", 0xC04>;
9999
let isIndirectBranch = 1 in {
100100
def B : FixedCondBranchRX<CondAlways, "b", 0x47>;
101101
def BR : FixedCondBranchRR<CondAlways, "br", 0x07, brind>;
@@ -117,7 +117,8 @@ def NOPR_bare : InstAlias<"nopr", (BCRAsm 0, R0D), 0>;
117117
def JNOP : InstAlias<"jnop\t$RI2", (BRCAsm 0, brtarget16:$RI2), 0>;
118118

119119
// An alias of BRCL 0, label
120-
def JGNOP : InstAlias<"jgnop\t$RI2", (BRCLAsm 0, brtarget32:$RI2), 0>;
120+
// jgnop on att ; jlnop on hlasm
121+
def JGNOP : InstAlias<"{jgnop|jlnop}\t$RI2", (BRCLAsm 0, brtarget32:$RI2), 0>;
121122

122123
// Fused compare-and-branch instructions.
123124
//
@@ -2375,10 +2376,12 @@ def JXHG : MnemonicAlias<"jxhg", "brxhg">;
23752376
def JXLEG : MnemonicAlias<"jxleg", "brxlg">;
23762377

23772378
def BRU : MnemonicAlias<"bru", "j">;
2378-
def BRUL : MnemonicAlias<"brul", "jg">;
2379+
def BRUL : MnemonicAlias<"brul", "jg", "att">;
2380+
def BRUL_HLASM : MnemonicAlias<"brul", "jlu", "hlasm">;
23792381

23802382
foreach V = [ "E", "NE", "H", "NH", "L", "NL", "HE", "NHE", "LE", "NLE",
23812383
"Z", "NZ", "P", "NP", "M", "NM", "LH", "NLH", "O", "NO" ] in {
2382-
def BRUAsm#V : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
2383-
def BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#">;
2384+
defm BRUAsm#V : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
2385+
defm BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#", "att">;
2386+
defm BRUL_HLASMAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jl#", "hlasm">;
23842387
}

llvm/test/MC/SystemZ/insn-bad.s

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,65 @@
561561
jnop 1
562562
jnop 0x10000
563563

564+
#CHECK: error: invalid instruction
565+
#CHECK: jlu label
566+
#CHECK: error: invalid instruction
567+
#CHECK: jlne label
568+
#CHECK: error: invalid instruction
569+
#CHECK: jlnh label
570+
#CHECK: error: invalid instruction
571+
#CHECK: jll label
572+
#CHECK: error: invalid instruction
573+
#CHECK: jlnl label
574+
#CHECK: error: invalid instruction
575+
#CHECK: jlhe label
576+
#CHECK: error: invalid instruction
577+
#CHECK: jlnhe label
578+
#CHECK: error: invalid instruction
579+
#CHECK: jlle label
580+
#CHECK: error: invalid instruction
581+
#CHECK: jlnle label
582+
#CHECK: error: invalid instruction
583+
#CHECK: jlz label
584+
#CHECK: error: invalid instruction
585+
#CHECK: jlnz label
586+
#CHECK: error: invalid instruction
587+
#CHECK: jlp label
588+
#CHECK: error: invalid instruction
589+
#CHECK: jlnp label
590+
#CHECK: error: invalid instruction
591+
#CHECK: jlm label
592+
#CHECK: error: invalid instruction
593+
#CHECK: jlnm label
594+
#CHECK: error: invalid instruction
595+
#CHECK: jllh label
596+
#CHECK: error: invalid instruction
597+
#CHECK: jllnlh label
598+
#CHECK: error: invalid instruction
599+
#CHECK: jlo label
600+
#CHECK: error: invalid instruction
601+
#CHECK: jlno label
602+
603+
jlu label
604+
jlne label
605+
jlnh label
606+
jll label
607+
jlnl label
608+
jlhe label
609+
jlnhe label
610+
jlle label
611+
jlnle label
612+
jlz label
613+
jlnz label
614+
jlp label
615+
jlnp label
616+
jlm label
617+
jlnm label
618+
jllh label
619+
jllnlh label
620+
jlo label
621+
jlno label
622+
564623
#CHECK: error: invalid operand
565624
#CHECK: brc foo, bar
566625
#CHECK: error: invalid operand
@@ -598,6 +657,11 @@
598657
jgnop 1
599658
jgnop 0x100000000
600659

660+
661+
#CHECK: error: invalid instruction
662+
#CHECK: jlnop label
663+
jlnop label
664+
601665
#CHECK: error: invalid operand
602666
#CHECK: brcl foo, bar
603667
#CHECK: error: invalid operand

0 commit comments

Comments
 (0)