Skip to content

Commit 81e5077

Browse files
committed
[RISCV] Assembler support for XRivosVizip
This implements assembler support for the XRivosVizip custom/vendor extension from Rivos Inc. which is defined in: https://github.com/rivosinc/rivos-custom-extensions (See src/xrivosvizip.adoc) Codegen support will follow in a separate change.
1 parent 72f4e65 commit 81e5077

File tree

7 files changed

+71
-0
lines changed

7 files changed

+71
-0
lines changed

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
// CHECK-NEXT: xqcilo 0.2 'Xqcilo' (Qualcomm uC Large Offset Load Store Extension)
203203
// CHECK-NEXT: xqcilsm 0.2 'Xqcilsm' (Qualcomm uC Load Store Multiple Extension)
204204
// CHECK-NEXT: xqcisls 0.2 'Xqcisls' (Qualcomm uC Scaled Load Store Extension)
205+
// CHECK-NEXT: xrivosvizip 0.1 'XRivosVizip' (Rivos Vector Register Zips)
205206
// CHECK-EMPTY:
206207
// CHECK-NEXT: Supported Profiles
207208
// CHECK-NEXT: rva20s64

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
721721
"Qualcomm uC Conditional Move custom opcode table");
722722
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXqciint, DecoderTableXqciint32,
723723
"Qualcomm uC Interrupts custom opcode table");
724+
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXRivosVizip, DecoderTableXRivos32,
725+
"Rivos custom opcode table");
724726
TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
725727

726728
return MCDisassembler::Fail;

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,15 @@ def HasVendorXqcilo
13331333
AssemblerPredicate<(all_of FeatureVendorXqcilo),
13341334
"'Xqcilo' (Qualcomm uC Large Offset Load Store Extension)">;
13351335

1336+
// Rivos Extension(s)
1337+
1338+
def FeatureVendorXRivosVizip
1339+
: RISCVExperimentalExtension<0, 1, "Rivos Vector Register Zips">;
1340+
def HasVendorXRivosVizip
1341+
: Predicate<"Subtarget->hasVendorXRivosVizip()">,
1342+
AssemblerPredicate<(all_of FeatureVendorXRivosVizip),
1343+
"'XRivosVizip' (Rivos Vector Register Zips)">;
1344+
13361345
//===----------------------------------------------------------------------===//
13371346
// LLVM specific features and extensions
13381347
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ include "RISCVInstrInfoXCV.td"
21482148
include "RISCVInstrInfoXwch.td"
21492149
include "RISCVInstrInfoXqci.td"
21502150
include "RISCVInstrInfoXMips.td"
2151+
include "RISCVInstrInfoXRivos.td"
21512152

21522153
//===----------------------------------------------------------------------===//
21532154
// Global ISel
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===-- RISCVInstrInfoXRivos.td --------------------------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file describes the vendor extensions defined by Rivos Inc.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
//===----------------------------------------------------------------------===//
14+
// XRivosVizip
15+
//===----------------------------------------------------------------------===//
16+
17+
18+
let Predicates = [HasVendorXRivosVizip], hasSideEffects = 0,
19+
mayLoad = 0, mayStore = 0, isCodeGenOnly = 0, DecoderNamespace = "XRivos",
20+
Inst<6-0> = OPC_CUSTOM_2.Value in {
21+
defm RV_VZIPEVEN_V : VALU_IV_V<"rv.vzipeven", 0b001100>;
22+
defm RV_VZIPODD_V : VALU_IV_V<"rv.vzipodd", 0b011100>;
23+
defm RV_VZIP2A_V : VALU_IV_V<"rv.vzip2a", 0b000100>;
24+
defm RV_VZIP2B_V : VALU_IV_V<"rv.vzip2b", 0b010100>;
25+
defm RV_VUNZIP2A_V : VALU_IV_V<"rv.vunzip2a", 0b001000>;
26+
defm RV_VUNZIP2B_V : VALU_IV_V<"rv.vunzip2b", 0b011000>;
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xrivosvizip -riscv-no-aliases -show-encoding \
2+
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3+
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-xrivosvizip < %s \
4+
# RUN: | llvm-objdump --mattr=+experimental-xrivosvizip -M no-aliases -d -r - \
5+
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
6+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-xrivosvizip -riscv-no-aliases -show-encoding \
7+
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
8+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-xrivosvizip < %s \
9+
# RUN: | llvm-objdump --mattr=+experimental-xrivosvizip -M no-aliases -d -r - \
10+
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
11+
12+
# CHECK-ASM-AND-OBJ: rv.vzipeven.vv v1, v2, v3
13+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x32]
14+
rv.vzipeven.vv v1, v2, v3
15+
# CHECK-ASM-AND-OBJ: rv.vzipodd.vv v1, v2, v3
16+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x72]
17+
rv.vzipodd.vv v1, v2, v3
18+
# CHECK-ASM-AND-OBJ: rv.vzip2a.vv v1, v2, v3
19+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x12]
20+
rv.vzip2a.vv v1, v2, v3
21+
# CHECK-ASM-AND-OBJ: rv.vzip2b.vv v1, v2, v3
22+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x52]
23+
rv.vzip2b.vv v1, v2, v3
24+
# CHECK-ASM-AND-OBJ: rv.vunzip2a.vv v1, v2, v3
25+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x22]
26+
rv.vunzip2a.vv v1, v2, v3
27+
# CHECK-ASM-AND-OBJ: rv.vunzip2b.vv v1, v2, v3
28+
# CHECK-ASM: encoding: [0xdb,0x80,0x21,0x62]
29+
rv.vunzip2b.vv v1, v2, v3
30+

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ Experimental extensions
11281128
xqcilo 0.2
11291129
xqcilsm 0.2
11301130
xqcisls 0.2
1131+
xrivosvizip 0.1
11311132
11321133
Supported Profiles
11331134
rva20s64

0 commit comments

Comments
 (0)