]> granicus.if.org Git - clang/commitdiff
AMDGPU: Add support for 's' and 'v' asm constraints
authorTom Stellard <thomas.stellard@amd.com>
Thu, 19 Nov 2015 22:11:58 +0000 (22:11 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Thu, 19 Nov 2015 22:11:58 +0000 (22:11 +0000)
Summary: 's' is used to specify sgprs and 'v' is used to specify vgprs.

Reviewers: arsenm, echristo

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14307

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253610 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/Sema/inline-asm-validate-amdgpu.cl [new file with mode: 0644]

index 648ef4b3d2640cd8587d5d0d54acc797ba2b4f12..697a9f232e05465d6eacbe454b6eb3df589148eb 100644 (file)
@@ -1826,8 +1826,15 @@ public:
   }
 
   bool validateAsmConstraint(const char *&Name,
-                             TargetInfo::ConstraintInfo &info) const override {
-    return true;
+                             TargetInfo::ConstraintInfo &Info) const override {
+    switch (*Name) {
+    default: break;
+    case 'v': // vgpr
+    case 's': // sgpr
+      Info.setAllowsRegister();
+      return true;
+    }
+    return false;
   }
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override {
diff --git a/test/Sema/inline-asm-validate-amdgpu.cl b/test/Sema/inline-asm-validate-amdgpu.cl
new file mode 100644 (file)
index 0000000..d60b09e
--- /dev/null
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}