Index: lib/Target/AMDGPU/AMDGPUInstructions.td =================================================================== --- lib/Target/AMDGPU/AMDGPUInstructions.td +++ lib/Target/AMDGPU/AMDGPUInstructions.td @@ -363,24 +363,54 @@ 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;}] ->; - -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 atomic_cmp_swap_global : global_binary_atomic_op; +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 _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 _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 Index: lib/Target/AMDGPU/FLATInstructions.td =================================================================== --- lib/Target/AMDGPU/FLATInstructions.td +++ lib/Target/AMDGPU/FLATInstructions.td @@ -372,7 +372,7 @@ 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 ; } // End Predicates = [isCIVI] Index: lib/Target/AMDGPU/SIInstrInfo.td =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.td +++ lib/Target/AMDGPU/SIInstrInfo.td @@ -81,8 +81,8 @@ // 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