authorgravatar for jan.hafer@rwth-aachen.deJan Philipp Hafer <jan.hafer@rwth-aachen.de> 2023-04-26 01:42:13+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-26 15:32:05-07:00
logf618398b24acdc3317e6fd81f486d49176ffcef9
treef54936ea0a4d169cb95008c139bbdbdf7139d0c9
parent66da64d77c377a3e77e66bea192c39482d9bcda7

compiler_rt: document ARM status

This commit documents the status of Run-time ABI 2022Q3 for ARM excluding C++ helper functions.

2 files changed, 93 insertions(+), 4 deletions(-)

lib/compiler_rt/README.md+83-3
......@@ -72,9 +72,11 @@ Integer and Float Operations
7272| | | | | | **Integer Comparison** |
7373| ✓ | __cmpsi2 | i32 | i32 | i32 | `(a<b) -> 0, (a==b) -> 1, (a>b) -> 2` |
7474| ✓ | __cmpdi2 | i64 | i64 | i32 | .. |
75| ✗ | __aeabi_lcmp | i64 | i64 | i32 | .. ARM |
7576| ✓ | __cmpti2 | i128 | i128 | i32 | .. |
7677| ✓ | __ucmpsi2 | u32 | u32 | i32 | `(a<b) -> 0, (a==b) -> 1, (a>b) -> 2` |
7778| ✓ | __ucmpdi2 | u64 | u64 | i32 | .. |
79| ✗ | __aeabi_ulcmp | u64 | u64 | i32 | .. ARM |
7880| ✓ | __ucmpti2 | u128 | u128 | i32 | .. |
7981| | | | | | **Integer Arithmetic** |
8082| ✓ | __ashlsi3 | i32 | i32 | i32 | `a << b` [^unused_rl78] |
......@@ -94,6 +96,7 @@ Integer and Float Operations
9496| ✓ | __negti2 | i128 | i128 | i128 | .. |
9597| ✓ | __mulsi3 | i32 | i32 | i32 | `a * b` |
9698| ✓ | __muldi3 | i64 | i64 | i64 | .. |
99| ✓ | __aeabi_lmul | i64 | i64 | i64 | .. ARM |
97100| ✓ | __multi3 | i128 | i128 | i128 | .. |
98101| ✓ | __divsi3 | i32 | i32 | i32 | `a / b` |
99102| ✓ | __divdi3 | i64 | i64 | i64 | .. |
......@@ -110,10 +113,14 @@ Integer and Float Operations
110113| ✓ | __umoddi3 | u64 | u64 | u64 | .. |
111114| ✓ | __umodti3 | u128 | u128 | u128 | .. |
112115| ✓ | __udivmodsi4 | u32 | u32 | u32 | `a / b, rem.* = a % b` |
116| ✓ | __aeabi_uidivmod | u32 | u32 | u32 | .. ARM |
113117| ✓ | __udivmoddi4 | u64 | u64 | u64 | .. |
118| ✓ | __aeabi_uldivmod | u64 | u64 | u64 | .. ARM |
114119| ✓ | __udivmodti4 | u128 | u128 | u128 | .. |
115120| ✓ | __divmodsi4 | i32 | i32 | i32 | `a / b, rem.* = a % b` |
121| ✓ | __aeabi_idivmod | i32 | i32 | i32 | .. ARM |
116122| ✓ | __divmoddi4 | i64 | i64 | i64 | .. |
123| ✓ | __aeabi_ldivmod | i64 | i64 | i64 | .. ARM |
117124| ✓ | __divmodti4 | i128 | i128 | i128 | .. [^libgcc_compat] |
118125| | | | | | **Integer Arithmetic with Trapping Overflow**|
119126| ✓ | __absvsi2 | i32 | i32 | i32 | abs(a) |
......@@ -142,11 +149,16 @@ Integer and Float Operations
142149| ✓ | __mulodi4 | i64 | i64 | i64 | .. |
143150| ✓ | __muloti4 | i128 | i128 | i128 | .. |
144151| | | | | | **Float Conversion** |
152| ✓ | __extendhfdf2 | f16 | ∅ | f32 | .. |
145153| ✓ | __extendsfdf2 | f32 | ∅ | f64 | .. |
154| ✓ | __aeabi_f2d | f32 | ∅ | f64 | .. |
146155| ✓ | __extendsftf2 | f32 | ∅ | f128 | .. |
147156| ✓ | __extendsfxf2 | f32 | ∅ | f80 | .. |
148157| ✓ | __extenddftf2 | f64 | ∅ | f128 | .. |
149158| ✓ | __extenddfxf2 | f64 | ∅ | f80 | .. |
159| ✗ | __aeabi_h2f | f16 | ∅ | f32 | .. ARM |
160| ✗ | __aeabi_h2f_alt | f16 | ∅ | f32 | .. ARM alternate [^VFPv3alt] |
161| ✓ | __gnu_h2f_ieee | f16 | ∅ | f32 | .. GNU naming convention |
150162| ✓ | __truncsfhf2 | f32 | ∅ | f16 | rounding towards zero |
151163| ✓ | __truncdfhf2 | f64 | ∅ | f16 | .. |
152164| ✓ | __truncdfsf2 | f64 | ∅ | f32 | .. |
......@@ -157,9 +169,11 @@ Integer and Float Operations
157169| ✓ | __truncxfhf2 | f80 | ∅ | f16 | .. |
158170| ✓ | __truncxfsf2 | f80 | ∅ | f32 | .. |
159171| ✓ | __truncxfdf2 | f80 | ∅ | f64 | .. |
160| ✓ | __aeabi_f2h | f32 | ∅ | f16 | .. ARM |
161| ✓ | __gnu_f2h_ieee | f32 | ∅ | f16 | ..GNU naming convention |
172| ✗ | __aeabi_f2h | f32 | ∅ | f16 | .. ARM |
173| ✗ | __aeabi_f2h_alt | f32 | ∅ | f16 | .. ARM alternate [^VFPv3alt] |
174| ✓ | __gnu_f2h_ieee | f32 | ∅ | f16 | .. GNU naming convention |
162175| ✓ | __aeabi_d2h | f64 | ∅ | f16 | .. ARM |
176| ✗ | __aeabi_d2h_alt | f64 | ∅ | f16 | .. ARM alternate [^VFPv3alt] |
163177| ✓ | __aeabi_d2f | f64 | ∅ | f32 | .. ARM |
164178| ✓ | __trunckfsf2 | f128 | ∅ | f32 | .. PPC |
165179| ✓ | _Qp_qtos |*f128 | ∅ | f32 | .. SPARC |
......@@ -167,12 +181,16 @@ Integer and Float Operations
167181| ✓ | _Qp_qtod |*f128 | ∅ | f64 | .. SPARC |
168182| ✓ | __fixhfsi | f16 | ∅ | i32 | float to int, rounding towards zero |
169183| ✓ | __fixsfsi | f32 | ∅ | i32 | .. |
184| ✓ | __aeabi_f2iz | f32 | ∅ | i32 | .. ARM |
170185| ✓ | __fixdfsi | f64 | ∅ | i32 | .. |
186| ✓ | __aeabi_d2iz | f64 | ∅ | i32 | .. ARM |
171187| ✓ | __fixtfsi | f128 | ∅ | i32 | .. |
172188| ✓ | __fixxfsi | f80 | ∅ | i32 | .. |
173189| ✓ | __fixhfdi | f16 | ∅ | i64 | .. |
174190| ✓ | __fixsfdi | f32 | ∅ | i64 | .. |
191| ✓ | __aeabi_f2lz | f32 | ∅ | i64 | .. ARM |
175192| ✓ | __fixdfdi | f64 | ∅ | i64 | .. |
193| ✓ | __aeabi_d2lz | f64 | ∅ | i64 | .. ARM |
176194| ✓ | __fixtfdi | f128 | ∅ | i64 | .. |
177195| ✓ | __fixxfdi | f80 | ∅ | i64 | .. |
178196| ✓ | __fixhfti | f16 | ∅ | i128 | .. |
......@@ -182,12 +200,16 @@ Integer and Float Operations
182200| ✓ | __fixxfti | f80 | ∅ | i128 | .. |
183201| ✓ | __fixunshfsi | f16 | ∅ | u32 | float to uint, rounding towards zero. negative values become 0. |
184202| ✓ | __fixunssfsi | f32 | ∅ | u32 | .. |
203| ✓ | __aeabi_f2uiz | f32 | ∅ | u32 | .. ARM |
185204| ✓ | __fixunsdfsi | f64 | ∅ | u32 | .. |
205| ✓ | __aeabi_d2uiz | f64 | ∅ | u32 | .. ARM |
186206| ✓ | __fixunstfsi | f128 | ∅ | u32 | .. |
187207| ✓ | __fixunsxfsi | f80 | ∅ | u32 | .. |
188208| ✓ | __fixunshfdi | f16 | ∅ | u64 | .. |
189209| ✓ | __fixunssfdi | f32 | ∅ | u64 | .. |
210| ✓ | __aeabi_f2ulz | f32 | ∅ | u64 | .. ARM |
190211| ✓ | __fixunsdfdi | f64 | ∅ | u64 | .. |
212| ✓ | __aeabi_d2ulz | f64 | ∅ | u64 | .. ARM |
191213| ✓ | __fixunstfdi | f128 | ∅ | u64 | .. |
192214| ✓ | __fixunsxfdi | f80 | ∅ | u64 | .. |
193215| ✓ | __fixunshfti | f16 | ∅ | u128 | .. |
......@@ -197,11 +219,15 @@ Integer and Float Operations
197219| ✓ | __fixunsxfti | f80 | ∅ | u128 | .. |
198220| ✓ | __floatsihf | i32 | ∅ | f16 | int to float |
199221| ✓ | __floatsisf | i32 | ∅ | f32 | .. |
222| ✓ | __aeabi_i2f | i32 | ∅ | f32 | .. ARM |
200223| ✓ | __floatsidf | i32 | ∅ | f64 | .. |
224| ✓ | __aeabi_i2d | i32 | ∅ | f64 | .. ARM |
201225| ✓ | __floatsitf | i32 | ∅ | f128 | .. |
202226| ✓ | __floatsixf | i32 | ∅ | f80 | .. |
203227| ✓ | __floatdisf | i64 | ∅ | f32 | .. |
228| ✓ | __aeabi_l2f | i64 | ∅ | f32 | .. ARM |
204229| ✓ | __floatdidf | i64 | ∅ | f64 | .. |
230| ✓ | __aeabi_l2d | i64 | ∅ | f64 | .. ARM |
205231| ✓ | __floatditf | i64 | ∅ | f128 | .. |
206232| ✓ | __floatdixf | i64 | ∅ | f80 | .. |
207233| ✓ | __floattihf | i128 | ∅ | f16 | .. |
......@@ -211,12 +237,16 @@ Integer and Float Operations
211237| ✓ | __floattixf | i128 | ∅ | f80 | .. |
212238| ✓ | __floatunsihf | u32 | ∅ | f16 | uint to float |
213239| ✓ | __floatunsisf | u32 | ∅ | f32 | .. |
240| ✓ | __aeabi_ui2f | u32 | ∅ | f32 | .. ARM |
214241| ✓ | __floatunsidf | u32 | ∅ | f64 | .. |
242| ✓ | __aeabi_ui2d | u32 | ∅ | f64 | .. ARM |
215243| ✓ | __floatunsitf | u32 | ∅ | f128 | .. |
216244| ✓ | __floatunsixf | u32 | ∅ | f80 | .. |
217245| ✓ | __floatundihf | u64 | ∅ | f16 | .. |
218246| ✓ | __floatundisf | u64 | ∅ | f32 | .. |
247| ✓ | __aeabi_ul2f | u64 | ∅ | f32 | .. ARM |
219248| ✓ | __floatundidf | u64 | ∅ | f64 | .. |
249| ✓ | __aeabi_ul2d | u64 | ∅ | f64 | .. ARM |
220250| ✓ | __floatunditf | u64 | ∅ | f128 | .. |
221251| ✓ | __floatundixf | u64 | ∅ | f80 | .. |
222252| ✓ | __floatuntihf | u128 | ∅ | f16 | .. |
......@@ -353,6 +383,7 @@ Integer and Float Operations
353383[^noptr_faster]: Operations without pointer and without C struct semantics lead to better optimizations.
354384[^perf_addition]: Has better performance than standard method due to 2s complement semantics.
355385Not provided by LLVM and libgcc.
386[^VFPv3alt]: Converts IEEE-format to VFPv3 alternative-format.
356387
357388Decimal float library routines
358389
......@@ -712,8 +743,57 @@ TODO brief description
712743| | | | | | | |**BigInt Arithmetic which Return on Overflow**[^noptr_faster]|
713744
714745Further content (conditionally) exported with C abi:
746
747ARM-only routines
748
749| Done | Name | a | b | Out | Comment |
750| ---- | -------- | --- | --- | -----| ----------------------|
751| | | | | | **Float Comparison** |
752|✗|__aeabi_cfcmpeq | f32 | f32 | void | `a == b` result in PSR ZC flags[^PSRZC] |
753|✗|__aeabi_cfcmple | f32 | f32 | void | `a <= b` result .. |
754|✗|__aeabi_cfrcmple| f32 | f32 | void | `b <= a` .. |
755|✗|__aeabi_cdcmpeq | f64 | f64 | void | `a == b` .. |
756|✗|__aeabi_cdcmple | f64 | f64 | void | `a <= b` .. |
757|✗|__aeabi_cdrcmple| f64 | f64 | void | `b <= a` .. |
758| | | | | | **Float Arithmetic** |
759|✗|__aeabi_frsub | f64 | f64 | f64 | `b - a` |
760|✗|__aeabi_drsub | f64 | f64 | f64 | .. |
761| | | | | | **Special** |
762|✓|__aeabi_read_tp | ∅ | ∅ | *u8 | ret tls pointer |
763|✗|__aeabi_idiv0 | i32 | ∅ | i32 | div by 0 modifier |
764|✗|__aeabi_ldiv0 | i64 | ∅ | i64 | div by 0 modifier |
765| | | | | | **Unaligned memory access** |
766|✗|__aeabi_uread4 |[*]u8| ∅ | i32 | ret value read |
767|✗|__aeabi_uwrite4 | i32 |[*]u8| i32 | ret value written |
768|✗|__aeabi_uread8 |[*]u8| ∅ | i64 | .. |
769|✗|__aeabi_uwrite8 | i64 |[*]u8| i64 | .. |
770
771
772| Done | Name | a | b | c | Comment |
773| ---- | -------- | --- | --- | -----| ----------------------|
774| | | | | | **Memory copy, move and set** |
775|✓|__aeabi_memcpy8 |[*]u8|[*]u8| usize| *dest, *src, size |
776|✓|__aeabi_memcpy4 |[*]u8|[*]u8| usize| .. |
777|✓|__aeabi_memcpy |[*]u8|[*]u8| usize| .. |
778|✓|__aeabi_memmove8|[*]u8|[*]u8| usize| *dest, *src, size |
779|✓|__aeabi_memmove4|[*]u8|[*]u8| usize| .. |
780|✓|__aeabi_memmove |[*]u8|[*]u8| usize| .. |
781|✓|__aeabi_memset8 |[*]u8|usize| i32 | *dest, size, char |
782|✓|__aeabi_memset4 |[*]u8|usize| i32 | .. |
783|✓|__aeabi_memset |[*]u8|usize| i32 | .. |
784|✓|__aeabi_memclr8 |[*]u8| u32 | usize| *dest, size |
785|✓|__aeabi_memclr4 |[*]u8| u32 | usize| .. |
786|✓|__aeabi_memclr |[*]u8| u32 | usize| .. |
787|✓|__aeabi_uwrite8 | i64 |[*]u8| i64 | .. |
788
789- __aeabi_read_tp
790
791[^PSRZC]: return result in the CPSR Z and C flag. C is clear only if the
792operands are ordered and the first operand is less than the second.
793Z is set only when the operands are ordered and equal.
794Preserves all core registers except ip, lr, and the CPSR.
795
715796- aarch64 outline atomics
716- arm routines (memory routines + memclr [setting to 0], divmod routines and stubs for unwind_cpp)
717797- atomics
718798- bcmp
719799- clear cache
lib/compiler_rt/arm.zig+10-1
......@@ -1,4 +1,5 @@
1// ARM specific builtins
1//! Implementation of ARM specific builtins for Run-time ABI
2//! This file includes all ARM-only functions.
23const std = @import("std");
34const builtin = @import("builtin");
45const arch = builtin.cpu.arch;
......@@ -38,6 +39,9 @@ comptime {
3839 if (builtin.os.tag == .linux) {
3940 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
4041 }
42
43 // floating-point helper functions (double-precision reverse subtraction, y – x), see subdf3.zig
44 @export(__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });
4145 }
4246 }
4347}
......@@ -186,3 +190,8 @@ pub fn __aeabi_ldivmod() callconv(.Naked) void {
186190 ::: "memory");
187191 unreachable;
188192}
193
194pub fn __aeabi_drsub(a: f64, b: f64) callconv(.AAPCS) f64 {
195 const neg_a = @bitCast(f64, @bitCast(u64, a) ^ (@as(u64, 1) << 63));
196 return b + neg_a;
197}