Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Why compilers are retarded

Name: Cudder !MhMRSATORI 2014-09-09 4:38

Suppose I have a set of functions, written in Asm, which take as input parameters in registers, and also output multiple values in registers. In C, this would look like

struct { int n; char *e; char *f; }
phoo(int ni, void *p, char *ei, char *fi);


which is nothing special, but the problem is that no compiler I know of will allow specifying where the parameters and returns are!! They all only support a very limited set of "calling conventions", and nothing else. There's no way to write something like

struct { int n@eax; char *e@esi; char *f@edi; }
phoo(int ni@ecx, void *p@edx, char *ei@esi, char *fi@edi);


and have existing compilers generate the appropriate code when calling and using the return values. Is it really so hard to, when compiling a function call,

1. Look up where the function wants its parameters
2. Evaluate the parameters and put them in the right places
3. Call the function
4. Direct any expressions using its the return value(s) to read from the right places

instead of following a stupid cookie-cutter template every time? Am I going to have to write a compiler too?

As they say, "If you want it done right, do it yourself..."

Name: Anonymous 2014-09-09 4:55

ur mom is a cookie-cutter template

Name: Anonymous 2014-09-09 5:42

Write a DSL for this.

Name: Anonymous 2014-09-09 6:14

Make a compiler extension for Clang (easier than GCC). I'm fairly sure that you can make FASM macros to make syntactic caramel for any language you want, and still access register shit.

Don't know why you would want to though. If you need to hack on registers, C is too high level for your needs.

Name: Anonymous 2014-09-09 6:47

SBCL vops allows that.

Name: Cudder !MhMRSATORI 2014-09-09 11:01

>>4
Looked into Clang/LLVM but the way it does code generation won't really make it easy to do this.

Don't know why you would want to though.
Because I want to efficiently use Asm from C?

Name: Anonymous 2014-09-09 11:19

>>6
then use ASM directly from C you fucking kike
how about you optimize yourself out of /prog/

Name: Anonymous 2014-09-09 11:33

SHALOM!

Name: Anonymous 2014-09-09 14:13

>>3
Write a DSL for this.

But I am not a Lisp programmer, and therefore do not know how to do that ;(

Name: Anonymous 2014-09-09 16:44

Pepe the Frog says: ``install gentoo''

Name: Anonymous 2014-09-09 17:12

Use C-- or another C-like low-level language instead

Name: Anonymous 2014-09-09 18:02

>>9
That's one of those statements like "this statement is false." YOU'RE NOT A FUCKING LISP PROGRAMMER IF YOU CAN'T WRITE A GODDAMN DSL

Name: Anonymous 2014-09-10 5:56

>>1
The Watcom C and C++ compilers did allow the calling convention to be customized using the magic #pragma aux:

http://www.openwatcom.org/index.php/Calling_Conventions#Specifying_Calling_Conventions_the_Watcom_Way

There are some limitations, mostly involving composite data types that can only be passed in certain registers or register pairs. I never managed to find the code in the OpenWatcom tree that handles this but I suspect it involves some highly involved fiddling with the code generator's naughty bits.

Whatever the implementation, it works pretty well for its primary purpose (interfacing with baroque DOS TSR and BIOS interrupt services).

Name: Cudder !MhMRSATORI 2014-09-10 12:21

>>13
wat

That sounds bloody amazing if it's true. Does OpenWatcom even support pragma aux? The syntax isn't all that great though.

Of course I'm not so keen on downloading and setting up another compiler (and Watcom looks like it's not small either), so... thanks anyway.

Name: Anonymous 2014-09-10 17:05

>>14
make your own compiler and stop complaining, transkike

Name: Anonymous 2014-09-10 20:08

>>14
Shalom!

Name: Anonymous 2014-09-10 21:36

>>6
Just use ASM then. You can't use C effecitvely in ASM very well.

Name: Anonymous 2014-09-11 4:49

>>14
Does OpenWatcom even support pragma aux?

OpenWatcom is a direct descendant and superset of Watcom functionally, so yes it does.

The syntax isn't all that great though.

(Open)Watcom has not evolved tremendously since the nineties. If you really want something more modern I think you're left with rolling your own.

Watcom doesn't look small either

The install package is big, but you probably don't need to use all of it. I once fit a self hosting environment for DOS development with Watcom on a bootable USB drive.

Don't change these.
Name: Email:
Entire Thread Thread List