Say you have a pointer:
int *p;
and an inline asm that writes to a block of memory
__asm__("\t0:\n"
"\tstr wzr, [%2, #4]!\n"
"\tsub %1, %1, #1\n"
"\tcbnz %1, 0b\n"
: "=m"(*p), "+r"(len) : "r"(p));
I presume this is wrong because *p only refers to p[0]. Is it
possible to tell GCC that the asm writes to the whole block of memory
reachable from p without a total memory clobber?
I have attached some code that works but it is so fugly that I'm
reluctant to recommend it.
Andrew.
typedef struct {
int theData[0];
} thing;
int main() {
int arr[20];
thing *p = (thing*)arr;
int len = 20;
__asm__("\t0:\n"
"\tstr %1, [%2, #4]!\n"
"\tsub %1, %1, #1\n"
"\tcbnz %1, 0b\n"
: "=m"(*p), "+r"(len) : "r"(p));
return p->theData[5];
}