inline-asm-validate-aarch64.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
  2. typedef unsigned char uint8_t;
  3. uint8_t constraint_r(uint8_t *addr) {
  4. uint8_t byte;
  5. __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");
  6. // CHECK: warning: value size does not match register size specified by the constraint and modifier
  7. // CHECK: note: use constraint modifier "w"
  8. // CHECK: fix-it:{{.*}}:{8:26-8:28}:"%w0"
  9. return byte;
  10. }
  11. uint8_t constraint_r_symbolic(uint8_t *addr) {
  12. uint8_t byte;
  13. __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
  14. // CHECK: warning: value size does not match register size specified by the constraint and modifier
  15. // CHECK: note: use constraint modifier "w"
  16. // CHECK: fix-it:{{.*}}:{19:26-19:31}:"%w[s0]"
  17. return byte;
  18. }
  19. #define PERCENT "%"
  20. uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
  21. uint8_t byte;
  22. __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
  23. // CHECK: warning: value size does not match register size specified by the constraint and modifier
  24. // CHECK: note: use constraint modifier "w"
  25. // CHECK-NOT: fix-it
  26. return byte;
  27. }
  28. // CHECK: warning: value size does not match register size specified by the constraint and modifier
  29. // CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
  30. // CHECK: note: use constraint modifier "w"
  31. // CHECK: fix-it:{{.*}}:{47:17-47:19}:"%w2"
  32. void read_write_modifier0(int one, int two) {
  33. long wide_two = two;
  34. asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
  35. }
  36. // CHECK-NOT: warning:
  37. void read_write_modifier1(int one, int two) {
  38. long wide_two = two;
  39. asm ("%w0 %1" : "+r" (one), "+r" (wide_two));
  40. }