[M3devel] struct complaints and C backend update

Jay K jay.krell at cornell.edu
Sun Sep 16 00:29:05 CEST 2012


It'd be nice if declare_procedure gave the size of returned structs.I guess I could deduce it maybe from the "_result" variable or some of thedeclare_ stuff with typeids that I ignore or something.I've reworked my code to use "standard structs", even though I'd rather not.I'd rather return them by value and have the C compiler deal with it.

Efficiency and ABI correctness is lost.NT/amd64 passes 1, 2, 4, and 8 byte structs in registers, or somesuch.NT/x86 I think passes some small structs in registers too.

If we returned structs by value, the left-or-right matter would be solved too.

Not that ABI correctness is all that important -- so little C code passesor returns structs by value anyway, let alone C code we need to interoperate with.

But I'd still like to give the C compiler more of the work.


It SEEMS that local declared procedures take struct parametersas type "struct", with size, and I can pass them with a somewhat strong type.It SEEMS that imported procedures take them by untyped "address".I've reworked my code here. To pass structs by pointer and copy theminto a local. I'd rather just pass them by value and have the C compilerdeal with it.

I can now compile and link cm3 for {I386,AMD64,PPC}_DARWIN, usingthe C backend. It crashes..in RTLinker__InitRunTime.traceLink does manage to output a fair amount before crashing,which is itself actually quite impressive.This is difficult work though!

I've also reworked structs slightly to compose them of short, int, INT64in order to raise their alignment, if needed.

I still predeclare a bunch of struct sizes.I need to make a second pass over the data to discover them all.Or do something higher level still, not just go by size.

If I try to compile the entire system, I don't get too far beyondcm3 before I hit a C compiler error, something exception handling related.



 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120915/8f2716f6/attachment-0001.html>


More information about the M3devel mailing list