-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV][MC] Add MC support of Zibi experimental extension #127463
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3321010
[RISCV][MC] Add MC support of Zibi experimental extension
BoyaoWang430 5196dd3
Format adjustment and some bugfix
BoyaoWang430 a0678ff
Some format adjustment
BoyaoWang430 c72b686
Update zibi release specification
BoyaoWang430 3b086c3
change uimm5_zibi to imm5_zibi
BoyaoWang430 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
| //===-- RISCVInstrInfoZibi.td - 'Zibi' instructions --------*- 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 for 'Zibi' (branch with imm). | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // A 5-bit unsigned immediate representing 1-31 and -1. 00000 represents -1. | ||
wangpc-pp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def uimm5_zibi : RISCVOp<XLenVT>, ImmLeaf<XLenVT, [{ | ||
BoyaoWang430 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return (Imm != 0 && isUInt<5>(Imm)) || Imm == -1; | ||
| }]> { | ||
| let ParserMatchClass = UImmAsmOperand<5, "Zibi">; | ||
| let EncoderMethod = "getImmOpValueZibi"; | ||
| let DecoderMethod = "decodeUImmZibiOperand"; | ||
| let MCOperandPredicate = [{ | ||
| int64_t Imm; | ||
| if (!MCOp.evaluateAsConstantImm(Imm)) | ||
| return false; | ||
| return (Imm >= 1 && Imm <= 31) || Imm == -1; | ||
| }]; | ||
| let OperandType = "OPERAND_UIMM5_ZIBI"; | ||
| } | ||
|
|
||
| class Branch_imm<bits<3> funct3, string opcodestr> | ||
| : RVInstBIMM<funct3, OPC_BRANCH, (outs), | ||
| (ins GPR:$rs1, uimm5_zibi:$cimm, bare_simm13_lsb0:$imm12), | ||
| opcodestr, "$rs1, $cimm, $imm12">, | ||
| Sched<[WriteJmp, ReadJmp]> { | ||
| let isBranch = 1; | ||
| let isTerminator = 1; | ||
| let hasSideEffects = 0; | ||
| let mayLoad = 0; | ||
| let mayStore = 0; | ||
| } | ||
|
|
||
| let Predicates = [HasStdExtZibi] in { | ||
wangpc-pp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def BEQI : Branch_imm<0b010, "beqi">; | ||
| def BNEI : Branch_imm<0b011, "bnei">; | ||
| } // Predicates = [HasStdExtZibi] | ||
wangpc-pp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| # RUN: not llvm-mc -triple=riscv32 --mattr=+experimental-zibi %s 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
| # RUN: not llvm-mc -triple=riscv64 --mattr=+experimental-zibi %s 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
| beqi a0, 0x0, 0x400 | ||
| # CHECK-ERROR: [[@LINE-1]]:10: error: immediate must be non-zero in the range [-1, 31] | ||
| # CHECK-ERROR-LABEL: beqi a0, 0x0, 0x400 | ||
| beqi a0, 0x21, 0x400 | ||
| # CHECK-ERROR: [[@LINE-1]]:10: error: immediate must be non-zero in the range [-1, 31] | ||
| # CHECK-ERROR-LABEL: beqi a0, 0x21, 0x400 | ||
| beqi a2, 0x10, -0x1f000 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: beqi a2, 0x10, -0x1f000 | ||
| beqi a2, 0x10, 0x1000 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: beqi a2, 0x10, 0x1000 | ||
| beqi a2, 0x10, 0x111 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: beqi a2, 0x10, 0x111 | ||
| bnei a0, 0x0, 0x400 | ||
| # CHECK-ERROR: [[@LINE-1]]:10: error: immediate must be non-zero in the range [-1, 31] | ||
| # CHECK-ERROR-LABEL: bnei a0, 0x0, 0x400 | ||
| bnei a0, 0x21, 0x400 | ||
| # CHECK-ERROR: [[@LINE-1]]:10: error: immediate must be non-zero in the range [-1, 31] | ||
| # CHECK-ERROR-LABEL: bnei a0, 0x21, 0x400 | ||
| bnei a2, 0x10, -0x1f000 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: bnei a2, 0x10, -0x1f000 | ||
| bnei a2, 0x10, 0x1000 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: bnei a2, 0x10, 0x1000 | ||
| bnei a2, 0x10, 0x111 | ||
| # CHECK-ERROR: [[@LINE-1]]:16: error: immediate must be a multiple of 2 bytes in the range [-4096, 4094] | ||
| # CHECK-ERROR-LABEL: bnei a2, 0x10, 0x111 | ||
BoyaoWang430 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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,63 @@ | ||
| # RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zibi %s \ | ||
| # RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-ASM | ||
| # RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zibi %s \ | ||
| # RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-ASM | ||
| # RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
| # RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-ERROR | ||
| # RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zibi %s \ | ||
| # RUN: | llvm-objdump -d --mattr=+experimental-zibi --no-print-imm-hex - \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-OBJ | ||
| # RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zibi %s \ | ||
| # RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN | ||
| # RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zibi %s \ | ||
| # RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN | ||
| beqi a0, 1, 1024 | ||
| # CHECK-OBJ: beqi a0, 1, 0x400 | ||
| # CHECK-ASM: beqi a0, 1, 1024 | ||
| # CHECK-ENCODING: [0x63,0x20,0x15,0x40] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 40152063 <unknown> | ||
| beqi a5, -1, -1024 | ||
| # CHECK-OBJ: beqi a5, -1, 0xfffffc04 | ||
| # CHECK-ASM: beqi a5, -1, -1024 | ||
| # CHECK-ENCODING: [0xe3,0xa0,0x07,0xc0] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: c007a0e3 <unknown> | ||
| beqi s0, 22, 0xffe | ||
| # CHECK-OBJ: beqi s0, 22, 0x1006 | ||
| # CHECK-ASM: beqi s0, 22, 4094 | ||
| # CHECK-ENCODING: [0xe3,0x2f,0x64,0x7f] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 7f642fe3 <unknown> | ||
| beqi s1, 11, -4096 | ||
| # CHECK-OBJ: beqi s1, 11, 0xfffff00c | ||
| # CHECK-ASM: beqi s1, 11, -4096 | ||
| # CHECK-ENCODING: [0x63,0xa0,0xb4,0x80] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 80b4a063 <unknown> | ||
| bnei a0, 1, 1024 | ||
| # CHECK-OBJ: bnei a0, 1, 0x410 | ||
| # CHECK-ASM: bnei a0, 1, 1024 | ||
| # CHECK-ENCODING: [0x63,0x30,0x15,0x40] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 40153063 <unknown> | ||
| bnei a5, -1, -1024 | ||
| # CHECK-OBJ: bnei a5, -1, 0xfffffc14 | ||
| # CHECK-ASM: bnei a5, -1, -1024 | ||
| # CHECK-ENCODING: [0xe3,0xb0,0x07,0xc0] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: c007b0e3 <unknown> | ||
| bnei s0, 22, 0xffe | ||
| # CHECK-OBJ: bnei s0, 22, 0x1016 | ||
| # CHECK-ASM: bnei s0, 22, 4094 | ||
| # CHECK-ENCODING: [0xe3,0x3f,0x64,0x7f] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 7f643fe3 <unknown> | ||
| bnei s1, 11, -4096 | ||
| # CHECK-OBJ: bnei s1, 11, 0xfffff01c | ||
| # CHECK-ASM: bnei s1, 11, -4096 | ||
| # CHECK-ENCODING: [0x63,0xb0,0xb4,0x80] | ||
| # CHECK-ERROR: instruction requires the following: 'Zibi' (Branch with Immediate){{$}} | ||
| # CHECK-UNKNOWN: 80b4b063 <unknown> |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.