[llvm] 7a09aec - [VE] Add LSV/LVS/LVM/SVM instructions

Kazushi Marukawa via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 02:32:56 PDT 2020


Author: Kazushi (Jam) Marukawa
Date: 2020-10-19T18:32:48+09:00
New Revision: 7a09aec8040a805fb3ba9e3858ab9948a248be63

URL: https://github.com/llvm/llvm-project/commit/7a09aec8040a805fb3ba9e3858ab9948a248be63
DIFF: https://github.com/llvm/llvm-project/commit/7a09aec8040a805fb3ba9e3858ab9948a248be63.diff

LOG: [VE] Add LSV/LVS/LVM/SVM instructions

Add LSV/LVS/LVM/SVM vector instructions and regression tests.
Also update AsmParser to support new format of operands.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D89499

Added: 
    llvm/test/MC/VE/LSV.s
    llvm/test/MC/VE/LVM.s
    llvm/test/MC/VE/LVS.s
    llvm/test/MC/VE/SVM.s

Modified: 
    llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
    llvm/lib/Target/VE/VEInstrVec.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
index 7a899b4b38e2..73228f93d11b 100644
--- a/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
+++ b/llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp
@@ -1377,7 +1377,24 @@ OperandMatchResultTy VEAsmParser::parseOperand(OperandVector &Operands,
     if (!Parser.getTok().is(AsmToken::LParen))
       break;
 
-    // FIXME: Parsing %vec-reg + "(" + %sclar-reg/number + ")"
+    // Parsing %vec-reg + "(" + %sclar-reg/number + ")"
+    std::unique_ptr<VEOperand> Op1 = VEOperand::CreateToken(
+        Parser.getTok().getString(), Parser.getTok().getLoc());
+    Parser.Lex(); // Eat the '('.
+
+    std::unique_ptr<VEOperand> Op2;
+    ResTy = parseVEAsmOperand(Op2);
+    if (ResTy != MatchOperand_Success || !Op2)
+      return MatchOperand_ParseFail;
+
+    if (!Parser.getTok().is(AsmToken::RParen))
+      return MatchOperand_ParseFail;
+
+    Operands.push_back(std::move(Op1));
+    Operands.push_back(std::move(Op2));
+    Operands.push_back(VEOperand::CreateToken(Parser.getTok().getString(),
+                                              Parser.getTok().getLoc()));
+    Parser.Lex(); // Eat the ')'.
     break;
   }
   }

diff  --git a/llvm/lib/Target/VE/VEInstrVec.td b/llvm/lib/Target/VE/VEInstrVec.td
index 3ed3541a7172..dd04ece0c537 100644
--- a/llvm/lib/Target/VE/VEInstrVec.td
+++ b/llvm/lib/Target/VE/VEInstrVec.td
@@ -283,3 +283,72 @@ multiclass PFCHVm<string opcStr, bits<8>opc> {
 }
 let vc = 1, vx = 0 in defm PFCHV : PFCHVm<"pfchv", 0x80>;
 let vc = 0, vx = 0 in defm PFCHVNC : PFCHVm<"pfchv.nc", 0x80>;
+
+// Section 8.9.20 - LSV (Load S to V)
+let sx = 0, vx = ?, hasSideEffects = 0 in
+multiclass LSVbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
+                 dag dag_in> {
+  def "" : RR<opc, (outs RC:$vx), dag_in, !strconcat(opcStr, " ${vx}", argStr)>;
+  let Constraints = "$vx = $base", DisableEncoding = "$base",
+      isCodeGenOnly = 1 in
+  def _v : RR<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
+               !strconcat(opcStr, " ${vx}", argStr)>;
+}
+multiclass LSVm<string opcStr, bits<8>opc, RegisterClass RC> {
+  defm rr : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins I64:$sy, I64:$sz)>;
+  let cy = 0 in
+  defm ir : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins uimm7:$sy, I64:$sz)>;
+  let cz = 0 in
+  defm rm : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins I64:$sy, mimm:$sz)>;
+  let cy = 0, cz = 0 in
+  defm im : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins uimm7:$sy, mimm:$sz)>;
+}
+defm LSV : LSVm<"lsv", 0x8e, V64>;
+
+// Section 8.9.21 - LVS (Load V to S)
+let cz = 0, sz = 0, vx = ?, hasSideEffects = 0 in
+multiclass LVSm<string opcStr, bits<8>opc, RegisterClass RC> {
+  def vr : RR<opc, (outs I64:$sx), (ins RC:$vx, I64:$sy),
+              opcStr#" $sx, ${vx}(${sy})">;
+  let cy = 0 in
+  def vi : RR<opc, (outs I64:$sx), (ins RC:$vx, uimm7:$sy),
+              opcStr#" $sx, ${vx}(${sy})">;
+}
+defm LVS : LVSm<"lvs", 0x9e, V64>;
+
+// Section 8.9.22 - LVM (Load VM)
+let sx = 0, vx = ?, hasSideEffects = 0 in
+multiclass LVMbm<string opcStr, string argStr, bits<8>opc, RegisterClass RCM,
+                 dag dag_in> {
+  def "" : RR<opc, (outs RCM:$vx), dag_in,
+              !strconcat(opcStr, " $vx, ", argStr)>;
+  let Constraints = "$vx = $base", DisableEncoding = "$base",
+      isCodeGenOnly = 1 in {
+    def _m : RR<opc, (outs RCM:$vx), !con(dag_in, (ins RCM:$base)),
+                !strconcat(opcStr, " $vx, ", argStr)>;
+  }
+}
+multiclass LVMom<string opcStr, bits<8>opc, RegisterClass RCM> {
+  defm rr : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins I64:$sy, I64:$sz)>;
+  let cy = 0 in
+  defm ir : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins uimm2:$sy, I64:$sz)>;
+  let cz = 0 in
+  defm rm : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins I64:$sy, mimm:$sz)>;
+  let cy = 0, cz = 0 in
+  defm im : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins uimm2:$sy, mimm:$sz)>;
+}
+multiclass LVMm<string opcStr, bits<8>opc, RegisterClass RCM> {
+  defm "" : LVMom<opcStr, opc, RCM>;
+}
+defm LVM : LVMm<"lvm", 0xb7, VM>;
+
+// Section 8.9.23 - SVM (Save VM)
+let cz = 0, sz = 0, vz = ?, hasSideEffects = 0 in
+multiclass SVMm<string opcStr, bits<8>opc, RegisterClass RCM> {
+  def mr : RR<opc, (outs I64:$sx), (ins RCM:$vz, I64:$sy),
+              opcStr#" $sx, $vz, $sy">;
+  let cy = 0 in
+  def mi : RR<opc, (outs I64:$sx), (ins RCM:$vz, uimm2:$sy),
+              opcStr#" $sx, $vz, $sy">;
+}
+defm SVM : SVMm<"svm", 0xa7, VM>;

