OSDN Git Service

[Hexagon] Add inline-asm constraint 'a' for modifier register class
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Fri, 21 Jul 2017 17:51:27 +0000 (17:51 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Fri, 21 Jul 2017 17:51:27 +0000 (17:51 +0000)
For example
  asm ("memw(%0++%1) = %2" : : "r"(addr),"a"(mod),"r"(val) : "memory")

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

lib/Target/Hexagon/HexagonISelLowering.cpp
test/CodeGen/Hexagon/inline-asm-a.ll [new file with mode: 0644]

index 1291af8..f02cd6d 100644 (file)
@@ -2923,7 +2923,11 @@ HexagonTargetLowering::getConstraintType(StringRef Constraint) const {
       case 'q':
       case 'v':
         if (Subtarget.useHVXOps())
-          return C_Register;
+          return C_RegisterClass;
+        break;
+      case 'a':
+        return C_RegisterClass;
+      default:
         break;
     }
   }
@@ -2951,6 +2955,9 @@ HexagonTargetLowering::getRegForInlineAsmConstraint(
       case MVT::f64:
         return std::make_pair(0U, &Hexagon::DoubleRegsRegClass);
       }
+      break;
+    case 'a': // M0-M1
+      return std::make_pair(0U, &Hexagon::ModRegsRegClass);
     case 'q': // q0-q3
       switch (VT.getSizeInBits()) {
       default:
@@ -2960,6 +2967,7 @@ HexagonTargetLowering::getRegForInlineAsmConstraint(
       case 1024:
         return std::make_pair(0U, &Hexagon::VecPredRegs128BRegClass);
       }
+      break;
     case 'v': // V0-V31
       switch (VT.getSizeInBits()) {
       default:
@@ -2973,7 +2981,7 @@ HexagonTargetLowering::getRegForInlineAsmConstraint(
       case 2048:
         return std::make_pair(0U, &Hexagon::VecDblRegs128BRegClass);
       }
-
+      break;
     default:
       llvm_unreachable("Unknown asm register class");
     }
diff --git a/test/CodeGen/Hexagon/inline-asm-a.ll b/test/CodeGen/Hexagon/inline-asm-a.ll
new file mode 100644 (file)
index 0000000..08862d9
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+
+; Check that constraint a is handled correctly.
+; CHECK: [[M:m[01]]] = r1
+; CHECK: memw(r0++[[M]]) = r2
+
+target triple = "hexagon"
+
+; Function Attrs: nounwind
+define void @foo(i32* %a, i32 %m, i32 %v) #0 {
+entry:
+  tail call void asm sideeffect "memw($0++$1) = $2", "r,a,r,~{memory}"(i32* %a, i32 %m, i32 %v)
+  ret void
+}
+
+attributes #0 = { nounwind "target-cpu"="hexagonv60" }