This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Assembling Power instructions: dcbtst/dcbt.


Hello,

 Per Power ISA Version 2.07 (May 3, 2013) "4.3.2 Data Cache Instructions",
 the assembly language syntax for the dcbtst instruction (pp. 771) is:

 dcbtst RA,RB,TH [Category: Server]
 dcbtst TH,RA,RB [Category: Embedded]

 and it's layout in the object code is:

  +------+------+------+------+------------+---+
  |  31  |  TH  |  RA  |   RB |  246(0xF6) | / |
  |0     |6     |11    |16    |21          |31 |
  +------+------+------+------+------------+---+

 (Analogously: dcbt pp. 770)

 However, GAS (as of version 2.23.52.20130912) decides on the syntax to use based on
 processor/architecture dialect (not Power ISA Category), using the Server syntax in
 the case of POWER4 and the Embedded syntax for generic PPC or VLE.

 From ./opcodes/ppc-opc.c

--------------------------------------------------------------------------------
 {"dcbtst",      X(31,246),      X_MASK,      POWER4,    PPCNONE,        {RA0, RB, CT}},
 {"dcbtst",      X(31,246),      X_MASK,      PPC|PPCVLE, POWER4,        {CT, RA0, RB}},
--------------------------------------------------------------------------------

 Consequently (e.g.),

 dcbtst 17, 14, 6

 in the assembly file gets "misassembled" under -many for a user-space program on Linux:

--------------------------------------------------------------------------------
(gdb) disassemble $pc,$pc+4
Dump of assembler code from 0x100004c8 to 0x100004cc:
=> 0x00000000100004c8 <.main+12>:       dcbtst  r14,r6,17
End of assembler dump.
(gdb) x/t 0x00000000100004c8
0x100004c8 <.main+12>:  01111110001011100011000111101100
(gdb) p (0b01111110001011100011000111101100 >> 26) & 0x3f
$11 = 31
(gdb) p (0b01111110001011100011000111101100 >> 21) & 0x1f
$12 = 17
(gdb) p (0b01111110001011100011000111101100 >> 16) & 0x1f
$13 = 14
(gdb) p (0b01111110001011100011000111101100 >> 11) & 0x1f
$14 = 6
(gdb) p (0b01111110001011100011000111101100 >> 1) & 0x3ff
$15 = 246
(gdb)

 i.e.
| OPCD := 31 | TH := 17 | RA := 14 | RB := 6 | XO := 246 | / := 0 |

--------------------------------------------------------------------------------

 To work around this issue, I use the .machine "<cpu>" PowerPC assembler directive
 provided by GAS to make it use the desired syntax in the assembling of dcbtst and
 dcbt:

--------------------------------------------------------------------------------
#define ISA2_07_XFORM20(insn) \
".machine \"push\"  \n\t"     \
".machine \"power4\"\n\t"     \
insn "\n\t"                   \
".machine \"pop\""

#define X20 ISA2_07_XFORM20

int main (void)
{
  __asm__ __volatile__ (X20("dcbtst %0, %1,  6") : : "b" (r17), "r" (r14));
  return 0;
}
--------------------------------------------------------------------------------

 I was wondering if there was a better approach than the one I have above?

 --

 Also, is it at all possible that we add a PowerPC option to GAS: --isa-category=<val>
 where <val> in { server, embedded, ... /* more values as applicable */ } to be used
 in such cases where the Power ISA category serves to distinguish? The option could
 be OFF by default and be implemented in a way that keeps the code change as minimal
 as possible and preserves current user experience.

 Thank you very much.

Regards,
Anmol P. Paralkar


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]