Skip to content
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

Add inline assembler tests for i386, arm, arm64, riscv32 and riscv64 #24564

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

demotomohiro
Copy link
Contributor

This fixes one error in #24544 .
I tested this on Raspberry Pi Pico (arm) and Raspberry Pi 3(arm64).
It is not tested on i386, riscv32 and riscv64 CPU.

Copy link
Member

@ringabout ringabout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by GitHub copilot

To verify the correctness of the assembly code, we need to check each architecture-specific block for proper syntax and logic. Here's a breakdown of the provided code:

x86 (i386 and amd64)

asm """
  mov %1, %0\n\t
  add $1, %0
  : "=r" (`dst`)
  : "r" (`src`)"""
  • mov %1, %0 moves the value of src into dst.
  • add $1, %0 increments dst by 1.

ARM (arm and arm64)

asm """
  mov %0, %1\n\t
  add %0, %0, #1
  : "=r" (`dst`)
  : "r" (`src`)"""
  • mov %0, %1 moves the value of src into dst.
  • add %0, %0, #1 increments dst by 1.

RISC-V (riscv32 and riscv64)

asm """
  addi %0, %1, 0\n\t
  addi %0, %0, 1
  : "=r" (`dst`)
  : "r" (`src)"""
  • addi %0, %1, 0 moves the value of src into dst.
  • addi %0, %0, 1 increments dst by 1.

Summary

The provided assembly code seems correct for each architecture. The logic is consistent across different architectures:

  • Move the value of src into dst.
  • Increment dst by 1.

If you need further verification, running tests on actual hardware or using an emulator for each architecture would be ideal.

@ringabout ringabout merged commit fc80671 into nim-lang:devel Dec 24, 2024
15 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from fc80671

Hint: mm: orc; opt: speed; options: -d:release
178143 lines; 8.938s; 653.859MiB peakmem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants