-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[RISCV] Add Qualcomm uC Xqcicsr (CSR) extension #117169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
92a3e2e
4e6ee07
bfcfb3c
e67ffbd
ce0bdd2
40906aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //===---------------- RISCVInstrInfoXQci.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 vendor extensions defined by QUALCOMM. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Operand and SDNode transformation definitions. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Formats | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Class Templates | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instructions | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let Predicates = [HasVendorXqcicsr, IsRV32], DecoderNamespace = "Xqcicsr" in { | ||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in { | ||
| def QC_CSRRWR : RVInstR<0b1000110, 0b000, OPC_SYSTEM, (outs GPR:$rd), | ||
| (ins GPR:$rs1, GPRNoX0:$rs2), "qc.csrrwr", | ||
| "$rd, $rs1, $rs2">; | ||
|
|
||
| def QC_CSRRWRI : RVInstRBase<0b000, OPC_SYSTEM, (outs GPR:$rd), | ||
| (ins uimm5:$imm5, GPRNoX0:$rs2), | ||
| "qc.csrrwri", "$rd, $imm5, $rs2"> { | ||
| bits<5> imm5; | ||
|
|
||
| let Inst{31-25} = {0b1000111}; | ||
| let Inst{19-15} = imm5; | ||
| } | ||
| } // hasSideEffects = 0, mayLoad = 0, mayStore = 0 | ||
| } // Predicates = [HasVendorXqcicsr, IsRV32], DecoderNamespace = "Xqcicsr" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -771,6 +771,10 @@ Error RISCVISAInfo::checkDependency() { | |
| return getIncompatibleError("xwchc", "zcb"); | ||
| } | ||
|
|
||
| if (Exts.count("xqcicsr") != 0 && (XLen != 32)) { | ||
| return getError("'xqcicsr' is only supported in 'rv32'"); | ||
|
||
| } | ||
|
|
||
| return Error::success(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Xqcicsr - Qualcomm uC CSR Extension | ||
| # RUN: not llvm-mc -triple riscv32 -mattr=+experimental-xqcicsr < %s 2>&1 \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK,CHECK-PLUS %s | ||
| # RUN: not llvm-mc -triple riscv32 -mattr=-experimental-xqcicsr < %s 2>&1 \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK,CHECK-MINUS %s | ||
|
|
||
| # CHECK: :[[@LINE+1]]:20: error: invalid operand for instruction | ||
| qc.csrrwr x10, x5, x0 | ||
|
|
||
| # CHECK: :[[@LINE+1]]:1: error: too few operands for instruction | ||
| qc.csrrwr x10, x5 | ||
|
|
||
| # CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicsr' (Qualcomm uC CSR Extension) | ||
| qc.csrrwr x10, x5, x20 | ||
|
|
||
|
|
||
| # CHECK: :[[@LINE+1]]:21: error: invalid operand for instruction | ||
| qc.csrrwri x20, 31, x0 | ||
|
|
||
| # CHECK-PLUS: :[[@LINE+1]]:17: error: immediate must be an integer in the range [0, 31] | ||
| qc.csrrwri x20, 45, x12 | ||
|
|
||
| # CHECK: :[[@LINE+1]]:1: error: too few operands for instruction | ||
| qc.csrrwri x20, 23 | ||
|
|
||
| # CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicsr' (Qualcomm uC CSR Extension) | ||
| qc.csrrwri x30, 31, x12 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Xqcicsr - Qualcomm uC CSR Extension | ||
| # RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcicsr -riscv-no-aliases -show-encoding \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcicsr < %s \ | ||
| # RUN: | llvm-objdump --mattr=+experimental-xqcicsr -M no-aliases --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-INST %s | ||
| # RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcicsr -show-encoding \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcicsr < %s \ | ||
| # RUN: | llvm-objdump --mattr=+experimental-xqcicsr --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefix=CHECK-INST %s | ||
|
|
||
| # CHECK-INST: qc.csrrwr a0, t0, s4 | ||
| # CHECK-ENC: encoding: [0x73,0x85,0x42,0x8d] | ||
| qc.csrrwr x10, x5, x20 | ||
|
|
||
| # CHECK-INST: qc.csrrwri s4, 31, a2 | ||
| # CHECK-ENC: encoding: [0x73,0x8a,0xcf,0x8e] | ||
| qc.csrrwri x20, 31, x12 | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1084,6 +1084,7 @@ Experimental extensions | |
| zvkgs 0.7 | ||
| smctr 1.0 | ||
| ssctr 1.0 | ||
| xqcicsr 0.2 | ||
|
|
||
| Supported Profiles | ||
| rva20s64 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just use
RVInstRif you useuimm5:$rs1. It's whatCSR_iidoes for the standard CSR instructions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done