This is the mail archive of the gcc@gcc.gnu.org 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]

Grokking GCC [Was: Re: I give up.]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Oct 22, 2003 at 09:11:35PM +0800, Jonathan Wilson wrote:
> >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.

I think I empathise with your predicament...

> 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 

... but I think the solution is to stare at the code a little (much)
longer.  I feel like only now, after 3 years of on-and-off looking and
lurking am I beginning to understand some of the pieces.  More
importantly, I feel I know which parts I can ignore as being "some
compiler guru obviously knows what's going on here; I don't, so I'll
just leave it".  Don't let my "3 years" quote discourage you: if I
didn't have a Real Job (tm) it'd probably be much, much less than that.

Oh, and BTW, actually *messing around* has helped me tremendously: I've
been working on a 16-bit x86 port with lots of tips and links from other
people.  A bit of a learning-through-immersion thing, I think.

> 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 :'(

AFAICT there's some heavy magic going on in GCC, practically having a
built-in LISP interpreter.  I think you generate that LISP-like RTL with
all those gen_rtx_* functions (that may themselves be generated), which
the "instruction recogniser" then matches to the patterns in the machine
description.  Those instruction patterns then specify what the assembly
output will be.

I'm not sure why you (think you) need to fret over all that RTL
generation if you just want to implement TLS on mingw?  Okay, a bit, but
I can't imagine it'd be all that much...

Oh, another hint I've found useful: this is all GPL'ed stuff.  Copy and
paste with gay abandon, then edit.  You can try to understand it all
later.  (Disclaimer: this is probably bad advice.)  Then fill in
asignment form(s).  There is no "their code/my code" dichotomy I
perceive in the evil proprietary software development world in which I
work.  :)

> 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?

Oh, don't mean to sound arrogant, but have you tried "info gccint" (a
*separate* manual for GCC internals)?  Between it, the code and the
mailing list I don't find life too hard.  Women are much harder to hack.

Read the code some more, I think.  Repeat if necessary.

bernd
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/lprG/FmLrNfLpjMRApaQAJ93SvXzNseCrqWo4gL2B/m6x/LDVACgpla6
UgeCJStzLfKRgBxajmit9Ew=
=nCeT
-----END PGP SIGNATURE-----

P.S. BTW, is all of Oz going nuts with Thugby like they are here in
South Africa?  What with the world cup being there and all...


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