Bug 39440 - User Manual: describe asm ("%a0,%c0"::)
Summary: User Manual: describe asm ("%a0,%c0"::)
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2009-03-12 10:07 UTC by etienne_lorrain
Modified: 2013-05-11 21:46 UTC (History)
3 users (show)

See Also:
Host: all-all-all
Target: all-all-all
Build: all-all-all
Known to work:
Known to fail:
Last reconfirmed: 2009-04-16 20:48:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description etienne_lorrain 2009-03-12 10:07:34 UTC
The user manual at:
http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Extended-Asm.html#Extended-Asm
decribes a lot of the asm syntax, but do not describe the modifier in between
the percent sign and the digit (or [name]) inside the string of the asm.

One use case is to access global structure fields inside asm(""):
union {
    struct {
        int a;
        char b, c, d;
        } part1;
    unsigned long long part2;
    } global_var;

void fct(void) {
    asm volatile (" global_var_a = %c0 " : : "p" (global_var.part1.a) );
    asm volatile (" global_var_c = %c0 " : : "p" (global_var.part1.c) );
    }

asm (
"    movl $0,global_var_a    \n"
"    movb $0,global_var_c    \n"
);
Comment 1 Paul Brook 2009-03-12 13:45:42 UTC
I'm not so sure documenting these is a good idea. Aren't these really internal implementation details that are accidentally exposed via asm()?

IMHO putting them in the user documentation is risky because it means users have a legitimate grievance when we break them. I suspect many of the modifiers also don't do what you expect, and only work in very limited circumstances for particular .md patterns.
Comment 2 etienne_lorrain 2009-03-12 14:10:17 UTC
 The thread associated:
http://gcc.gnu.org/ml/gcc/2009-03/msg00288.html
Comment 3 Ian Lance Taylor 2009-03-12 18:29:54 UTC
We don't have to document all of the modifiers, but we do have to document some of them.  There are cases where they are required in order to use asm statements effectively.  Most of the modifiers haven't changed for decades, I don't think we have to worry about that as long as we are careful about which ones we document.
Comment 4 David 2013-05-11 21:46:40 UTC
(In reply to Ian Lance Taylor from comment #3)

Since I am working on the extended asm docs, this might be something I could look at.  The question is, which ones get doc'ed?  The letters acln are platform neutral (see output_asm_insn in final.c).  Anything beyond that is platform specific.  Do we really want to doc every letter for every platform? (yikes!)

I don't own a vax, pdp, sparc, or most of the other 40 odd platforms supported by gcc.  There's no way I could test modifiers to see if they produce what I think they do for most platforms, which makes doc'ing them problematical. 

I could take a look at the ones for i386, but there's no point in even doing that until there's agreement about which ones to doc.  

Who decides?  Or if I'm the person doing the work, do I get to?