-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
loongarch: Scaffold self-hosted LoongArch backend #24182
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
base: master
Are you sure you want to change the base?
Conversation
It is a weird AIR construction. I am just doing what the x86-64 backend is doing.
@@ -0,0 +1,790 @@ | |||
//! Inline assembly parser for LoongArch. |
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.
Also should rename this directory.
@@ -91,6 +94,7 @@ pub fn legalizeFeatures(pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) ?*co | |||
pub const AnyMir = union { | |||
aarch64: @import("arch/aarch64/Mir.zig"), | |||
arm: @import("arch/arm/Mir.zig"), | |||
loongarch64: @import("arch/loongarch64/Mir.zig"), |
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.
loongarch64: @import("arch/loongarch64/Mir.zig"), | |
loongarch: @import("arch/loongarch/Mir.zig"), |
@@ -102,6 +106,7 @@ pub const AnyMir = union { | |||
return switch (backend) { | |||
.stage2_aarch64 => "aarch64", | |||
.stage2_arm => "arm", | |||
.stage2_loongarch => "loongarch64", |
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.
.stage2_loongarch => "loongarch64", | |
.stage2_loongarch => "loongarch", |
@@ -44,6 +44,10 @@ pub const Env = enum { | |||
/// - `zig build-* -fno-llvm -fno-lld -target wasm32-* --listen=-` | |||
wasm, | |||
|
|||
/// - sema | |||
/// - `zig build-* -fincremental -fno-llvm -fno-lld -target loongarch64-linux --listen=-` |
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.
/// - `zig build-* -fincremental -fno-llvm -fno-lld -target loongarch64-linux --listen=-` | |
/// - `zig build-* -fincremental -fno-llvm -fno-lld -target loongarch(32,64)-linux --listen=-` |
@@ -0,0 +1,514 @@ | |||
const std = @import("std"); |
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.
Is this tool 64-bit only?
@@ -4128,7 +4128,7 @@ pub fn getTarget(self: Elf) std.Target { | |||
fn requiresThunks(self: Elf) bool { | |||
return switch (self.getTarget().cpu.arch) { | |||
.aarch64 => true, | |||
.x86_64, .riscv64 => false, | |||
.x86_64, .riscv64, .loongarch64 => false, |
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.
Worth checking if all the added linker code is actually 64-bit only; I suspect not?
No, it also generates encoders for LA32(S/R). Thank you for looking into this PR. I will rename this file next weekend as soon as I am available.
|
cc @jacobly0 to review the general structure of the new backend. |
You might want to |
This PR adds a self-hosted LoongArch64 backend.
The backend currently implements only a few features.
Test runner is working, but due to the very limited number of passing behavior tests, the backend is not added to the test target list.
Although it is foreseeable that I will not have much time to work on this backend in the coming one year due to my study, I will try to keep the backend working and expand its features.