[llvm] 5cb4175 - [SystemZ] Introduce distinction between the jg/jl family of mnemonics for GNU as vs HLASM
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 13:36:54 PST 2021
Author: Anirudh Prasad
Date: 2021-03-01T16:36:07-05:00
New Revision: 5cb417527cbca62bbee93504deb2f1e7a357e6ec
URL: https://github.com/llvm/llvm-project/commit/5cb417527cbca62bbee93504deb2f1e7a357e6ec
DIFF: https://github.com/llvm/llvm-project/commit/5cb417527cbca62bbee93504deb2f1e7a357e6ec.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/SystemZ/SystemZInstrFormats.td
llvm/lib/Target/SystemZ/SystemZInstrInfo.td
llvm/test/MC/SystemZ/insn-bad.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
index a1b65b159eb1..2c0750908504 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
+++ b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
@@ -1921,9 +1921,13 @@ class ICV<string name>
// Defines a class that makes it easier to define
// a MnemonicAlias when CondVariant's are involved.
-class MnemonicCondBranchAlias<CondVariant V, string from, string to>
- : MnemonicAlias<!subst("#", V.suffix, from), !subst("#", V.suffix, to),
- V.asmvariant>;
+multiclass 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>;
+}
//===----------------------------------------------------------------------===//
// Instruction definitions with semantics
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
index ed6dc193eca0..76d0381649c6 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
+++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td
@@ -81,7 +81,7 @@ let isBranch = 1, isTerminator = 1, Uses = [CC] in {
foreach V = [ "E", "NE", "H", "NH", "L", "NL", "HE", "NHE", "LE", "NLE",
"Z", "NZ", "P", "NP", "M", "NM", "LH", "NLH", "O", "NO" ] in {
def JAsm#V : FixedCondBranchRI <CV<V>, "j#", 0xA74>;
- def JGAsm#V : FixedCondBranchRIL<CV<V>, "jg#", 0xC04>;
+ def JGAsm#V : FixedCondBranchRIL<CV<V>, "j{g|l}#", 0xC04>;
let isIndirectBranch = 1 in {
def BAsm#V : FixedCondBranchRX <CV<V>, "b#", 0x47>;
def BRAsm#V : FixedCondBranchRR <CV<V>, "b#r", 0x07>;
@@ -95,7 +95,7 @@ let isBranch = 1, isTerminator = 1, Uses = [CC] in {
// conditional branches with the condition mask set to "always".
let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
def J : FixedCondBranchRI <CondAlways, "j", 0xA74, br>;
- def JG : FixedCondBranchRIL<CondAlways, "jg", 0xC04>;
+ def JG : FixedCondBranchRIL<CondAlways, "j{g|lu}", 0xC04>;
let isIndirectBranch = 1 in {
def B : FixedCondBranchRX<CondAlways, "b", 0x47>;
def BR : FixedCondBranchRR<CondAlways, "br", 0x07, brind>;
@@ -117,7 +117,8 @@ def NOPR_bare : InstAlias<"nopr", (BCRAsm 0, R0D), 0>;
def JNOP : InstAlias<"jnop\t$RI2", (BRCAsm 0, brtarget16:$RI2), 0>;
// An alias of BRCL 0, label
-def JGNOP : InstAlias<"jgnop\t$RI2", (BRCLAsm 0, brtarget32:$RI2), 0>;
+// jgnop on att ; jlnop on hlasm
+def JGNOP : InstAlias<"{jgnop|jlnop}\t$RI2", (BRCLAsm 0, brtarget32:$RI2), 0>;
// Fused compare-and-branch instructions.
//
@@ -2375,10 +2376,12 @@ def JXHG : MnemonicAlias<"jxhg", "brxhg">;
def JXLEG : MnemonicAlias<"jxleg", "brxlg">;
def BRU : MnemonicAlias<"bru", "j">;
-def BRUL : MnemonicAlias<"brul", "jg">;
+def BRUL : MnemonicAlias<"brul", "jg", "att">;
+def BRUL_HLASM : MnemonicAlias<"brul", "jlu", "hlasm">;
foreach V = [ "E", "NE", "H", "NH", "L", "NL", "HE", "NHE", "LE", "NLE",
"Z", "NZ", "P", "NP", "M", "NM", "LH", "NLH", "O", "NO" ] in {
- def BRUAsm#V : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
- def BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#">;
+ defm BRUAsm#V : MnemonicCondBranchAlias <CV<V>, "br#", "j#">;
+ defm BRULAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jg#", "att">;
+ defm BRUL_HLASMAsm#V : MnemonicCondBranchAlias <CV<V>, "br#l", "jl#", "hlasm">;
}
diff --git a/llvm/test/MC/SystemZ/insn-bad.s b/llvm/test/MC/SystemZ/insn-bad.s
index 4637a2f0dbc3..dbe5b71d92dd 100644
--- a/llvm/test/MC/SystemZ/insn-bad.s
+++ b/llvm/test/MC/SystemZ/insn-bad.s
@@ -561,6 +561,65 @@
jnop 1
jnop 0x10000
+#CHECK: error: invalid instruction
+#CHECK: jlu label
+#CHECK: error: invalid instruction
+#CHECK: jlne label
+#CHECK: error: invalid instruction
+#CHECK: jlnh label
+#CHECK: error: invalid instruction
+#CHECK: jll label
+#CHECK: error: invalid instruction
+#CHECK: jlnl label
+#CHECK: error: invalid instruction
+#CHECK: jlhe label
+#CHECK: error: invalid instruction
+#CHECK: jlnhe label
+#CHECK: error: invalid instruction
+#CHECK: jlle label
+#CHECK: error: invalid instruction
+#CHECK: jlnle label
+#CHECK: error: invalid instruction
+#CHECK: jlz label
+#CHECK: error: invalid instruction
+#CHECK: jlnz label
+#CHECK: error: invalid instruction
+#CHECK: jlp label
+#CHECK: error: invalid instruction
+#CHECK: jlnp label
+#CHECK: error: invalid instruction
+#CHECK: jlm label
+#CHECK: error: invalid instruction
+#CHECK: jlnm label
+#CHECK: error: invalid instruction
+#CHECK: jllh label
+#CHECK: error: invalid instruction
+#CHECK: jllnlh label
+#CHECK: error: invalid instruction
+#CHECK: jlo label
+#CHECK: error: invalid instruction
+#CHECK: jlno label
+
+ jlu label
+ jlne label
+ jlnh label
+ jll label
+ jlnl label
+ jlhe label
+ jlnhe label
+ jlle label
+ jlnle label
+ jlz label
+ jlnz label
+ jlp label
+ jlnp label
+ jlm label
+ jlnm label
+ jllh label
+ jllnlh label
+ jlo label
+ jlno label
+
#CHECK: error: invalid operand
#CHECK: brc foo, bar
#CHECK: error: invalid operand
@@ -598,6 +657,11 @@
jgnop 1
jgnop 0x100000000
+
+#CHECK: error: invalid instruction
+#CHECK: jlnop label
+ jlnop label
+
#CHECK: error: invalid operand
#CHECK: brcl foo, bar
#CHECK: error: invalid operand
More information about the llvm-commits
mailing list