brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 9354087 Raw
51 lines · c
1// RUN: %clang_cc1 -triple thumbv7m -fsyntax-only -verify %s2// RUN: %clang_cc1 -triple thumbv8m.main -fsyntax-only -verify %s3// RUN: %clang_cc1 -triple armv8.1m.main -fsyntax-only -verify %s4 5// All these architecture versions provide 1-, 2- or 4-byte exclusive accesses,6// but don't have the LDREXD instruction which takes two operand registers and7// performs an 8-byte exclusive access. So the calls with a pointer to long8// long are rejected.9 10int test_ldrex(char *addr) {11  int sum = 0;12  sum += __builtin_arm_ldrex(addr);13  sum += __builtin_arm_ldrex((short *)addr);14  sum += __builtin_arm_ldrex((int *)addr);15  sum += __builtin_arm_ldrex((long long *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2 or 4 byte type}}16  return sum;17}18 19int test_strex(char *addr) {20  int res = 0;21  res |= __builtin_arm_strex(4, addr);22  res |= __builtin_arm_strex(42, (short *)addr);23  res |= __builtin_arm_strex(42, (int *)addr);24  res |= __builtin_arm_strex(42, (long long *)addr); // expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2 or 4 byte type}}25  return res;26}27 28int test_ldrexd(char *addr) {29  int sum = 0;30  sum += __builtin_arm_ldrexd(addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}31  sum += __builtin_arm_ldrexd((short *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}32  sum += __builtin_arm_ldrexd((int *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}33  sum += __builtin_arm_ldrexd((long long *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}34  sum += __builtin_arm_ldrexd((unsigned long long *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}35  sum += __builtin_arm_ldrexd((float *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}36  sum += __builtin_arm_ldrexd((double *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}37  return sum;38}39 40int test_strexd(char *addr) {41  int res = 0;42  res |= __builtin_arm_strexd(4, addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}43  res |= __builtin_arm_strexd(42, (short *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}44  res |= __builtin_arm_strexd(42, (int *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}45  res |= __builtin_arm_strexd(42, (long long *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}46  res |= __builtin_arm_strexd(42, (unsigned long long *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}47  res |= __builtin_arm_strexd(2.71828f, (float *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}48  res |= __builtin_arm_strexd(3.14159, (double *)addr); // expected-error {{eight-byte load and store exclusive builtins are not available on this architecture}}49  return res;50}51