-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV][MC] MC layer support for the experimental zacas extension
This implements the v1.0-rc1 draft extension. amocas.d on RV32 and amocas.q have the restriction that rd and rs2 must be even registers. I've opted to implement this restriction in RISCVAsmParser::validateInstruction even though for codegen we'll need a new register class and can then remove this validation. This also sidesteps, for now, the issue of amocas.d being different on rv32 vs rv64. See <riscv-non-isa/riscv-c-api-doc#37> for the issue of needing an agreed asm register constraint for register pairs. Differential Revision: https://reviews.llvm.org/D149248
- Loading branch information
Showing
13 changed files
with
211 additions
and
1 deletion.
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
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,18 @@ | ||
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zacas < %s 2>&1 | FileCheck %s | ||
|
||
# Non-zero offsets not supported for the third operand (rs1). | ||
amocas.w a1, a3, 1(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0 | ||
amocas.d a1, a3, 2(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0 | ||
|
||
# First and second operands (rd and rs2) of amocas.d must be even for RV32. | ||
amocas.d a1, a2, (a1) # CHECK: :[[@LINE]]:10: error: The destination register must be even. | ||
amocas.d a0, a1, (a1) # CHECK: :[[@LINE]]:14: error: The source register must be even. | ||
amocas.d.aq a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even. | ||
amocas.d.aq a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even. | ||
amocas.d.rl a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even. | ||
amocas.d.rl a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even. | ||
amocas.d.aqrl a1, a2, (a1) # CHECK: :[[@LINE]]:15: error: The destination register must be even. | ||
amocas.d.aqrl a0, a1, (a1) # CHECK: :[[@LINE]]:19: error: The source register must be even. | ||
|
||
# amocas.q is not supported for RV32. | ||
amocas.q a1, a1, (a1) # CHECK: :[[@LINE]]:1: error: instruction requires the following: RV64I Base Instruction Set{{$}} |
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,64 @@ | ||
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zacas -riscv-no-aliases -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zacas -riscv-no-aliases -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zacas < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zacas -M no-aliases -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zacas < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zacas -M no-aliases -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
# RUN: not llvm-mc -triple=riscv32 -mattr=+a -show-encoding %s 2>&1 \ | ||
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
# RUN: not llvm-mc -triple=riscv64 -mattr=+a -show-encoding %s 2>&1 \ | ||
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
||
# CHECK-ASM-AND-OBJ: amocas.w a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xa5,0xd7,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w a1, a3, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.w a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xa5,0xd7,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w a1, a3, 0(a5) | ||
# CHECK-ASM-AND-OBJ: amocas.w zero, zero, (a5) | ||
# CHECK-ASM: encoding: [0x2f,0xa0,0x07,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w zero, zero, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.w.aq zero, zero, (a5) | ||
# CHECK-ASM: encoding: [0x2f,0xa0,0x07,0x2c] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w.aq zero, zero, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.w.rl zero, zero, (a5) | ||
# CHECK-ASM: encoding: [0x2f,0xa0,0x07,0x2a] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w.rl zero, zero, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.w.aqrl zero, zero, (a5) | ||
# CHECK-ASM: encoding: [0x2f,0xa0,0x07,0x2e] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.w.aqrl zero, zero, (a5) | ||
|
||
# CHECK-ASM-AND-OBJ: amocas.d a0, a2, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb5,0xc5,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d a0, a2, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.d a0, a2, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb5,0xc5,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d a0, a2, 0(a1) | ||
# CHECK-ASM-AND-OBJ: amocas.d zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb0,0x05,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.d.aq zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb0,0x05,0x2c] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.aq zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.d.rl zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb0,0x05,0x2a] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.rl zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.d.aqrl zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xb0,0x05,0x2e] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.aqrl zero, zero, (a1) |
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,16 @@ | ||
# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zacas < %s 2>&1 | FileCheck %s | ||
|
||
# Non-zero offsets not supported for the third operand (rs1). | ||
amocas.w a1, a3, 1(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0 | ||
amocas.d a1, a3, 2(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0 | ||
amocas.q a1, a3, 3(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0 | ||
|
||
# First and second operands (rd and rs2) of amocas.q must be even. | ||
amocas.q a1, a2, (a1) # CHECK: :[[@LINE]]:10: error: The destination register must be even. | ||
amocas.q a0, a1, (a1) # CHECK: :[[@LINE]]:14: error: The source register must be even. | ||
amocas.q.aq a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even. | ||
amocas.q.aq a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even. | ||
amocas.q.rl a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even. | ||
amocas.q.rl a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even. | ||
amocas.q.aqrl a1, a2, (a1) # CHECK: :[[@LINE]]:15: error: The destination register must be even. | ||
amocas.q.aqrl a0, a1, (a1) # CHECK: :[[@LINE]]:19: error: The source register must be even. |
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,51 @@ | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zacas -riscv-no-aliases -show-encoding \ | ||
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s | ||
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zacas < %s \ | ||
# RUN: | llvm-objdump --mattr=+experimental-zacas -M no-aliases -d -r - \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s | ||
# RUN: not llvm-mc -triple=riscv64 -mattr=+a -show-encoding %s 2>&1 \ | ||
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
||
# Odd register numbers for rd and rs2 are allowed for amocas.d on RV64. | ||
|
||
# CHECK-ASM-AND-OBJ: amocas.d a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d a1, a3, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.d.aq a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2c] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.aq a1, a3, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.d.rl a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2a] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.rl a1, a3, (a5) | ||
# CHECK-ASM-AND-OBJ: amocas.d.aqrl a1, a3, (a5) | ||
# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2e] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.d.aqrl a1, a3, (a5) | ||
|
||
# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q a0, a2, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q a0, a2, 0(a1) | ||
# CHECK-ASM-AND-OBJ: amocas.q zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x28] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.q.aq zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2c] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q.aq zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.q.rl zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2a] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q.rl zero, zero, (a1) | ||
# CHECK-ASM-AND-OBJ: amocas.q.aqrl zero, zero, (a1) | ||
# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2e] | ||
# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}} | ||
amocas.q.aqrl zero, zero, (a1) |