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]

Suggestions for extended asm


I'd like to suggest two new features for extended asm.
I'm not sure how hard would be to actually implement
them, but these things can already be done in *.md files,
so I hope it won't be that hard after all...

1. allow specifying the true length of assembler code
inserted (equivalent of set_attr "length" ... in *.md,
currently it is done by counting line separators in the
string, but that might be unreliable if machine opcodes
have different sizes or constructs like .rept/.endr are
used).  This is significant to prevent assembler errors
if branches have limited range (like -64/+63 on AVR).

2. allow multiple alternatives of operand constraints,
with different instruction templates for each alternative.

I think it might look like this - made up example for avr
enhanced core, using the not yet implemented "v" register
class (can copy two registers at once if both source and
destination are aligned to even-numbered registers):

 asm ( "movw %A0,%A1" (1), "mov %A0,%A1 $ mov %B0,%B1" (2)
       : "=v,&r" (dest) : "v,r" (src) );

This is trivial "dest = src;" in C for 16-bit ints, but it's
just an example to show both of the above suggestions.
If the true length is not specified after the template, it
should be calculated the old way (count line separators).

Comments?

Marek

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