[llvm-dev] Creating a C-ABI compatible function signature with a struct

edA-qa mort-ora-y via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 14 04:58:20 PDT 2018


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
	



More information about the llvm-dev mailing list