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]

modification to inline asm



Hi there,

I'm brand new to this list so I'm not sure where this should go, but I have a
request for a very useful addition to the inline assembler feature of gcc.

I've already made the change in a copy of the gcc source I have and it seems to
work fine.

It is regarding the "which_alternative" variable in recog.c - all I've done is
made it useable from within an asm() statement as a %% command.

For example:

asm
(
     "    .if %A0                  \n"
     "    load_to_cop2_from_memory %0         \n"
     "    .else                          \n"
     "    move_to_cop2_from_register %0  \n"
     "    .endif                         \n"
     : : "m,r" (variable)
);

%An is converted to 0 (false) or 1 (true) with the equation "which_alternative
== n"

This very minor change can cause fairly major speed increases in low-level core
routines, especially on RISC+COP machines where latency cycles very high... I
want the value put into COP2 with as few instructions as possible.

Best Regards
Dylan Cuthbert
Sony Computer Entertainment Inc.
(all views and comments, however sadistic, are solely mine and have nothing to
do with any company I have ever worked for)

Implementation details:

1. I added a simple "if" check to the '%' case in final.c to do the comparision
and output of zero or 1 which was simple enough. (just search for '%')
2. However, the value which_alternative is overwritten by the output of
instructions to load up the values/registers etc so I needed (and this is the
bit that needs confirming and maybe a cleaner hack) to put "check_asm_operands(
body )" immediately after the "decode_asm_operands( body, ops, NULL_PTR,
NULL_PTR, NULL_PTR )" in final_scan_insn.
3. I know 'A' is quite probably a bad choice but I leave that for you folks with
more knowledge of what letters are useable to decide upon.  I thought %@ would
be more sensible (as @ is used in RTL to do a similar thing), but @ seems to be
used.




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