Skip to content
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

compiler_rt: Tracking Issue ARM Routines #14634

Open
60 of 81 tasks
matu3ba opened this issue Feb 12, 2023 · 2 comments
Open
60 of 81 tasks

compiler_rt: Tracking Issue ARM Routines #14634

matu3ba opened this issue Feb 12, 2023 · 2 comments
Labels
arch-arm 32-bit ARM enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@matu3ba
Copy link
Contributor

matu3ba commented Feb 12, 2023

Context and Purpose

Based on https://gist.github.com/harieamjari/61aa4420ae4ded5e86f5143e46d93573 by user @harieamjari the list of ARM run-time functions to double-check

The official documentation is found here https://github.com/ARM-software/abi-aa/releases and the runtime abi (Q32022) here: https://github.com/ARM-software/abi-aa/blob/2982a9f3b512a5bfdc9e3fea5d3b298f9165c36b/rtabi32/rtabi32.rst

Preparation for audit of compiler_rt in #1504.
see also https://embeddedartistry.com/blog/2017/10/11/demystifying-arm-floating-point-compiler-options/

List of Routines

The functions declared here is based on the document, number,
 * "ARM IHI 0043D, current through ABI release 2.09", which
 * defines the run-time helper-function ABI for programs written
 * in ARM-Thumb assembly language, C, and C++.

/* Standard double precision floating-point arithmetic helper functions */

  • extern double __aeabi_dadd(double, double);
  • extern double __aeabi_ddiv(double n, double d);
  • extern double __aeabi_dmul(double, double);
  • extern double __aeabi_drsub(double x, double y);
  • extern double __aeabi_dsub(double x, double y);

/* double precision floating-point comparison helper functions */

  • extern void __aeabi_cdcmpeq(double, double);
  • extern void __aeabi_cdcmple(double, double);
  • extern void __aeabi_cdrcmple(double, double);
  • extern int __aeabi_dcmpeq(double, double);
  • extern int __aeabi_dcmplt(double, double);
  • extern int __aeabi_dcmple(double, double);
  • extern int __aeabi_dcmpge(double, double); TODO README
  • extern int __aeabi_dcmpgt(double, double); TODO README
  • extern int __aeabi_dcmpun(double, double);

/* Standard single precision floating-point arithmetic helper functions */

  • extern float __aeabi_fadd(float, float);
  • extern float __aeabi_fdiv(float n, float d);
  • extern float __aeabi_fmul(float, float); TODO README
  • extern float __aeabi_frsub(float x, float y);
  • extern float __aeabi_fsub(float x, float y);

/* Standard single precision floating-point comparison helper functions */

  • extern void __aeabi_cfcmpeq(float, float);
  • extern void __aeabi_cfcmple(float, float);
  • extern void __aeabi_cfrcmple(float, float);
  • extern int __aeabi_fcmpeq(float, float);
  • extern int __aeabi_fcmplt(float, float);
  • extern int __aeabi_fcmple(float, float);
  • extern int __aeabi_fcmpge(float, float); TODO README
  • extern int __aeabi_fcmpgt(float, float); TODO README
  • extern int __aeabi_fcmpun(float, float);

/* Standard floating-point to integer conversions */

  • extern int __aeabi_d2iz(double); TODO README
  • extern unsigned __aeabi_d2uiz(double); TODO README
  • extern long long __aeabi_d2lz(double); TODO README
  • extern unsigned long long __aeabi_d2ulz(double); TODO README
  • extern int __aeabi_f2iz(float); TODO README
  • extern unsigned __aeabi_f2uiz(float); TODO README
  • extern long long __aeabi_f2lz(float); TODO README
  • extern unsigned long long __aeabi_f2ulz(float); TODO README

/* Standard conversions between floating types */

  • extern float __aeabi_d2f(double);
  • extern double __aeabi_f2d(float); TODO README
  • extern float __aeabi_h2f(short hf); TODO README
  • extern float __aeabi_h2f_alt(short hf);
  • extern short __aeabi_f2h(float f);
  • extern short __aeabi_f2h_alt(float f);
  • extern short __aeabi_d2h(double);
  • extern short __aeabi_d2h_alt(double);

/* Standard integer to floating-point conversions */

  • extern double __aeabi_i2d(int); TODO README
  • extern double __aeabi_ui2d(unsigned); TODO README
  • extern double __aeabi_l2d(long long); TODO README
  • extern double __aeabi_ul2d(unsigned long long); TODO README
  • extern float __aeabi_i2f(int); TODO README
  • extern float __aeabi_ui2f(unsigned); TODO README
  • extern float __aeabi_l2f(long long); TODO README
  • extern float __aeabi_ul2f(unsigned long long); TODO README

/* Long long functions */

  • extern long long __aeabi_lmul(long long, long long); TODO README
  • extern lldiv_t __aeabi_ldivmod(long long n, long long d); TODO README
    /* ulldiv_t might be unsupported */
  • extern ulldiv_t __aeabi_uldivmod(unsigned long long n, unsigned long long d); TODO README
  • extern long long __aeabi_llsl(long long, int);
  • extern long long __aeabi_llsr(long long, int);
  • extern int __aeabi_lcmp(long long, long long);
  • extern int __aeabi_ulcmp(unsigned long long, unsigned long long);

