aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Prasad <Anirudh.Prasad@ibm.com>2021-03-01 16:31:29 -0500
committerKai Nacke <kai@redstar.de>2021-03-01 16:36:07 -0500
commit5cb417527cbca62bbee93504deb2f1e7a357e6ec (patch)
tree12db42a216ddba295eeab3cb4e439ab03f5b348a
parent5cf2a37f1255700d4da9d5f45e82bdfff09aee8c (diff)
downloadllvm-5cb417527cbca62bbee93504deb2f1e7a357e6ec.zip
llvm-5cb417527cbca62bbee93504deb2f1e7a357e6ec.tar.gz
llvm-5cb417527cbca62bbee93504deb2f1e7a357e6ec.tar.bz2
[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
-rw-r--r--llvm/lib/Target/SystemZ/SystemZInstrFormats.td10
-rw-r--r--llvm/lib/Target/SystemZ/SystemZInstrInfo.td15
-rw-r--r--llvm/test/MC/SystemZ/insn-bad.s64
3 files changed, 80 insertions, 9 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
index a1b65b1..2c075090 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 ed6dc19..76d0381 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 4637a2f0..dbe5b71 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