brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 1e753d4 Raw
66 lines · c
1// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -verify -DVERIFY %s2// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s3 4typedef unsigned char uint8_t;5 6#ifdef VERIFY7void test_s(int i) {8  asm("" :: "s"(i)); // expected-error{{invalid input constraint 's' in asm}}9 10  /// Codegen error11  asm("" :: "S"(i));12  asm("" :: "S"(test_s(i))); // expected-error{{invalid type 'void' in asm input for constraint 'S'}}13}14#else15uint8_t constraint_r(uint8_t *addr) {16  uint8_t byte;17 18  __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");19// CHECK: warning: value size does not match register size specified by the constraint and modifier20// CHECK: note: use constraint modifier "w"21// CHECK: fix-it:{{.*}}:{[[#@LINE-3]]:26-[[#@LINE-3]]:28}:"%w0"22 23  return byte;24}25 26uint8_t constraint_r_symbolic(uint8_t *addr) {27  uint8_t byte;28 29  __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");30// CHECK: warning: value size does not match register size specified by the constraint and modifier31// CHECK: note: use constraint modifier "w"32// CHECK: fix-it:{{.*}}:{[[#@LINE-3]]:26-[[#@LINE-3]]:31}:"%w[s0]"33 34  return byte;35}36 37#define PERCENT "%"38 39uint8_t constraint_r_symbolic_macro(uint8_t *addr) {40  uint8_t byte;41 42  __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");43// CHECK: warning: value size does not match register size specified by the constraint and modifier44// CHECK: note: use constraint modifier "w"45// CHECK-NOT: fix-it46 47  return byte;48}49 50// CHECK: warning: value size does not match register size specified by the constraint and modifier51// CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));52// CHECK: note: use constraint modifier "w"53 54void read_write_modifier0(int one, int two) {55  long wide_two = two;56  asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));57// CHECK: fix-it:{{.*}}:{[[#@LINE-1]]:17-[[#@LINE-1]]:19}:"%w2"58}59 60// CHECK-NOT: warning: 61void read_write_modifier1(int one, int two) {62  long wide_two = two;63  asm ("%w0 %1" : "+r" (one), "+r" (wide_two));64}65#endif66