blob: a3b1e1a08c5101819806fe65ea13c88313d17def [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
Akira Hatanaka8c26ea62015-11-18 00:15:28 +00008 global_dev_hreg asm("rsp"); // device-side error
Artem Belevich5ef02c22015-08-27 19:54:21 +00009
Akira Hatanaka8c26ea62015-11-18 00:15:28 +000010register long global_host_reg asm("rsp");
Artem Belevich5ef02c22015-08-27 19:54:21 +000011register 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");
Akira Hatanaka8c26ea62015-11-18 00:15:28 +000015 register long local_host_reg asm("rsp"); // 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
Akira Hatanaka8c26ea62015-11-18 00:15:28 +000023 register long local_host_reg asm("rsp");
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:
Akira Hatanaka8c26ea62015-11-18 00:15:28 +000033// expected-error@8 {{unknown register name 'rsp' in asm}}
34// expected-error@15 {{unknown register name 'rsp' in asm}}
Artem Belevich5ef02c22015-08-27 19:54:21 +000035#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