[RFC] [compiler-rt][builtins] Make the default LibCall implementations more customizable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[RFC] [compiler-rt][builtins] Make the default LibCall implementations more customizable

Tom Stellard via cfe-dev
Hello,

When working with the builtins library from compiler-rt, turned out some trivial customization points may be useful.

# Background

* The builtins library from compiler-rt has portable default implementations written in C for all its LibCalls
* Those implementations can be replaced by potentially much efficient target-specific ones when appropriate
* Ideally, one should be able to start with all-default implementations ASAP when adding support for a new target, and then gradually improve it

# Problem statement

* Some targets have special requirements on LibCalls:
  - name aliases (see existing ARM-specific aliases, MSP430 requires some as well)
  - seemingly arbitrarily chosen calling conventions (see Section 6.3 of MSP430 EABI document [1]). While they are probably justified by implementation specifics, it is hard to deduce the required convention merely from the signature (harder than just "special iff is LibCall and has two 64-bit arguments")
  - the default implementation (that can probably be quite elaborate) may perfectly fit all the requirements except for those tiny configuration details
* It is worth not to force target implementations to diverge from the upstream ones just to account for such tiny details
* On the other hand, it is worth to not clobber the generic implementation with a bunch of target-specific defines

# Implementation

Here is an example implementation: https://reviews.llvm.org/D84636. It uses preprocessor macro and a header that is auto-generated by a shell script. The two customization points it introduces are per-LibCall `__attribute__`s (calling conventions, etc.) and generic source file footers (name aliases can be placed there).

[1] MSP430 EABI: https://www.ti.com/lit/an/slaa534a/slaa534a.pdf

Best regards,
Anatoly Trosinenko
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev