blob: ebf44243d9d68b3047cb3251a8dbe5ae4c4c6821 [file] [log] [blame]
Artem Belevich5ef02c22015-08-27 19:54:21 +00001// REQUIRES: x86-registered-target
2// REQUIRES: nvptx-registered-target
Artem Belevich5196fe72015-03-19 18:40:25 +00003// 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 Belevich5ef02c22015-08-27 19:54:21 +00005
6__attribute__((device)) register long global_dev_reg asm("r0");
7__attribute__((device)) register long
8 global_dev_hreg asm("rax"); // device-side error
9
10register long global_host_reg asm("rax");
11register long global_host_dreg asm("r0"); // host-side error
Artem Belevich5196fe72015-03-19 18:40:25 +000012
13__attribute__((device)) void df() {
Artem Belevich5ef02c22015-08-27 19:54:21 +000014 register long local_dev_reg asm("r0");
15 register long local_host_reg asm("rax"); // device-side error
Artem Belevich5196fe72015-03-19 18:40:25 +000016 short h;
17 // asm with PTX constraints. Some of them are PTX-specific.
Artem Belevich5ef02c22015-08-27 19:54:21 +000018 __asm__("dont care" : "=h"(h) : "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0));
Artem Belevich5196fe72015-03-19 18:40:25 +000019}
20
21void hf() {
Artem Belevich5ef02c22015-08-27 19:54:21 +000022 register long local_dev_reg asm("r0"); // host-side error
23 register long local_host_reg asm("rax");
Artem Belevich5196fe72015-03-19 18:40:25 +000024 int a;
Artem Belevich5ef02c22015-08-27 19:54:21 +000025 // 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 Belevich5196fe72015-03-19 18:40:25 +000027}
Artem Belevich5ef02c22015-08-27 19:54:21 +000028
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 'rax' in asm}}
34// expected-error@15 {{unknown register name 'rax' 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