From 206a510e5406fcab172b15a11cea64b65c953823 Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Fri, 23 Dec 2016 15:34:51 +0000 Subject: [PATCH] AMDGPU: split ret/noret patterns for global atomics Differential Revision: https://reviews.llvm.org/D27989 llvm-svn: 290435 --- llvm/lib/Target/AMDGPU/AMDGPUInstructions.td | 62 +++++++++++++++----- llvm/lib/Target/AMDGPU/FLATInstructions.td | 4 +- llvm/lib/Target/AMDGPU/SIInstrInfo.td | 4 +- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td index c49866da5d3e..513df3a9cdf3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td @@ -363,24 +363,54 @@ multiclass AtomicCmpSwapLocal { defm atomic_cmp_swap : AtomicCmpSwapLocal ; -class global_binary_atomic_op : PatFrag< - (ops node:$ptr, node:$value), - (atomic_op node:$ptr, node:$value), - [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;}] ->; +multiclass global_binary_atomic_op { + def "" : PatFrag< + (ops node:$ptr, node:$value), + (atomic_op node:$ptr, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;}]>; -def atomic_swap_global : global_binary_atomic_op; -def atomic_add_global : global_binary_atomic_op; -def atomic_and_global : global_binary_atomic_op; -def atomic_max_global : global_binary_atomic_op; -def atomic_min_global : global_binary_atomic_op; -def atomic_or_global : global_binary_atomic_op; -def atomic_sub_global : global_binary_atomic_op; -def atomic_umax_global : global_binary_atomic_op; -def atomic_umin_global : global_binary_atomic_op; -def atomic_xor_global : global_binary_atomic_op; + def _noret : PatFrag< + (ops node:$ptr, node:$value), + (atomic_op node:$ptr, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && (SDValue(N, 0).use_empty());}]>; -def atomic_cmp_swap_global : global_binary_atomic_op; + def _ret : PatFrag< + (ops node:$ptr, node:$value), + (atomic_op node:$ptr, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && (!SDValue(N, 0).use_empty());}]>; +} + +defm atomic_swap_global : global_binary_atomic_op; +defm atomic_add_global : global_binary_atomic_op; +defm atomic_and_global : global_binary_atomic_op; +defm atomic_max_global : global_binary_atomic_op; +defm atomic_min_global : global_binary_atomic_op; +defm atomic_or_global : global_binary_atomic_op; +defm atomic_sub_global : global_binary_atomic_op; +defm atomic_umax_global : global_binary_atomic_op; +defm atomic_umin_global : global_binary_atomic_op; +defm atomic_xor_global : global_binary_atomic_op; + +//legacy +def AMDGPUatomic_cmp_swap_global : PatFrag< + (ops node:$ptr, node:$value), + (AMDGPUatomic_cmp_swap node:$ptr, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;}]>; + +def atomic_cmp_swap_global : PatFrag< + (ops node:$ptr, node:$cmp, node:$value), + (atomic_cmp_swap node:$ptr, node:$cmp, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;}]>; + +def atomic_cmp_swap_global_noret : PatFrag< + (ops node:$ptr, node:$cmp, node:$value), + (atomic_cmp_swap node:$ptr, node:$cmp, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && (SDValue(N, 0).use_empty());}]>; + +def atomic_cmp_swap_global_ret : PatFrag< + (ops node:$ptr, node:$cmp, node:$value), + (atomic_cmp_swap node:$ptr, node:$cmp, node:$value), + [{return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && (!SDValue(N, 0).use_empty());}]>; //===----------------------------------------------------------------------===// // Misc Pattern Fragments diff --git a/llvm/lib/Target/AMDGPU/FLATInstructions.td b/llvm/lib/Target/AMDGPU/FLATInstructions.td index a46970b1fca0..849fb8ad50f5 100644 --- a/llvm/lib/Target/AMDGPU/FLATInstructions.td +++ b/llvm/lib/Target/AMDGPU/FLATInstructions.td @@ -372,7 +372,7 @@ def : FlatAtomicPat ; def : FlatAtomicPat ; def : FlatAtomicPat ; def : FlatAtomicPat ; -def : FlatAtomicPat ; +def : FlatAtomicPat ; def : FlatAtomicPat ; def : FlatAtomicPat ; @@ -386,7 +386,7 @@ def : FlatAtomicPat ; def : FlatAtomicPat ; def : FlatAtomicPat ; def : FlatAtomicPat ; -def : FlatAtomicPat ; +def : FlatAtomicPat ; def : FlatAtomicPat ; } // End Predicates = [isCIVI] diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td index 7fb3f42a8a6a..0b57085dd38d 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -94,8 +94,8 @@ def SIpc_add_rel_offset : SDNode<"AMDGPUISD::PC_ADD_REL_OFFSET", // PatFrags for global memory operations //===----------------------------------------------------------------------===// -def atomic_inc_global : global_binary_atomic_op; -def atomic_dec_global : global_binary_atomic_op; +defm atomic_inc_global : global_binary_atomic_op; +defm atomic_dec_global : global_binary_atomic_op; //===----------------------------------------------------------------------===// // SDNodes and PatFrag for local loads and stores to enable s_mov_b32 m0, -1