Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV][MC] Add support for experimental Zcmop extension (#76395)
This implements experimental support for the Zcmop extension as specified here: https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc. This change adds only MC support.
- Loading branch information
Showing
10 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- RISCVInstrInfoZcmop.td -----------------------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file describes the RISC-V instructions from the standard Compressed | ||
// May-Be-Operations Extension (Zcmop). | ||
// This version is still experimental as the 'Zcmop' extension hasn't been | ||
// ratified yet. It is based on v0.2 of the specification. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
class CMOPInst<bits<3> imm3, string opcodestr> | ||
: RVInst16CI<0b011, 0b01, (outs), (ins), opcodestr, ""> { | ||
let Inst{6-2} = 0; | ||
let Inst{7} = 1; | ||
let Inst{10-8} = imm3; | ||
let Inst{12-11} = 0; | ||
} | ||
|
||
foreach i = 0...7 in { | ||
let Predicates = [HasStdExtZcmop] in { | ||
defvar n = !add(!mul(i, 2), 1); | ||
def CMOP # n : CMOPInst<i, "cmop." # n>, Sched<[]>; | ||
} // Predicates = [HasStdExtZcmop] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zcmop < %s 2>&1 | FileCheck %s | ||
|
||
cmop.0 # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic | ||
|
||
cmop.1 t0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction | ||
|
||
cmop.1 0x0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcmop -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmop -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcmop < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zcmop -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcmop < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zcmop -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.1 | ||
# CHECK-ASM: encoding: [0x81,0x60] | ||
cmop.1 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.3 | ||
# CHECK-ASM: encoding: [0x81,0x61] | ||
cmop.3 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.5 | ||
# CHECK-ASM: encoding: [0x81,0x62] | ||
cmop.5 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.7 | ||
# CHECK-ASM: encoding: [0x81,0x63] | ||
cmop.7 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.9 | ||
# CHECK-ASM: encoding: [0x81,0x64] | ||
cmop.9 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.11 | ||
# CHECK-ASM: encoding: [0x81,0x65] | ||
cmop.11 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.13 | ||
# CHECK-ASM: encoding: [0x81,0x66] | ||
cmop.13 | ||
|
||
# CHECK-ASM-AND-OBJ: cmop.15 | ||
# CHECK-ASM: encoding: [0x81,0x67] | ||
cmop.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters