[PATCH] D44815: [AArch64]: Add support for parsing rN registers.

Peter Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 26 11:46:14 PDT 2018


peter.smith added a comment.

I think that we may have a bit of a conceptual difference with GCC here. As far as I can tell in GCC it doesn't matter if "rn", "wn", "xn" or even "bn" is used, this refers to register 0. The Operand constraint such as %w0 is used to control the substitution so the r registers aren't strictly aliases like the other registers. The comment

> // The S/D/Q and W/X registers overlap, but aren't really aliases; we 
>  //don't want to substitute one of these for a different-sized one.

suggests that this may have been the intent that Clang behave differently to GCC in this respect. For example in Clang there appears to be a bit more significance placed on the "wn" or "xn", for example clang will warn in the following example, whereas gcc will not:

  long f2(int i) {
      register int x asm("w6");
      register int y asm("w7");
      register int z asm("w8");
      asm("add %0, %1, %2\n": "=r"(x) : "r"(y), "r"(z));
      return y;
  }
  
  t2.c:5:34: warning: value size does not match register size specified by the
        constraint and modifier [-Wasm-operand-widths]
      asm("add %0, %1, %2\n": "=r"(x) : "r"(y), "r"(z));
                       ^~
                       %w0
  // and so on for %1 and %2.               

Having said all that, clang will not warn when the operand modifier is explicit, for example:

  long f2(int i) {
      register long x asm("w6");
      register long y asm("w7");
      register long z asm("w8");
      asm("add %w0, %w1, %w2\n": "=r"(x) : "r"(y), "r"(z));
      return y;
  }

At the moment I'm not too sure what to make of this. Strictly speaking I think "rn" is an unsized register that Clang shouldn't warn about size mismatch in the operand modifier. With the implementation above it won't because we default to xn and clang doesn't seem to warn when there is an explicit modifier for wn, although this could change in the future.

I'd be very interested to hear other opinions on this? If register rn is to be supported perhaps a test that clang doesn't warn when asm("rn") is used with the operand modifier %wn is used.


Repository:
  rC Clang

https://reviews.llvm.org/D44815





More information about the cfe-commits mailing list