This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: I give up.

Jonathan Wilson writes:
 > > Such as... (yesterday) gen_rtx_REG?  That's in emit-rtl.c.  As for
 > > gen_rtx_UNSPEC, I don't know.  Bear in mind that there are about a dozen
 > > or so C files that are *generated* during the build.  Sometimes what
 > > you're looking for is in there instead, or in the generator program.
 > I did finally find all the bits of code (for example in genrtl.c).
 > But all that has done is made me even more confused as to just WTF all 
 > these functions are actually for.
 > What I am looking for is a "guide to emitting RTL in GCC on i?86 
 > processors". Or if such a thing doesnt exist, someone out there who knows 
 > how to do what it is that I am trying to do and can tell me.
 > Because after staring at the code, the docs, the (in this case) usless 
 > google search results and the back-postings to this list, I am still no 
 > closer to figuring out how functions like gen_rtx_UNSPEC, gen_rtx_CONST, 
 > gen_reg_rtx, gen_subsi3, emit_insn, gen_rtx_SET and so on actually transfer 
 > to the x86 assembler instructions that appear in the output thats fed to 
 > GAS :'(

Look at i386.c.  There's a ton of examples there, such as this one in
ix86_expand_epilogue :

	  rtx tmp, sa = EH_RETURN_STACKADJ_RTX;

	  if (frame_pointer_needed)
	      tmp = gen_rtx_PLUS (Pmode, hard_frame_pointer_rtx, sa);
	      tmp = plus_constant (tmp, UNITS_PER_WORD);
	      emit_insn (gen_rtx_SET (VOIDmode, sa, tmp));

	      tmp = gen_rtx_MEM (Pmode, hard_frame_pointer_rtx);
	      emit_move_insn (hard_frame_pointer_rtx, tmp);

	      emit_insn (gen_pro_epilogue_adjust_stack
			 (stack_pointer_rtx, sa, const0_rtx));
	      tmp = gen_rtx_PLUS (Pmode, stack_pointer_rtx, sa);
	      tmp = plus_constant (tmp, (frame.to_allocate
                                         + frame.nregs * UNITS_PER_WORD));
	      emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx, tmp));

which generates code to adjust registers, read and write memory, and
so on.  emit_insn() pushes an insn into the insn stream, which is then
optimized and converted to assembler.

Segment registers are a bit tricky.

 > Normally, the usual response to "the docs, google and list archives" didnt 
 > help (when it comes to open source projects) is "go read the code".
 > However in this case, what is one supposed to do when you have already read 
 > the code and even that didnt help?

That's still true.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]