Software APIs
Data Structures | Typedefs | Functions
math_builtins.c File Reference

(9908a5cbd6)

Implementations of libgcc-style polyfills for arithmetic. More...

#include <stdint.h>
#include <stdnoreturn.h>
#include "sw/device/lib/base/macros.h"

Go to the source code of this file.

Data Structures

union  u32x2
 Helper type for fussing with the upper and lower halves of an i64. More...
 
struct  u32x2.__unnamed5__
 
union  u32x2.__unnamed5__.__unnamed7__
 

Typedefs

typedef union u32x2 u32x2_t
 Helper type for fussing with the upper and lower halves of an i64. More...
 

Functions

int64_t _ot_builtin_lshift_i64 (int64_t val, int32_t shift)
 
int64_t _ot_builtin_rshift_i64 (int64_t val, int32_t shift)
 
int64_t _ot_builtin_ashift_i64 (int64_t val, int32_t shift)
 

Detailed Description

Implementations of libgcc-style polyfills for arithmetic.

This file has no header, since its functions should not be called directly; the compiler will generate calls into them as needed.

The functions have names like _ot_builtin_*, rather than their libgcc names, so that they can coexist with libgcc/libcompiler-rt on the host-side for the purpose of unit tests. The linker aliases for the libgcc names only exist on the device-side.

See https://github.com/llvm/llvm-project/tree/main/compiler-rt/lib/builtins for a detailed specification of the ABI we implement in this file.

The provided functions here are:

Although the RISC-V B extension provides instructions for some ofthese, we currently do not require using a Clang that is aware of how to codegen them, so LLVM may choose to emit libgcc polyfill symbols (like the following) instead. Once we mandate such a Clang, they should be removed.

Definition in file math_builtins.c.


Data Structure Documentation

◆ u32x2

union u32x2

Helper type for fussing with the upper and lower halves of an i64.

This is necessary to avoid accidentally calling into the shift polyfills inside of their implementations.

Definition at line 41 of file math_builtins.c.

Data Fields
struct u32x2 __unnamed__
int64_t full

◆ u32x2.__unnamed5__

struct u32x2.__unnamed5__

Definition at line 42 of file math_builtins.c.

Data Fields
__unnamed5__ __unnamed__
uint32_t lo

◆ u32x2.__unnamed5__.__unnamed7__

union u32x2.__unnamed5__.__unnamed7__

Definition at line 44 of file math_builtins.c.

Data Fields
uint32_t hi
int32_t hi_signed

Typedef Documentation

◆ u32x2_t

typedef union u32x2 u32x2_t

Helper type for fussing with the upper and lower halves of an i64.

This is necessary to avoid accidentally calling into the shift polyfills inside of their implementations.