[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / inline-asm-validate-aarch64.c
blob014767d5a3923e902c6d2069e0898f16a550d322
1 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
3 typedef unsigned char uint8_t;
5 uint8_t constraint_r(uint8_t *addr) {
6 uint8_t byte;
8 __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");
9 // CHECK: warning: value size does not match register size specified by the constraint and modifier
10 // CHECK: note: use constraint modifier "w"
11 // CHECK: fix-it:{{.*}}:{8:26-8:28}:"%w0"
13 return byte;
16 uint8_t constraint_r_symbolic(uint8_t *addr) {
17 uint8_t byte;
19 __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
20 // CHECK: warning: value size does not match register size specified by the constraint and modifier
21 // CHECK: note: use constraint modifier "w"
22 // CHECK: fix-it:{{.*}}:{19:26-19:31}:"%w[s0]"
24 return byte;
27 #define PERCENT "%"
29 uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
30 uint8_t byte;
32 __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
33 // CHECK: warning: value size does not match register size specified by the constraint and modifier
34 // CHECK: note: use constraint modifier "w"
35 // CHECK-NOT: fix-it
37 return byte;
40 // CHECK: warning: value size does not match register size specified by the constraint and modifier
41 // CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
42 // CHECK: note: use constraint modifier "w"
43 // CHECK: fix-it:{{.*}}:{47:17-47:19}:"%w2"
45 void read_write_modifier0(int one, int two) {
46 long wide_two = two;
47 asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
50 // CHECK-NOT: warning:
51 void read_write_modifier1(int one, int two) {
52 long wide_two = two;
53 asm ("%w0 %1" : "+r" (one), "+r" (wide_two));