User account creation filtered due to spam.

Bug 30527

Summary: Use of input/output operands in __asm__ templates not fully documented
Product: gcc Reporter: Davin McCall <davmac>
Component: inline-asmAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: etienne_lorrain, gcc-bugs, gccbugzilla, mschulze, pi3orama
Priority: P3 Keywords: documentation
Version: 4.1.1   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description Davin McCall 2007-01-21 14:14:34 UTC
It seems that I can use "%k0" (rather than just "%0") in an asm template to force the (register) operand to "long" size (i.e. a value in %al referenced as %k0 comes out as %eax in the generated assembly).

This doesn't seem to be documented anywhere. I presume there may be other such character prefixes which have similar functions.
Comment 1 Davin McCall 2007-01-21 14:15:25 UTC
I should add that I'm prepared to send a patch for the documentation if someone will tell me what the operands are and what they do.
Comment 2 Andrew Pinski 2007-01-21 16:37:38 UTC
Every target have slightly different operand modifiers.  They are usually "documented" in config/*/*.md or config/*/*.c, but I think it is incorrect to documented them for real because people will then abuse them.
Comment 3 Davin McCall 2007-01-22 04:17:45 UTC
You've got to be kidding - these things are genuinely useful. What sort of abuse are you worried about?

In any case, I'd like to know if that is the general consensus among maintainers. I'm not going to write documentation and submit a patch if it's not going to be accepted.
Comment 4 Davin McCall 2015-07-17 10:54:51 UTC
I recently stumbled across section of the manual, which does in fact document the operand modifiers for (and only for) x86. Modifiers for other architectures are not documented.
Comment 5 David 2016-05-08 22:03:17 UTC
These modifiers are intended primarily for use by Machine Descriptions.  As a result, some of them aren't going to be meaningful/usable by inline asm code.  And it makes sense to leave open the option to change their meaning should future MD work require it, something that documenting them all would prevent.

On the other hand, some of these values are indeed quite useful for inline asm.

The compromise, as evidenced by (added in v5.x), is to document certain commonly needed/used modifiers (such as the %k0 referenced above).

If there is some additional modifier that you need, I'd recommend opening a new bug and making an explicit case for it.

In the meantime, I recommend closing this bug (as fixed).
Comment 6 Richard Biener 2016-05-09 10:06:37 UTC
*** Bug 39440 has been marked as a duplicate of this bug. ***
Comment 7 Richard Biener 2016-05-09 10:07:21 UTC
*** Bug 43319 has been marked as a duplicate of this bug. ***