Skip to content

Commit 8c7a6c2

Browse files
Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser
Initial support for loongarch64-unknown-linux-gnu Hi, We hope to add a new port in rust for LoongArch. LoongArch intro LoongArch is a RISC style ISA which is independently designed by Loongson Technology in China. It is divided into two versions, the 32-bit version (LA32) and the 64-bit version (LA64). LA64 applications have application-level backward binary compatibility with LA32 applications. LoongArch is composed of a basic part (Loongson Base) and an expanded part. The expansion part includes Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX). Currently the LA464 processor core supports LoongArch ISA and the Loongson 3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit high-performance processor core. It can be used as a single core for high-end embedded and desktop applications, or as a basic processor core to form an on-chip multi-core system for server and high-performance machine applications. Documentations: ISA: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html ABI: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html More docs can be found at: https://loongson.github.io/LoongArch-Documentation/README-EN.html Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally. I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2 parents b8288e5 + 17a845b commit 8c7a6c2

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

std/src/env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ pub mod consts {
895895
/// - x86_64
896896
/// - arm
897897
/// - aarch64
898+
/// - loongarch64
898899
/// - m68k
899900
/// - mips
900901
/// - mips64

std/src/os/linux/raw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ mod arch {
231231
}
232232

233233
#[cfg(any(
234+
target_arch = "loongarch64",
234235
target_arch = "mips64",
235236
target_arch = "s390x",
236237
target_arch = "sparc64",

std/src/personality/gcc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1
7777
#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))]
7878
const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
7979

80+
#[cfg(target_arch = "loongarch64")]
81+
const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1
82+
8083
// The following code is based on GCC's C and C++ personality routines. For reference, see:
8184
// https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc
8285
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c

std/src/sys/common/alloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub const MIN_ALIGN: usize = 8;
2222
#[cfg(any(
2323
target_arch = "x86_64",
2424
target_arch = "aarch64",
25+
target_arch = "loongarch64",
2526
target_arch = "mips64",
2627
target_arch = "s390x",
2728
target_arch = "sparc64",

unwind/src/libunwind.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub const unwinder_private_data_size: usize = 20;
7575
#[cfg(all(target_arch = "hexagon", target_os = "linux"))]
7676
pub const unwinder_private_data_size: usize = 35;
7777

78+
#[cfg(target_arch = "loongarch64")]
79+
pub const unwinder_private_data_size: usize = 2;
80+
7881
#[repr(C)]
7982
pub struct _Unwind_Exception {
8083
pub exception_class: _Unwind_Exception_Class,

0 commit comments

Comments
 (0)