From 639545b4d8aa3609346fdde711e6918bab129df2 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Fri, 19 Aug 2016 16:57:05 +0000 Subject: [PATCH] [Hexagon] Enforce LLSC packetization rules 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 | 18 ++++++++++++++++++ llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index e0f8b44..b2acace 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -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 index 0000000..966945b --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/intrinsics/llsc_bundling.ll @@ -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 } -- 2.7.4