/* Integer (32/32 -> 32) division functions */

  • extern int __aeabi_idiv(int numerator, int denominator);
  • extern unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator);
    typedef struct { int quot; int rem; } idiv_return;
    typedef struct { unsigned quot; unsigned rem; } uidiv_return;
  • extern idiv_return __aeabi_idivmod(int numerator, int denominator); TODO README
  • extern uidiv_return __aeabi_uidivmod(unsigned numerator, unsigned denominator); TODO README

/* Division by zero */

  • extern int __aeabi_idiv0(int return_value);
  • extern long long __aeabi_ldiv0(long long return_value);

/* Unaligned memory access */

  • extern int __aeabi_uread4(void *address);
  • extern int __aeabi_uwrite4(int value, void *address);
  • extern long long __aeabi_uread8(void *address);
  • extern long long __aeabi_uwrite8(long long value, void *address);

/* Memory copying */

  • extern void __aeabi_memcpy8(void *dest, const void *src, size_t n);
  • extern void __aeabi_memcpy4(void *dest, const void *src, size_t n);
  • extern void __aeabi_memcpy(void *dest, const void *src, size_t n);
  • extern void __aeabi_memmove8(void *dest, const void *src, size_t n);
  • extern void __aeabi_memmove4(void *dest, const void *src, size_t n);
  • extern void __aeabi_memmove(void *dest, const void *src, size_t n);

/* Memory clearing and setting */

  • extern void __aeabi_memset8(void *dest, size_t n, int c);
  • extern void __aeabi_memset4(void *dest, size_t n, int c);
  • extern void __aeabi_memset(void *dest, size_t n, int c);
  • extern void __aeabi_memclr8(void *dest, size_t n);
  • extern void __aeabi_memclr4(void *dest, size_t n);
  • extern void __aeabi_memclr(void *dest, size_t n);
@matu3ba matu3ba added the bug Observed behavior contradicts documented or intended behavior label Feb 12, 2023
@Vexu Vexu added enhancement Solving this issue will likely involve adding new logic or components to the codebase. arch-arm 32-bit ARM and removed bug Observed behavior contradicts documented or intended behavior labels Feb 12, 2023
@Vexu Vexu added this to the 0.12.0 milestone Feb 12, 2023
@matu3ba
Copy link
Contributor Author

matu3ba commented Apr 26, 2023

See also #15468.

@matu3ba matu3ba changed the title Tracking issue for compiler_rt ARM compatibility compiler_rt: Tracking Issue ARM Routines May 12, 2023
@matu3ba
Copy link
Contributor Author

matu3ba commented May 12, 2023

ARM-only ones:

Done Name a b Out Comment
Float Comparison
__aeabi_cfcmpeq f32 f32 void a == b result in PSR ZC flags[^PSRZC]
__aeabi_cfcmple f32 f32 void a <= b result ..
__aeabi_cfrcmple f32 f32 void b <= a ..
__aeabi_cdcmpeq f64 f64 void a == b ..
__aeabi_cdcmple f64 f64 void a <= b ..
__aeabi_cdrcmple f64 f64 void b <= a ..
Float Arithmetic
__aeabi_frsub f64 f64 f64 b - a
__aeabi_drsub f64 f64 f64 ..
Special
__aeabi_read_tp *u8 ret tls pointer
__aeabi_idiv0 i32 i32 div by 0 modifier
__aeabi_ldiv0 i64 i64 div by 0 modifier
Unaligned memory access
__aeabi_uread4 [*]u8 i32 ret value read
__aeabi_uwrite4 i32 [*]u8 i32 ret value written
__aeabi_uread8 [*]u8 i64 ..
__aeabi_uwrite8 i64 [*]u8 i64 ..
Done Name a b c Comment
Memory copy, move and set
__aeabi_memcpy8 [*]u8 [*]u8 usize *dest, *src, size
__aeabi_memcpy4 [*]u8 [*]u8 usize ..
__aeabi_memcpy [*]u8 [*]u8 usize ..
__aeabi_memmove8 [*]u8 [*]u8 usize *dest, *src, size
__aeabi_memmove4 [*]u8 [*]u8 usize ..
__aeabi_memmove [*]u8 [*]u8 usize ..
__aeabi_memset8 [*]u8 usize i32 *dest, size, char
__aeabi_memset4 [*]u8 usize i32 ..
__aeabi_memset [*]u8 usize i32 ..
__aeabi_memclr8 [*]u8 u32 usize *dest, size
__aeabi_memclr4 [*]u8 u32 usize ..
__aeabi_memclr [*]u8 u32 usize ..
__aeabi_uwrite8 i64 [*]u8 i64 ..

Note: If having identical implementation [including besides function signature], routines are documented in #15675 and #15676.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm 32-bit ARM enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants