nir: Unify memory atomics
Avoids some copypaste and makes it easier to see how the different types relate. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8847>
This commit is contained in:

committed by
Marge Bot

parent
ee8ea0cf86
commit
8578adeaa6
@@ -582,41 +582,21 @@ intrinsic("vulkan_resource_reindex", src_comp=[0, 1], dest_comp=0,
|
||||
intrinsic("load_vulkan_descriptor", src_comp=[-1], dest_comp=0,
|
||||
indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
|
||||
|
||||
# variable atomic intrinsics
|
||||
# atomic intrinsics
|
||||
#
|
||||
# All of these variable atomic memory operations read a value from memory,
|
||||
# compute a new value using one of the operations below, write the new value
|
||||
# to memory, and return the original value read.
|
||||
# All of these atomic memory operations read a value from memory, compute a new
|
||||
# value using one of the operations below, write the new value to memory, and
|
||||
# return the original value read.
|
||||
#
|
||||
# All operations take 2 sources except CompSwap that takes 3. These sources
|
||||
# represent:
|
||||
# All variable operations take 2 sources except CompSwap that takes 3. These
|
||||
# sources represent:
|
||||
#
|
||||
# 0: A deref to the memory on which to perform the atomic
|
||||
# 1: The data parameter to the atomic function (i.e. the value to add
|
||||
# in shared_atomic_add, etc).
|
||||
# 2: For CompSwap only: the second data parameter.
|
||||
intrinsic("deref_atomic_add", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_imin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_umin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_imax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_umax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_and", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_or", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_xor", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_exchange", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_comp_swap", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_fadd", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_fmin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_fmax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("deref_atomic_fcomp_swap", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
|
||||
# SSBO atomic intrinsics
|
||||
#
|
||||
# All of the SSBO atomic memory operations read a value from memory,
|
||||
# compute a new value using one of the operations below, write the new
|
||||
# value to memory, and return the original value read.
|
||||
#
|
||||
# All operations take 3 sources except CompSwap that takes 4. These
|
||||
# All SSBO operations take 3 sources except CompSwap that takes 4. These
|
||||
# sources represent:
|
||||
#
|
||||
# 0: The SSBO buffer index.
|
||||
@@ -625,77 +605,50 @@ intrinsic("deref_atomic_fcomp_swap", src_comp=[-1, 1, 1], dest_comp=1, indices=[
|
||||
# 2: The data parameter to the atomic function (i.e. the value to add
|
||||
# in ssbo_atomic_add, etc).
|
||||
# 3: For CompSwap only: the second data parameter.
|
||||
intrinsic("ssbo_atomic_add", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_imin", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_umin", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_imax", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_umax", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_and", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_or", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_xor", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_exchange", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_comp_swap", src_comp=[-1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_fadd", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_fmin", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_fmax", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_fcomp_swap", src_comp=[-1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
|
||||
# CS shared variable atomic intrinsics
|
||||
#
|
||||
# All of the shared variable atomic memory operations read a value from
|
||||
# memory, compute a new value using one of the operations below, write the
|
||||
# new value to memory, and return the original value read.
|
||||
#
|
||||
# All operations take 2 sources except CompSwap that takes 3. These
|
||||
# sources represent:
|
||||
# All shared variable operations take 2 sources except CompSwap that takes 3.
|
||||
# These sources represent:
|
||||
#
|
||||
# 0: The offset into the shared variable storage region that the atomic
|
||||
# operation will operate on.
|
||||
# 1: The data parameter to the atomic function (i.e. the value to add
|
||||
# in shared_atomic_add, etc).
|
||||
# 2: For CompSwap only: the second data parameter.
|
||||
intrinsic("shared_atomic_add", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_imin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_umin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_imax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_umax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_and", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_or", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_xor", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_fadd", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_fmin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_fmax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("shared_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
|
||||
# Global atomic intrinsics
|
||||
#
|
||||
# All of the shared variable atomic memory operations read a value from
|
||||
# memory, compute a new value using one of the operations below, write the
|
||||
# new value to memory, and return the original value read.
|
||||
#
|
||||
# All operations take 2 sources except CompSwap that takes 3. These
|
||||
# All global operations take 2 sources except CompSwap that takes 3. These
|
||||
# sources represent:
|
||||
#
|
||||
# 0: The memory address that the atomic operation will operate on.
|
||||
# 1: The data parameter to the atomic function (i.e. the value to add
|
||||
# in shared_atomic_add, etc).
|
||||
# 2: For CompSwap only: the second data parameter.
|
||||
intrinsic("global_atomic_add", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_imin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_umin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_imax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_umax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_and", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_or", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_xor", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_fadd", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_fmin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_fmax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
|
||||
def memory_atomic_data1(name):
|
||||
intrinsic("deref_atomic_" + name, src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_" + name, src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("shared_atomic_" + name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_" + name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
|
||||
|
||||
def memory_atomic_data2(name):
|
||||
intrinsic("deref_atomic_" + name, src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("ssbo_atomic_" + name, src_comp=[-1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
|
||||
intrinsic("shared_atomic_" + name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
intrinsic("global_atomic_" + name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
|
||||
|
||||
memory_atomic_data1("add")
|
||||
memory_atomic_data1("imin")
|
||||
memory_atomic_data1("umin")
|
||||
memory_atomic_data1("imax")
|
||||
memory_atomic_data1("umax")
|
||||
memory_atomic_data1("and")
|
||||
memory_atomic_data1("or")
|
||||
memory_atomic_data1("xor")
|
||||
memory_atomic_data1("exchange")
|
||||
memory_atomic_data1("fadd")
|
||||
memory_atomic_data1("fmin")
|
||||
memory_atomic_data1("fmax")
|
||||
memory_atomic_data2("comp_swap")
|
||||
memory_atomic_data2("fcomp_swap")
|
||||
|
||||
def system_value(name, dest_comp, indices=[], bit_sizes=[32]):
|
||||
intrinsic("load_" + name, [], dest_comp, indices,
|
||||
|
Reference in New Issue
Block a user