mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Merge pull request #21715 from alexrp/loongarch-porting
Some miscellaneous LoongArch port work
This commit is contained in:
commit
bdd3bc056e
@ -28,8 +28,10 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
|
||||
.aarch64, .aarch64_be => true,
|
||||
else => false,
|
||||
};
|
||||
const loongarch64 = switch (arch) {
|
||||
.loongarch64 => true,
|
||||
const loongarch = switch (arch) {
|
||||
.loongarch32,
|
||||
.loongarch64,
|
||||
=> true,
|
||||
else => false,
|
||||
};
|
||||
const mips = switch (arch) {
|
||||
@ -163,7 +165,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
|
||||
// On Darwin, sys_icache_invalidate() provides this functionality
|
||||
sys_icache_invalidate(start, end - start);
|
||||
exportIt();
|
||||
} else if (os == .linux and loongarch64) {
|
||||
} else if (os == .linux and loongarch) {
|
||||
// See: https://github.com/llvm/llvm-project/blob/cf54cae26b65fc3201eff7200ffb9b0c9e8f9a13/compiler-rt/lib/builtins/clear_cache.c#L94-L95
|
||||
asm volatile (
|
||||
\\ ibar 0
|
||||
|
||||
@ -2711,7 +2711,6 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
|
||||
.csky,
|
||||
.x86,
|
||||
.xcore,
|
||||
.loongarch32,
|
||||
.kalimba,
|
||||
.spu_2,
|
||||
.xtensa,
|
||||
@ -2735,6 +2734,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
|
||||
|
||||
.aarch64,
|
||||
.aarch64_be,
|
||||
.loongarch32,
|
||||
.loongarch64,
|
||||
.mips64,
|
||||
.mips64el,
|
||||
@ -2815,7 +2815,6 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
|
||||
|
||||
.csky,
|
||||
.xcore,
|
||||
.loongarch32,
|
||||
.kalimba,
|
||||
.spu_2,
|
||||
.xtensa,
|
||||
@ -2845,6 +2844,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
|
||||
|
||||
.aarch64,
|
||||
.aarch64_be,
|
||||
.loongarch32,
|
||||
.loongarch64,
|
||||
.mips64,
|
||||
.mips64el,
|
||||
|
||||
@ -1338,7 +1338,7 @@ const LinuxThreadImpl = struct {
|
||||
[len] "r" (self.mapped.len),
|
||||
: "memory"
|
||||
),
|
||||
.loongarch64 => asm volatile (
|
||||
.loongarch32, .loongarch64 => asm volatile (
|
||||
\\ or $a0, $zero, %[ptr]
|
||||
\\ or $a1, $zero, %[len]
|
||||
\\ ori $a7, $zero, 215 # SYS_munmap
|
||||
|
||||
@ -520,6 +520,7 @@ const DataLayoutBuilder = struct {
|
||||
.arm,
|
||||
.armeb,
|
||||
.csky,
|
||||
.loongarch32,
|
||||
.mips,
|
||||
.mipsel,
|
||||
.powerpc,
|
||||
@ -535,6 +536,7 @@ const DataLayoutBuilder = struct {
|
||||
.amdgcn,
|
||||
.bpfeb,
|
||||
.bpfel,
|
||||
.loongarch64,
|
||||
.mips64,
|
||||
.mips64el,
|
||||
.powerpc64,
|
||||
@ -554,7 +556,6 @@ const DataLayoutBuilder = struct {
|
||||
.nvptx64,
|
||||
=> &.{ 16, 32, 64 },
|
||||
.x86_64 => &.{ 8, 16, 32, 64 },
|
||||
.loongarch64 => &.{64},
|
||||
else => &.{},
|
||||
}), 0..) |natural, index| switch (index) {
|
||||
0 => try writer.print("-n{d}", .{natural}),
|
||||
@ -12452,6 +12453,9 @@ fn backendSupportsF80(target: std.Target) bool {
|
||||
/// if it produces miscompilations.
|
||||
fn backendSupportsF16(target: std.Target) bool {
|
||||
return switch (target.cpu.arch) {
|
||||
// LoongArch can be removed from this list with LLVM 20.
|
||||
.loongarch32,
|
||||
.loongarch64,
|
||||
.hexagon,
|
||||
.powerpc,
|
||||
.powerpcle,
|
||||
|
||||
@ -108,10 +108,6 @@ const targets = [_]std.Target.Query{
|
||||
.{ .cpu_arch = .lanai, .os_tag = .freestanding, .abi = .none },
|
||||
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .freestanding, .abi = .none },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .gnu },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .gnuf32 },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .gnusf },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .musl },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .none },
|
||||
.{ .cpu_arch = .loongarch32, .os_tag = .uefi, .abi = .none },
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user