[Hexagon] Enforce LLSC packetization rules
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Fri, 19 Aug 2016 16:57:05 +0000 (16:57 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Fri, 19 Aug 2016 16:57:05 +0000 (16:57 +0000)
Ensure that load locked and store conditional instructions are only
packetized with ALU32 instructions.

Patch by Ben Craig.

llvm-svn: 279272

llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll [new file with mode: 0644]

index e0f8b44..b2acace 100644 (file)
@@ -1031,6 +1031,24 @@ static bool cannotCoexistAsymm(const MachineInstr &MI, const MachineInstr &MJ,
     return MJ.isInlineAsm() || MJ.isBranch() || MJ.isBarrier() ||
            MJ.isCall() || MJ.isTerminator();
 
+  switch (MI.getOpcode()) {
+  case (Hexagon::S2_storew_locked):
+  case (Hexagon::S4_stored_locked):
+  case (Hexagon::L2_loadw_locked):
+  case (Hexagon::L4_loadd_locked):
+  case (Hexagon::Y4_l2fetch): {
+    // These instructions can only be grouped with ALU32 or non-floating-point
+    // XTYPE instructions.  Since there is no convenient way of identifying fp
+    // XTYPE instructions, only allow grouping with ALU32 for now.
+    unsigned TJ = HII.getType(MJ);
+    if (TJ != HexagonII::TypeALU32)
+      return true;
+    break;
+  }
+  default:
+    break;
+  }
+
   // "False" really means that the quick check failed to determine if
   // I and J cannot coexist.
   return false;
diff --git a/llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll b/llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll
new file mode 100644 (file)
index 0000000..966945b
--- /dev/null
@@ -0,0 +1,12 @@
+; RUN: llc -march=hexagon < %s
+target triple = "hexagon-unknown--elf"
+
+; Function Attrs: norecurse nounwind
+define void @_Z4lockv() #0 {
+entry:
+  %__shared_owners = alloca i32, align 4
+  %0 = cmpxchg weak i32* %__shared_owners, i32 0, i32 1 seq_cst seq_cst
+  ret void
+}
+
+attributes #0 = { nounwind }