HOST: AIX, 8 * IBM POWER2 CPU
COMPILER: GCC 4.0.1, GCC 3.4.4

I am trying to compile my low-level library, which contains
several inline assembly functions. It doesn't work, because
the compiler (4.0.1) does not replace local labels from the
assembly code (i.e. "0:", "1:", etc.) with their machine-specific
replacements ("LCFI..4:" and so on). It generates the labels
literally, i.e. the template

    __asm__ __volatile__("0: bne 0b")

is translated into

    [...]

0: bne 0b

instead of, for example,

L0: bne L0

and then the assembler fails. If I hardcode the label manually, it works.
Even this simple excerpt form Postgres SQL (to exclude my own mistakes)
doesn't compile because of the error described above:

typedef unsigned int word_t;

static __inline__ int
tas(volatile word_t *lock)
{
 word_t _t;
 int _res;

 __asm__ __volatile__(
" lwarx   %0,0,%2  \n"
" cmpwi   %0,0  \n"
" bne     1f   \n"
" addi    %0,%0,1  \n"
" stwcx.  %0,0,%2  \n"
" beq     2f          \n"
"1: li      %1,1  \n"
" b  3f   \n"
"2:      \n"
" isync    \n"
" li      %1,0  \n"
"3:      \n"

: "=&r" (_t), "=r" (_res)
: "r" (lock)
: "cc", "memory"
 );
 return _res;
}

int main(int argc, char *argv[]) {

    word_t x;
    tas(&x);
    return 0;
}

Assembler:
/tmp//cckkGueR.s: line 54: 1252-142 Syntax error.
/tmp//cckkGueR.s: line 57: 1252-142 Syntax error.
/tmp//cckkGueR.s: line 58: 1252-142 Syntax error.
/tmp//cckkGueR.s: line 59: 1252-142 Syntax error.
/tmp//cckkGueR.s: line 60: 1252-142 Syntax error.
/tmp//cckkGueR.s: line 63: 1252-142 Syntax error.

which is exactly where the labels were emitted. GCC 3.4.4 has an
additional bug/misfeature related with some missing instruction patterns:

Assembler:
/tmp//ccgioejq.s: line 538: 1252-149 Instruction lwarx is not implemented in
the current assembly mode COM.
/tmp//ccgioejq.s: line 540: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 542: 1252-149 Instruction stwcx. is not implemented
in the current assembly mode COM.
/tmp//ccgioejq.s: line 543: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 544: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 545: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 546: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 549: 1252-142 Syntax error.
/tmp//ccgioejq.s: line 619: 1252-149 Instruction stwcx. is not implemented
in the current assembly mode COM.
/tmp//ccgioejq.s: line 654: 1252-149 Instruction lwarx is not implemented in
the current assembly mode COM.

    Best regards
    Piotr Wyderski


Reply via email to