authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-09 16:48:02+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-09 16:48:02+01:00
logafd491c07e7b69b0bdeaa2304c71e87b66a8a64a
tree21867f5291a7286f4308607ed4fae507253d0d19
parent518168edb2378039ba5c058c6e71ea4bc12d704b

compiler-rt: Fix compilation of clzsi for armv6 targets


1 files changed, 9 insertions(+), 13 deletions(-)

lib/std/special/compiler_rt/clzsi2.zig+9-13
......@@ -3,7 +3,8 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6const builtin = @import("builtin");
6const std = @import("std");
7const builtin = std.builtin;
78
89fn __clzsi2_generic(a: i32) callconv(.C) i32 {
910 @setRuntimeSafety(builtin.is_test);
......@@ -25,8 +26,6 @@ fn __clzsi2_generic(a: i32) callconv(.C) i32 {
2526}
2627
2728fn __clzsi2_thumb1() callconv(.Naked) void {
28 @setRuntimeSafety(builtin.is_test);
29
3029 // Similar to the generic version with the last two rounds replaced by a LUT
3130 asm volatile (
3231 \\ movs r1, #32
......@@ -59,8 +58,6 @@ fn __clzsi2_thumb1() callconv(.Naked) void {
5958}
6059
6160fn __clzsi2_arm32() callconv(.Naked) void {
62 @setRuntimeSafety(builtin.is_test);
63
6461 asm volatile (
6562 \\ // Assumption: n != 0
6663 \\ // r0: n
......@@ -107,14 +104,13 @@ fn __clzsi2_arm32() callconv(.Naked) void {
107104 unreachable;
108105}
109106
110pub const __clzsi2 = blk: {
111 if (builtin.arch.isARM()) {
112 break :blk __clzsi2_arm32;
113 } else if (builtin.arch.isThumb()) {
114 break :blk __clzsi2_thumb1;
115 } else {
116 break :blk __clzsi2_generic;
117 }
107pub const __clzsi2 = switch (std.Target.current.cpu.arch) {
108 .arm, .armeb => if (std.Target.arm.featureSetHas(std.Target.current.cpu.features, .noarm))
109 __clzsi2_thumb1
110 else
111 __clzsi2_arm32,
112 .thumb, .thumbeb => __clzsi2_thumb1,
113 else => __clzsi2_generic,
118114};
119115
120116test "test clzsi2" {