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

research: update LLVM x86 compiler and JIT #452

Merged
merged 1 commit into from
Aug 3, 2024
Merged

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented Aug 2, 2024

This updates the research on adding an x86 backend to our LLVM bindings following #402.

Furthermore this tests whether it's possible to create pure assembly .S files without Nim so that:

  • It's easier to integrate in C/Rust/Go as we remove the Nim toolchain
  • It's possible to reduce generate all code in the same LLVM module to ensure inter-procedural optimization, constant inlining and deduplication.
  • We don't depend on GCC codegen quality which is bad for big integers/cryptography

Unfortunately there is a showstopper:

  • We cannot use inline assembly and so ADOX/ADCX to print assembly

And a couple of annoying part:

  • If we fix the showstopper, we need to be able to clear the eflags (carry, overflow, sign, zero, ...)
    This is usually done by xor but it will be optimized away by the compiler
  • We need to ensure the compiler does not reorder in between add-with-carry operations or accidentally clear the carry flag, for example when we add with 0 for the final carries.
  • We need to be able to rotate buffers.
  • Despite using bmi2, LLVM does not seem to generate mulx instruction.

How to fix the showstopper?

  • We can compile the module then use LLVM disassembler.

For all other arch, we should have better luck as ADCX/ADOX should be the only instructions requiring inline assembly
or they support inline assembly in their ASM printer (GPU Virtual ISAs like Nvidia PTX).

@mratsim
Copy link
Owner Author

mratsim commented Aug 3, 2024

PR failing because the branch is missing #449

@mratsim mratsim merged commit cfe077b into master Aug 3, 2024
22 of 24 checks passed
@mratsim mratsim deleted the llvm-x86-research branch August 3, 2024 05:16
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.

1 participant