40 lines · plain
1// REQUIRES: x86-registered-target2// REQUIRES: nvptx-registered-target3// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify %s4// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s5 6__attribute__((device)) register long global_dev_reg asm("r0");7__attribute__((device)) register long8 global_dev_hreg asm("rsp"); // device-side error9 10register long global_host_reg asm("rsp");11register long global_host_dreg asm("r0"); // host-side error12 13__attribute__((device)) void df() {14 register long local_dev_reg asm("r0");15 register long local_host_reg asm("rsp"); // device-side error16 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 21void hf() {22 register long local_dev_reg asm("r0"); // host-side error23 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#else36// Host-side compilation:37// expected-error@11 {{unknown register name 'r0' in asm}}38// expected-error@22 {{unknown register name 'r0' in asm}}39#endif40