[M3commit] CVS Update: cm3

Jay Krell jkrell at elego.de
Wed Oct 3 08:58:33 CEST 2012


CVSROOT:	/usr/cvs
Changes by:	jkrell at birch.	12/10/03 08:58:33

Modified files:
	cm3/m3-sys/m3back/src/: M3C.m3 

Log message:
	Another great use of the multi-pass infrastructure.
	(Granted, "buffering" per-function instead of per-unit would suffice.
	But the code structure here isn't bad.)
	
	Add a new "Locals" pass that handles:
	declare_segment (needed to detect exception handlers)
	declare_procedure
	end_procedure
	declare_param
	declare_local
	declare_temp
	pop_static_link (because it calls declare_temp)
	begin_block (needed in future for stack packing frame via unions)
	end_block (needed in future for stack packing frame via unions)
	
	and now uplevel locals in subblocks are correctly placed in the frame struct.
	This lets more code compile successfully.
	
	pop_static_link is split up -- early pass calls declare_temp
	later pass uses it
	The linkage between them -- how the later pass find the variable,
	is easy. pop_static_link_temp_vars: RefSeq is introduced.
	early pop_static_link does add hi
	later pop_static_link does get, increasing index each time.
	It is assumed that pop_static_link occurs the same number of
	times and in the same relative order in each pass, this is
	highly reasonable. A much fancier compiler might reorder things
	for optimization, but it would convert this first to another form.
	
	begin/end_block aren't taken advantage of yet.
	The intent is that each subblock with uplevel locals is unioned
	with subblocks at equal nesting levels, something like that.
	This construct isn't even all that common -- uplevel locals
	in nested blocks.
	
	Fix Var_FixName (for now) to more often change the names.
	In particular, locals/params with names like "int",
	that occured multiple times in a function (due to blocks)
	weren't being handled right. They were getting the same name.
	
	(The right fix is to have subblocks use braces, and rely
	on Modula-3 lexical scoping matching C lexical scoping.
	For non-uplevel. For uplevel, we have to create structs/unions
	within the struct for subblocks, or at least do this old renaming.)
	
	Also add in some hacks to deal with uplevel structs.
	They exist. (I need a small test case to cover this and
	other rare but valid constructs).
	They are kind of a special case.
	This probably needs more design/abstraction to clean it up.
	However, soon we will know struct return sizes and then
	pass and return structs by value in the C code, and uplevel structs
	will become maybe less of a special case. Maybe.
	Actually, probably still a special case -- the frame struct should
	probably have a pointer instead of a copied value, to avoid the copy.
	Unless the struct is smaller than a pointer, or something.
	
	With this change, m3tk-misc compiles.
	We get all the way to stubgen having problems at runtime.
	I'll have to step through working and non-working sidebyside.
	
	As well, the hacky ExtraScope_Open / ExtraScope_Close are now unused.
	Good.
	
	Also note that I was using gcc -O2 a while, no problem.
	I've undone that for now, just so I can better debug.




More information about the M3commit mailing list