Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-registered-target |
| 2 | // REQUIRES: nvptx-registered-target |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 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 |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 5 | |
| 6 | __attribute__((device)) register long global_dev_reg asm("r0"); |
| 7 | __attribute__((device)) register long |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 8 | global_dev_hreg asm("rsp"); // device-side error |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 9 | |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 10 | register long global_host_reg asm("rsp"); |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 11 | register long global_host_dreg asm("r0"); // host-side error |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 12 | |
| 13 | __attribute__((device)) void df() { |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 14 | register long local_dev_reg asm("r0"); |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 15 | register long local_host_reg asm("rsp"); // device-side error |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 16 | short h; |
| 17 | // asm with PTX constraints. Some of them are PTX-specific. |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 18 | __asm__("dont care" : "=h"(h) : "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0)); |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | void hf() { |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 22 | register long local_dev_reg asm("r0"); // host-side error |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 23 | register long local_host_reg asm("rsp"); |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 24 | int a; |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 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"); |
Artem Belevich | 5196fe7 | 2015-03-19 18:40:25 +0000 | [diff] [blame] | 27 | } |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 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: |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 33 | // expected-error@8 {{unknown register name 'rsp' in asm}} |
| 34 | // expected-error@15 {{unknown register name 'rsp' in asm}} |
Artem Belevich | 5ef02c2 | 2015-08-27 19:54:21 +0000 | [diff] [blame] | 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 |