diff  --git a/llvm/test/MC/VE/LSV.s b/llvm/test/MC/VE/LSV.s
new file mode 100644
index 000000000000..72731c30606d
--- /dev/null
+++ b/llvm/test/MC/VE/LSV.s
@@ -0,0 +1,28 @@
+# RUN: llvm-mc -triple=ve --show-encoding < %s \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-INST
+
+# CHECK-INST: lsv %v11(0), %s12
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x8c,0x00,0x00,0x8e]
+lsv %v11(0), %s12
+
+# CHECK-INST: lsv %vix(%s23), %s12
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0xff,0x8c,0x97,0x00,0x8e]
+lsv %vix(%s23), %s12
+
+# CHECK-INST: lsv %v11(0), (32)0
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x60,0x00,0x00,0x8e]
+lsv %v11(0), (32)0
+
+# CHECK-INST: lsv %vix(%s23), (23)1
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0xff,0x17,0x97,0x00,0x8e]
+lsv %vix(%s23), (23)1
+
+# CHECK-INST: lsv %v11(%s22), (1)0
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x41,0x96,0x00,0x8e]
+lsv %v11(%s22), (1)0
+
+# CHECK-INST: lsv %vix(127), (63)1
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0xff,0x3f,0x7f,0x00,0x8e]
+lsv %vix(127), (63)1

diff  --git a/llvm/test/MC/VE/LVM.s b/llvm/test/MC/VE/LVM.s
new file mode 100644
index 000000000000..65a8953c7287
--- /dev/null
+++ b/llvm/test/MC/VE/LVM.s
@@ -0,0 +1,28 @@
+# RUN: llvm-mc -triple=ve --show-encoding < %s \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-INST
+
+# CHECK-INST: lvm %vm11, 0, %s12
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x8c,0x00,0x00,0xb7]
+lvm %vm11, 0, %s12
+
+# CHECK-INST: lvm %vm12, %s23, %s12
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0c,0x8c,0x97,0x00,0xb7]
+lvm %vm12, %s23, %s12
+
+# CHECK-INST: lvm %vm1, 0, (32)0
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x01,0x60,0x00,0x00,0xb7]
+lvm %vm1, 0, (32)0
+
+# CHECK-INST: lvm %vm2, %s23, (23)1
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x02,0x17,0x97,0x00,0xb7]
+lvm %vm2, %s23, (23)1
+
+# CHECK-INST: lvm %vm0, %s22, (1)0
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x41,0x96,0x00,0xb7]
+lvm %vm0, %s22, (1)0
+
+# CHECK-INST: lvm %vm15, 3, (63)1
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0f,0x3f,0x03,0x00,0xb7]
+lvm %vm15, 3, (63)1

diff  --git a/llvm/test/MC/VE/LVS.s b/llvm/test/MC/VE/LVS.s
new file mode 100644
index 000000000000..612376b24a20
--- /dev/null
+++ b/llvm/test/MC/VE/LVS.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple=ve --show-encoding < %s \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-INST
+
+# CHECK-INST: lvs %s12, %v11(0)
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x00,0x00,0x0c,0x9e]
+lvs %s12, %v11(0)
+
+# CHECK-INST: lvs %s63, %vix(%s23)
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0xff,0x00,0x97,0x3f,0x9e]
+lvs %s63, %vix(%s23)
+
+# CHECK-INST: lvs %s0, %v11(127)
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x0b,0x00,0x7f,0x00,0x9e]
+lvs %s0, %v11(127)

diff  --git a/llvm/test/MC/VE/SVM.s b/llvm/test/MC/VE/SVM.s
new file mode 100644
index 000000000000..f11428a9daf9
--- /dev/null
+++ b/llvm/test/MC/VE/SVM.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple=ve --show-encoding < %s \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=ve -filetype=obj < %s | llvm-objdump -d - \
+# RUN:     | FileCheck %s --check-prefixes=CHECK-INST
+
+# CHECK-INST: svm %s12, %vm11, 0
+# CHECK-ENCODING: encoding: [0x00,0x0b,0x00,0x00,0x00,0x00,0x0c,0xa7]
+svm %s12, %vm11, 0
+
+# CHECK-INST: svm %s63, %vm0, %s23
+# CHECK-ENCODING: encoding: [0x00,0x00,0x00,0x00,0x00,0x97,0x3f,0xa7]
+svm %s63, %vm0, %s23
+
+# CHECK-INST: svm %s0, %vm11, 3
+# CHECK-ENCODING: encoding: [0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0xa7]
+svm %s0, %vm11, 3


        


More information about the llvm-commits mailing list