inline in ATS

70 views
Skip to first unread message

Brandon Barker

unread,
Oct 15, 2014, 4:47:20 PM10/15/14
to ats-lan...@googlegroups.com
Is there a way or desire to have a function in ATS generate an inline C function declaration?

Something like the following could possibly act as both a hint and a way to export the function to C:
extern
fun myfun (...): int = "inline#myfun_in_c" 

Maybe most compilers are already good enough at spotting functions to be inlined that this isn't very helpful for function calls in loops.

gmhwxi

unread,
Oct 15, 2014, 6:00:33 PM10/15/14
to ats-lan...@googlegroups.com
I would just leave it to the compiler.

The important thing is to *facilitate* inlining. For instance, using templates
or putting code in a CATS-file can make sure that the functions to be inlined
stay in the same compilation unit where they are called.

I often combine all the files in a program into one (by using #include and
some other features of ATS) to allow the C compiler to "churn" it :)

The code in ATSLIB/prelude and ATSLIB/libats consists of mostly templates.
So most ATSLIB-functions get "churned" as well.

Barry Schwartz

unread,
Oct 15, 2014, 9:44:30 PM10/15/14
to ats-lan...@googlegroups.com
gmhwxi <gmh...@gmail.com> skribis:
> I often combine all the files in a program into one (by using #include and
> some other features of ATS) to allow the C compiler to "churn" it :)

Would -fwhole-program also work?

(The #include et al approach should work as long as -funit-at-a-time
is active.)

Hongwei Xi

unread,
Oct 15, 2014, 9:55:08 PM10/15/14
to ats-lan...@googlegroups.com
I did not try -fwhole-program. I tried a flag of the name '-compile' (?); it worked but the flag
was moved from the recent versions of gcc.

There is another reason for me to use ATS to generate a single C file containing everything.
I could use TinyCC (TCC) to compile such a file. Due to the speed of TCC, it is a bit like using
the C code as some kind of script.


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/20141016014421.GB26540%40crud.

Barry Schwartz

unread,
Oct 17, 2014, 6:15:49 PM10/17/14
to ats-lan...@googlegroups.com
I wrote:
> gmhwxi <gmh...@gmail.com> skribis:
> > I often combine all the files in a program into one (by using #include and
> > some other features of ATS) to allow the C compiler to "churn" it :)
>
> Would -fwhole-program also work?

-fwhole-program seems to work, at least in a simple case, _if_ I avoid
dynload. So it is not as good a method.

Reply all
Reply to author
Forward
0 new messages