Open jjscheel opened 1 year ago
Update : I am currently working on ACT for Zcmp and Zcmt .
While running the test I am encounter this assembler error which is saying "Zcm* is not compatible with C extension" . I have raised the same issue in arch-test repo (riscv-non-isa/riscv-arch-test#543) in which allen suggested to include c in ISA ( RV32ICZicsr_Zca_Zcmp ) , but even after that the error was not resolved .
I asked tariq sir also about this error , to which sir suggested it might be toolchain bug.
@pz9115 sir can you please help me here . I have attched ss of the error Image
@JAYANTH-IITM I think this is cause by the toolchain version issue, we'd better update both gcc
and binutils
to the latest upstream line.
There is no release version of riscv-gnu-toolchain yet, which means we need to build it manually, here is the steps:
First, use git clone get the riscv-gnu-toolchain
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
Then we need to prepare the environment, On Ubuntu, executing the following command should suffice:
$ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
The next step, go into subdir gcc
and binutils
, update the code to the upstream version:
cd gcc
git fetch origin
git checkout origin/trunk
cd ../binutils
git fetch origin
git checkout origin/trunk
After this, we need to set the toolchain installation directory(in --prefix=
, like /opt/riscv) and build it(the time cost based on your CPU performance, usually it takes about half an hour)
./configure --prefix=/opt/riscv --with-arch=rv32ic_zicsr_zca_zcmp --with-abi=ilp32
make -j$(nproc)
If you meet any problems in toolchain, please feel free to ask me at anytime.
Thank you sir . will update the toolchain and redo the tests .
Hi @pz9115 , I need both zcmp and zcmt , so in arch do use (-with-arch=rv32ic_zicsr_zca_zcmp_zcmt ) , or do i need to do it separately ( one with _zcmp and another with _zcmt )
Hi @pz9115 , I need both zcmp and zcmt , so in arch do use (-with-arch=rv32ic_zicsr_zca_zcmp_zcmt ) , or do i need to do it separately ( one with _zcmp and another with _zcmt )
Hi @JAYANTH-IITM ,it needs to use the first form I think(-with-arch=rv32ic_zicsr_zca_zcmp_zcmt), but currently zcmt haven't merged in upstream yet,. It means that you need to apply the zcmt patch into binutils and then re-build the toolchain, the patch link is
https://patchwork.sourceware.org/project/binutils/patch/20241029124423.734275-1-jiawei@iscas.ac.cn/
you can click theright up
botton mobox
to download it, and deploy it using git in the binutils repository.
""" git am v5-RISC-V-Add-Zcmt-instructions-and-csr..patch """
Hi @pz9115 , I tried to apply the patch for zcmt , but i am encountering this error
" Applying: RISC-V: Add Zcmt instructions and csr. error: patch failed: gas/config/tc-riscv.c:3922 error: gas/config/tc-riscv.c: patch does not apply error: patch failed: include/opcode/riscv-opc.h:2305 error: include/opcode/riscv-opc.h: patch does not apply error: patch failed: opcodes/riscv-opc.c:362 error: opcodes/riscv-opc.c: patch does not apply Patch failed at 0001 RISC-V: Add Zcmt instructions and csr. " . I am not sure how to proceed after this . Can you please help here
Hi @pz9115 , I tried to apply the patch for zcmt , but i am encountering this error
" Applying: RISC-V: Add Zcmt instructions and csr. error: patch failed: gas/config/tc-riscv.c:3922 error: gas/config/tc-riscv.c: patch does not apply error: patch failed: include/opcode/riscv-opc.h:2305 error: include/opcode/riscv-opc.h: patch does not apply error: patch failed: opcodes/riscv-opc.c:362 error: opcodes/riscv-opc.c: patch does not apply Patch failed at 0001 RISC-V: Add Zcmt instructions and csr. " . I am not sure how to proceed after this . Can you please help here
I think this is caused by binutils submodule not updated correctly, please checkout the binutils into the latest master branch, https://sourceware.org/git/?p=binutils-gdb.git;a=summary
Toolchain working fine @pz9115 . Thank you !
@pz9115 @tariqkurd-repo , for the instruction cm.popret and cm.popretz it is working only for imm_val (spimm) 0 , for imm_val 1 , 2 and 3 it is not working. But cm.push and cm.pop is working fine . Can you please guide here .
@allenjbaum , the test macro that I written for zcmp and zcmt does not append any signature ( but i am able get the expected coverage for all instruction as expected , expect for the above case ) . attached the test_macro for reference 1) do i need to append signature ? 2) what is the expected signature ? can you please help here test_macros.zip
sorry , closed by mistake
@pz9115 @tariqkurd-repo , for the instruction cm.popret and cm.popretz it is working only for imm_val (spimm) 0 , for imm_val 1 , 2 and 3 it is not working. But cm.push and cm.pop is working fine . Can you please guide here .
I tested with a simple example
spimm.s
and it works finetarget: cm.popret {ra}, 16 cm.popret {ra}, 32 cm.popret {ra}, 48 cm.popret {ra}, 64 cm.popretz {ra}, 16 cm.popretz {ra}, 32 cm.popretz {ra}, 48 cm.popretz {ra}, 64
/opt/riscv/bin/riscv64-unknown-elf-as -march=rv32ima_zcmp -mabi=ilp32 spimm.s -o spimm.o /opt/riscv/bin/riscv64-unknown-elf-objdump -d spimm.o
spimm.o: file format elf32-littleriscv
Disassembly of section .text:
00000000
The `stack_adj` (16|32|48|64) corresponding to the `stack_adj_base + 16 * spimm`. In this example, the `ra` set the adj_base equal 16, and when spimm pass form 0~3, total `stack_adj` comes into (16|32|48|64). It has the same behaviour with `cm.pop` as expected.
Could you give more detail about this error, thanks.
> @allenjbaum , the test macro that I written for zcmp and zcmt does not append any signature ( but i am able get the expected coverage for all instruction as expected , expect for the above case ) . attached the test_macro for reference
>
> 1. do i need to append signature ?
> 2. what is the expected signature ? can you please help here [test_macros.zip](https://github.com/user-attachments/files/17657609/test_macros.zip)
>
> sorry , closed by mistake
.section .text
.global _start
_start:
cm.popret {ra}, 16
cm.popret {ra,s0}, 16
cm.popret {ra,s0-s1}, 16
cm.popret {ra,s0-s2}, 16
when i try to execute this i am encountering ( I tried the same by using x register , but the same ) inside of using (ra , s0-s1) if (ra,s0,s1) is used it working ( which does not match with the spec )
$ riscv64-unknown-elf-as -march=rv64imac_zcmp -o test.o spimm.s
spimm.s: Assembler messages:
spimm.s:7: Error: illegal operands `cm.popret {ra,s0-s1},16'
spimm.s:8: Error: illegal operands `cm.popret {ra,s0-s2},16'
.section .text .global _start _start: cm.popret {ra}, 16 cm.popret {ra,s0}, 16 cm.popret {ra,s0-s1}, 16 cm.popret {ra,s0-s2}, 16
when i try to execute this i am encountering ( I tried the same by using x register , but the same ) inside of using (ra , s0-s1) if (ra,s0,s1) is used it working ( which does not match with the spec )
$ riscv64-unknown-elf-as -march=rv64imac_zcmp -o test.o spimm.s spimm.s: Assembler messages: spimm.s:7: Error: illegal operands `cm.popret {ra,s0-s1},16' spimm.s:8: Error: illegal operands `cm.popret {ra,s0-s2},16'
Let me explain why it's wrong here, in Zcmp, the base of stack_adj
will change when using more S-registers as the arguments.
You can find the stack_adj
setting in https://github.com/riscvarchive/riscv-code-size-reduction/blob/main/Zc-specification/pushpop_vars.adoc
Using -march=rv64imac_zcmp
to compile cm.popret {ra,s0-s1}
will match to the case 6
in RV64, sets the stack_adj_base
equal to 32, so it should to use cm.popret {ra,s0-s1},32
in this case.
Updates from IIT-M , 1) Tests for Zcmp and Zcmt are complete . Not getting expected coverage in cm.popret and cm.popretz . Other than these two , getting expected coverage in all other test.
reg : expected signature for zmp and zcmt test, need some guidance here @allenjbaum
I think you need to describe in a bit more detail the coverage you expect, and the coverage that is missing. (and I need to re-read the spec for those.)
On Tue, Nov 12, 2024 at 1:21 AM JAYANTH-IITM @.***> wrote:
Updates from IIT-M ,
- Tests for Zcmp and Zcmt are complete . Not getting expected coverage in cm.popret and cm.popretz . Other than these two , getting expected coverage in all other test.
reg : expected signature for zmp and zcmt test, need some guidance here @allenjbaum https://github.com/allenjbaum
— Reply to this email directly, view it on GitHub https://github.com/riscv-admin/dev-partners/issues/6#issuecomment-2469856030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPXVJS7T4IZ4RQDDVDIM7L2AHCDNAVCNFSM6AAAAAAV5WEWZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRZHA2TMMBTGA . You are receiving this because you were mentioned.Message ID: @.***>
Technical Group
Code Size Reduction TG
ratification-pkg
Code Size
Technical Liaison
Tariq Kurd
Task Category
Arch Tests
Task Sub Category
Ratification Target
1Q2023
Statement of Work (SOW)
SOW link
SOW Signoffs: (delete those not needed)
Waiver
Pull Request Details
No response