edA-qa mort-ora-y via llvm-dev
2018-Apr-14 11:58 UTC
[llvm-dev] Creating a C-ABI compatible function signature with a struct
Is there some way to create a target-specific C-ABI compatible function
signature using LLVM?
For example, this C-Code:
typedef struct vpt_data {
char x;
int a;
char c;
float b;
} vpt_data;
void vpt_test( vpt_data vd ) {
Generates a function:
define void @vpt_test(i64 %vd.coerce0, i64 %vd.coerce1) #0 {
And also packs/unpacks the structure values when calling/being called.
If I create the function signature `vpt_test( vpt_data vd)` in LLVM
however, it will just pass the structure as is to the function (push on
stack I presume). This means I can't call any C functions that accept
structures.
I've seen some old threads indicating this was the job of the frontend,
but perhaps a function in LLVM has been created since then. It also
feels like this is something that LLVM should be doing, otherwise I'd
need to create my own code to do this structuring for each target
machine I want to support.
--
edA-qa mort-ora-y
http://mortoray.com/
Creator of the Leaf language
http://leaflang.org/
Streaming algorithms, AI, and design on Twitch
https://www.twitch.tv/mortoray
Twitter
edaqa
Reasonably Related Threads
- Why does clang do a memcpy? Is the cast not enough? (ABI function args)
- A struct {i8, i64} has size == 12, clang says size 16
- A struct {i8, i64} has size == 12, clang says size 16
- A struct {i8, i64} has size == 12, clang says size 16
- Why does clang do a memcpy? Is the cast not enough? (ABI function args)
