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]

Re: MS/CW-style inline assembly for GCC


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

On Thu, May 06, 2004 at 07:19:06PM -0700, Ziemowit Laski wrote:
> On 6 May, 2004, at 19.11, Mike Stump wrote:
> >On Thursday, May 6, 2004, at 06:40 PM, Mark Mitchell wrote:
> >>If Apple checks in these extensions, in any way that touches code 
> >>outside of darwin.[hc],
> >
> >Then lets explore ways in which we can architect the code so that we 
> >can achieve this extension in such that it doesn't.  If we can manage 
> >to find a way, we all win.  We can simply require that Stan do all the 
> >work and come up with a lean thin interface down into port files.  If 
> >he can, we're set, if not, Apple local it is.
> 
> Good idea.  Maybe it will be possible to use a target hook to chew 
> through the CodeWarrior assembly fragments?

Step 1:

Link gas and bfd into GCC, exposing a new gas function
read_a_source_line (factored out of read_a_source_file).  Also make a
variant, read_a_source_line_pretend, which doesn't *do* anything other
than do the first "pass" over inline asm as in Step 4.

For targets not supported by gas, GCC can just provide default
implementations of read_a_source_line* that barf or fprintf to stdout.

Step 2:

Redo all of PRINT_OPERAND.*, ASM_OUTPUT_.*, and basically anything else
which uses a STREAM argument, to use some sprintf-like output instead,
into a ready-to-assemble buffer.

First mini-step: define a macro ASM_PRINTF(PRINTF_CONTEXT, (PRINTFARGS))
which can, for now, just be fprintf(PRINTF_CONTEXT, PRINTFARGS) and
rename STREAM to PRINTF_CONTEXT in the docs and headers.

Step 3:

Send whatever lands in that buffer to read_a_source_line.

Step 4:

Add middle-end callbacks for use by read_a_source_line_pretend so that
it can register (pardon the pun) inputs, outputs and clobbers as
*constraints*, if it can't otherwise parse the operand.

The assembler is in the best position to know these, after all.  It'd be
easier to teach than anything else - including, apparently, humans.

Step 5:

Now that you have all the constraints you need, deal with the ASM_STMT
as normal, allocating registers and passing off the lines to
read_a_source_line.


Hmm, I'd *love* to do (some of) this myself, but I'd have to get my
employer to sign off paperwork, and it'd take too long for the rest of
you, and the Apple guys have probably done something that works already.

- -- 
http://voyager.abite.co.za/~berndj/ (f1084a555d2098411cff4cefd41d2e2a1c85d18c)
I've generally found that the fastest way to get the right answer on the net
is to confidently assert the answer you believe to be right; those who know
will immediately correct you, while if you just ask, often no answers arrive.
All it requires is a willingness to look bad on occasion.
                                               - Joe Buck on gcc@gcc.gnu.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAm0R3/FmLrNfLpjMRAkBtAJ9J91HtDWTBt+N/pfzk+PXIneNvpQCeJPaS
EhtB2XH0x0//zbCRg0kh6u8=
=/3fd
-----END PGP SIGNATURE-----


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