| 1 |
// REQUIRES: x86-registered-target |
| 2 |
// REQUIRES: nvptx-registered-target |
| 3 |
// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify %s |
| 4 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s |
| 5 |
|
| 6 |
__attribute__((device)) register long global_dev_reg asm("r0"); |
| 7 |
__attribute__((device)) register long |
| 8 |
global_dev_hreg asm("rsp"); // device-side error |
| 9 |
|
| 10 |
register long global_host_reg asm("rsp"); |
| 11 |
register long global_host_dreg asm("r0"); // host-side error |
| 12 |
|
| 13 |
__attribute__((device)) void df() { |
| 14 |
register long local_dev_reg asm("r0"); |
| 15 |
register long local_host_reg asm("rsp"); // device-side error |
| 16 |
short h; |
| 17 |
// asm with PTX constraints. Some of them are PTX-specific. |
| 18 |
__asm__("dont care" : "=h"(h) : "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0)); |
| 19 |
} |
| 20 |
|
| 21 |
void hf() { |
| 22 |
register long local_dev_reg asm("r0"); // host-side error |
| 23 |
register long local_host_reg asm("rsp"); |
| 24 |
int a; |
| 25 |
// Asm with x86 constraints and registers that are not supported by PTX. |
| 26 |
__asm__("dont care" : "=a"(a) : "a"(0), "b"(0), "c"(0) : "flags"); |
| 27 |
} |
| 28 |
|
| 29 |
// Check errors in named register variables. |
| 30 |
// We should only see errors relevant to current compilation mode. |
| 31 |
#if defined(__CUDA_ARCH__) |
| 32 |
// Device-side compilation: |
| 33 |
// expected-error@8 {{unknown register name 'rsp' in asm}} |
| 34 |
// expected-error@15 {{unknown register name 'rsp' in asm}} |
| 35 |
#else |
| 36 |
// Host-side compilation: |
| 37 |
// expected-error@11 {{unknown register name 'r0' in asm}} |
| 38 |
// expected-error@22 {{unknown register name 'r0' in asm}} |
| 39 |
#endif |