[PATCH] [mips] Add support for 'ZC' inline assembly memory constraint.

Daniel Sanders daniel.sanders at imgtec.com
Fri Mar 20 02:44:32 PDT 2015


Fix missing return.


http://reviews.llvm.org/D8449

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/mips-inline-asm.c

Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5932,7 +5932,28 @@
     case 'R': // An address that can be used in a non-macro load or store
       Info.setAllowsMemory();
       return true;
+    case 'Z':
+      if (Name[1] == 'C') { // An address usable by ll, and sc.
+        Info.setAllowsMemory();
+        Name++; // Skip over 'Z'.
+        return true;
+      }
+      return false;
+    }
+  }
+
+  std::string convertConstraint(const char *&Constraint) const override {
+    std::string R;
+    switch (*Constraint) {
+    case 'Z': // Two-character constraint; add "^" hint for later parsing.
+      if (Constraint[1] == 'C') {
+        R = std::string("^") + std::string(Constraint, 2);
+        Constraint++;
+        return R;
+      }
+      break;
     }
+    return TargetInfo::convertConstraint(Constraint);
   }
 
   const char *getClobbers() const override {
Index: test/CodeGen/mips-inline-asm.c
===================================================================
--- /dev/null
+++ test/CodeGen/mips-inline-asm.c
@@ -0,0 +1,19 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int data;
+
+void m () {
+  asm("lw $1, %0" :: "m"(data));
+  // CHECK: call void asm sideeffect "lw $$1, $0", "*m,~{$1}"(i32* @data)
+}
+
+void ZC () {
+  asm("ll $1, %0" :: "ZC"(data));
+  // CHECK: call void asm sideeffect "ll $$1, $0", "*^ZC,~{$1}"(i32* @data)
+}
+
+void R () {
+  asm("lw $1, %0" :: "R"(data));
+  // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8449.22336.patch
Type: text/x-patch
Size: 1670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150320/92d668ac/attachment.bin>


More information about the cfe-commits mailing list