asm label generation bug?
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
Re: asm label generation bug?
On Thu, Dec 22, 2005 at 02:28:08PM +0100, Piotr Wyderski wrote: 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. I don't know what you expect GCC to do here. The contents of inline asm are passed through without modification, except for substituting % references. Note, the digit labels are a standard feature of the GNU assembler - which you are not using. 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. Again, this error is coming from the AIX assembler, not from GCC. You ned to pass the correct options (I don't know what they are) to that assembler to make it accept these instructions. -- Daniel Jacobowitz CodeSourcery, LLC
Re: asm label generation bug?
On Dec 22, 2005 02:28 PM, Piotr Wyderski [EMAIL PROTECTED] wrote: 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). The manual says: This assumes your assembler supports local labels, as the GNU assembler and most Unix assemblers do. Does your assembler support this? Gr. Steven
Re: asm label generation bug?
On Dec 22, 2005, at 5:28 AM, Piotr Wyderski wrote: 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) Please submit a bug report to your assembler provider, it is broken. :-) Beyond that, you can use: @samp{%=} outputs a number which is unique to each instruction in the entire compilation. This is useful for making local labels to be referred to more than once in a single template that generates multiple assembler instructions. If you looked in the manual and didn't find this the first time, please submit a patch that would have enabled you to find it, thanks. You're not the only one to not be able to find it, thanks.