agx: drop encoding masks

unused and will now never be used, since we have the XML for this instead.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35189>
This commit is contained in:
Alyssa Rosenzweig
2025-05-27 16:07:47 -04:00
committed by Marge Bot
parent 65a5ff67e9
commit 870bde17d0
+60 -117
View File
@@ -31,14 +31,13 @@ class Immediate(object):
class Encoding(object):
def __init__(self, description):
(exact, mask, length_short, length_long) = description
(exact, length_short, length_long) = description
# Convenience
if length_long is None:
length_long = length_short
self.exact = exact
self.mask = mask
self.length_short = length_short
self.extensible = length_short != length_long
@@ -189,16 +188,12 @@ FUNOP = lambda x: (x << 28)
FUNOP_MASK = FUNOP((1 << 14) - 1)
def funop(name, opcode, schedule_class = "none"):
op(name, (0x0A | (opcode << 28),
0x3F | (((1 << 14) - 1) << 28), 4, 6),
op(name, (0x0A | (opcode << 28), 4, 6),
srcs = 1, is_float = True, schedule_class = schedule_class)
def iunop(name, opcode):
assert(opcode < 4)
op(name, (0x3E | (opcode << 26),
0x7F | L | (((1 << 14) - 1) << 26),
6, _),
srcs = 1)
op(name, (0x3E | (opcode << 26), 6, _), srcs = 1)
# Listing of opcodes
funop("floor", 0b000000)
@@ -219,63 +214,25 @@ iunop("bitrev", 0b01)
iunop("popcount", 0b10)
iunop("ffs", 0b11)
op("fadd",
encoding = (0x2A, 0x3F, 4, 6),
srcs = 2, is_float = True)
op("ffma",
encoding = (0x3A, 0x3F, 6, 8),
srcs = 3, is_float = True)
op("fmul",
encoding = (0x1A, 0x3F, 4, 6),
srcs = 2, is_float = True)
op("hadd",
encoding = (0x26, 0x3F, 4, 6),
srcs = 2, is_float = True)
op("hfma",
encoding = (0x36, 0x3F, 6, 8),
srcs = 3, is_float = True)
op("hmul",
encoding = (0x16, 0x3F, 4, 6),
srcs = 2, is_float = True)
op("mov_imm",
encoding = (0x62, 0xFF, 6, 8),
imms = [IMM])
op("iadd",
encoding = (0x0E, 0x3F | L, 8, _),
srcs = 2, imms = [SHIFT])
op("imad",
encoding = (0x1E, 0x3F | L, 8, _),
srcs = 3, imms = [SHIFT])
op("bfi",
encoding = (0x2E, 0x7F | (0x3 << 26), 8, _),
srcs = 3, imms = [BFI_MASK])
op("bfeil",
encoding = (0x2E | L, 0x7F | L | (0x3 << 26), 8, _),
srcs = 3, imms = [BFI_MASK])
op("extr",
encoding = (0x2E | (0x1 << 26), 0x7F | L | (0x3 << 26), 8, _),
srcs = 3, imms = [BFI_MASK])
op("asr",
encoding = (0x2E | L | (0x1 << 26), 0x7F | L | (0x3 << 26), 8, _),
srcs = 2)
op("fadd", encoding = (0x2A, 4, 6), srcs = 2, is_float = True)
op("ffma", encoding = (0x3A, 6, 8), srcs = 3, is_float = True)
op("fmul", encoding = (0x1A, 4, 6), srcs = 2, is_float = True)
op("hadd", encoding = (0x26, 4, 6), srcs = 2, is_float = True)
op("hfma", encoding = (0x36, 6, 8), srcs = 3, is_float = True)
op("hmul", encoding = (0x16, 4, 6), srcs = 2, is_float = True)
op("mov_imm", encoding = (0x62, 6, 8), imms = [IMM])
op("iadd", encoding = (0x0E, 8, _), srcs = 2, imms = [SHIFT])
op("imad", encoding = (0x1E, 8, _), srcs = 3, imms = [SHIFT])
op("bfi", encoding = (0x2E, 8, _), srcs = 3, imms = [BFI_MASK])
op("bfeil", encoding = (0x2E | L, 8, _), srcs = 3, imms = [BFI_MASK])
op("extr", encoding = (0x2E | (0x1 << 26), 8, _), srcs = 3, imms = [BFI_MASK])
op("asr", encoding = (0x2E | L | (0x1 << 26), 8, _), srcs = 2)
op("icmpsel", encoding = (0x12, 8, 10), srcs = 4, imms = [ICOND])
op("fcmpsel", encoding = (0x02, 8, 10), srcs = 4, imms = [FCOND])
def subgroup_op(name, opc):
exact = 0b01101111 | L | (opc << 29)
exact_mask = 0b11111111 | L | (0x3 << 29)
op(name, encoding = (exact, exact_mask, 6, _), srcs = 1, imms = [SIMD_OP])
op(name, encoding = (exact, 6, _), srcs = 1, imms = [SIMD_OP])
subgroup_op("quad_reduce", 0x0)
subgroup_op("simd_reduce", 0x1)
@@ -285,8 +242,7 @@ subgroup_op("simd_prefix", 0x3)
for window, w_bit in [('quad_', 0), ('', 1)]:
for s, shuffle in enumerate(['', '_xor', '_up', '_down']):
op(f"{window}shuffle{shuffle}",
encoding = (0b01101111 | (w_bit << 26) | (s << 38),
0xFF | L | (1 << 47) | (3 << 38) | (3 << 26), 6, _),
encoding = (0b01101111 | (w_bit << 26) | (s << 38), 6, _),
srcs = 2)
# Pseudo-instruction ballotting a boolean
@@ -294,108 +250,99 @@ for window, w_bit in [('quad_', 0), ('', 1)]:
for T, T_bit, cond in [('f', 0, FCOND), ('i', 1, ICOND)]:
op(f"{T}cmp_{window}ballot",
encoding = (0b0100010 | (T_bit << 4) | (w_bit << 48), 0, 8, _),
encoding = (0b0100010 | (T_bit << 4) | (w_bit << 48), 8, _),
srcs = 2, imms = [cond, INVERT_COND])
op("icmpsel",
encoding = (0x12, 0x7F, 8, 10),
srcs = 4, imms = [ICOND])
op("fcmpsel",
encoding = (0x02, 0x7F, 8, 10),
srcs = 4, imms = [FCOND])
# Pseudo-instructions for compares returning 1/0
op("icmp", _, srcs = 2, imms = [ICOND, INVERT_COND])
op("fcmp", _, srcs = 2, imms = [FCOND, INVERT_COND])
# sources are coordinates, LOD, texture bindless base (zero for texture state
# registers), texture, sampler, shadow/offset
# TODO: anything else?
op("texture_sample",
encoding = (0x31, 0x7F, 8, 10), # XXX WRONG SIZE
encoding = (0x31, 8, 10), # XXX WRONG SIZE
srcs = 6, imms = [DIM, LOD_MODE, MASK, SCOREBOARD, OFFSET, SHADOW,
QUERY_LOD, GATHER, SPARSE])
for memory, can_reorder in [("texture", True), ("image", False)]:
coherency = [COHERENT] if not can_reorder else []
op(f"{memory}_load", encoding = (0x71, 0x7F, 8, 10), # XXX WRONG SIZE
op(f"{memory}_load", encoding = (0x71, 8, 10), # XXX WRONG SIZE
srcs = 6, imms = [DIM, LOD_MODE, MASK, SCOREBOARD, OFFSET, SPARSE] + coherency,
can_reorder = can_reorder,
schedule_class = "none" if can_reorder else "load")
# sources are base, index
op("device_load",
encoding = (0x05, 0x7F, 6, 8),
encoding = (0x05, 6, 8),
srcs = 2, imms = [FORMAT, MASK, SHIFT, SCOREBOARD, COHERENT], can_reorder = False,
schedule_class = "load")
# sources are base (relative to workgroup memory), index
op("local_load",
encoding = (0b1101001, 0, 6, 8),
encoding = (0b1101001, 6, 8),
srcs = 2, imms = [FORMAT, MASK], can_reorder = False,
schedule_class = "load")
# sources are value, base, index
# TODO: Consider permitting the short form
op("device_store",
encoding = (0x45 | (1 << 47), 0, 8, _),
encoding = (0x45 | (1 << 47), 8, _),
dests = 0, srcs = 3, imms = [FORMAT, MASK, SHIFT, SCOREBOARD, COHERENT], can_eliminate = False,
schedule_class = "store")
# sources are value, base, index
op("local_store",
encoding = (0b0101001, 0, 6, 8),
encoding = (0b0101001, 6, 8),
dests = 0, srcs = 3, imms = [FORMAT, MASK],
can_eliminate=False, schedule_class = "store")
# sources are value, index
# TODO: Consider permitting the short form
op("uniform_store",
encoding = ((0b111 << 27) | 0b1000101 | (1 << 47), 0, 8, _),
encoding = ((0b111 << 27) | 0b1000101 | (1 << 47), 8, _),
dests = 0, srcs = 2, imms = [MASK], can_eliminate = False)
# sources are value, base, index
op("atomic",
encoding = (0x15 | (1 << 26) | (1 << 31) | (5 << 44), 0x3F | (1 << 26) | (1 << 31) | (5 << 44), 8, _),
encoding = (0x15 | (1 << 26) | (1 << 31) | (5 << 44), 8, _),
dests = 1, srcs = 3, imms = [ATOMIC_OPC, SCOREBOARD],
can_eliminate = False, schedule_class = "atomic")
# XXX: stop hardcoding the long form
op("local_atomic",
encoding = (0x19 | (1 << 15) | (1 << 36) | (1 << 47), 0x3F | (1 << 36) | (1 << 47), 10, _),
encoding = (0x19 | (1 << 15) | (1 << 36) | (1 << 47), 10, _),
dests = 1, srcs = 3, imms = [ATOMIC_OPC], schedule_class = "atomic",
can_eliminate = False)
op("wait", (0x38, 0xFF, 2, _), dests = 0,
op("wait", (0x38, 2, _), dests = 0,
can_eliminate = False, imms = [SCOREBOARD], schedule_class = "invalid")
for (suffix, schedule_class) in [("", "none"), ("_coverage", "coverage"), ("_barrier", "barrier")]:
op(f"get_sr{suffix}", (0x72, 0x7F | L, 4, _), dests = 1, imms = [SR],
op(f"get_sr{suffix}", (0x72, 4, _), dests = 1, imms = [SR],
schedule_class = schedule_class, can_reorder = schedule_class == "none")
op("sample_mask", (0x7fc1, 0xffff, 6, _), dests = 0, srcs = 2,
op("sample_mask", (0x7fc1, 6, _), dests = 0, srcs = 2,
can_eliminate = False, schedule_class = "coverage")
# Sources: sample mask, combined depth/stencil
op("zs_emit", (0x41, 0xFF | L, 4, _), dests = 0, srcs = 2,
op("zs_emit", (0x41, 4, _), dests = 0, srcs = 2,
can_eliminate = False, imms = [ZS], schedule_class = "coverage")
# Sources: sample mask, explicit coords (if present)
op("ld_tile", (0x49, 0x7F, 8, _), dests = 1, srcs = 2,
op("ld_tile", (0x49, 8, _), dests = 1, srcs = 2,
imms = [FORMAT, MASK, PIXEL_OFFSET, EXPLICIT_COORDS], can_reorder = False,
schedule_class = "coverage")
# Sources: value, sample mask, explicit coords (if present)
op("st_tile", (0x09, 0x7F, 8, _), dests = 0, srcs = 3,
op("st_tile", (0x09, 8, _), dests = 0, srcs = 3,
can_eliminate = False, imms = [FORMAT, MASK, PIXEL_OFFSET, EXPLICIT_COORDS],
schedule_class = "coverage")
for (name, exact) in [("any", 0xC000), ("none", 0xC020), ("none_after", 0xC020)]:
op("jmp_exec_" + name, (exact, (1 << 16) - 1, 6, _), dests = 0, srcs = 0,
op("jmp_exec_" + name, (exact, 6, _), dests = 0, srcs = 0,
can_eliminate = False, schedule_class = "invalid", imms = [TARGET])
# TODO: model implicit r0l destinations
op("pop_exec", (0x52 | (0x3 << 9), ((1 << 48) - 1) ^ (0x3 << 7) ^ (0x3 << 11), 6, _),
op("pop_exec", (0x52 | (0x3 << 9), 6, _),
dests = 0, srcs = 0, can_eliminate = False, schedule_class = "invalid",
imms = [NEST])
@@ -405,56 +352,55 @@ for is_float in [False, True]:
for (cf, cf_op) in [("if", 0), ("else", 1), ("while", 2)]:
name = "{}_{}cmp".format(cf, "f" if is_float else "i")
exact = 0x42 | (0x0 if is_float else 0x10) | (cf_op << 9)
mask = 0x7F | (0x3 << 9) | mod_mask | (0x3 << 44)
imms = [NEST, FCOND if is_float else ICOND, INVERT_COND, TARGET]
op(name, (exact, mask, 6, _), dests = 0, srcs = 2, can_eliminate = False,
op(name, (exact, 6, _), dests = 0, srcs = 2, can_eliminate = False,
imms = imms, is_float = is_float,
schedule_class = "preload" if cf == "else" else "invalid")
op("bitop", (0x7E, 0x7F, 6, _), srcs = 2, imms = [TRUTH_TABLE])
op("intl", (0x3E, 0x7F, 6, _), srcs = 2, imms = [])
op("convert", (0x3E | L, 0x7F | L | (0x3 << 38), 6, _), srcs = 2, imms = [ROUND])
op("bitop", (0x7E, 6, _), srcs = 2, imms = [TRUTH_TABLE])
op("intl", (0x3E, 6, _), srcs = 2, imms = [])
op("convert", (0x3E | L, 6, _), srcs = 2, imms = [ROUND])
# Sources are the coeffient register and the sample index (if applicable)
op("iter", (0x21, 0xBF, 8, _), srcs = 2, imms = [CHANNELS, INTERPOLATION])
op("iter", (0x21, 8, _), srcs = 2, imms = [CHANNELS, INTERPOLATION])
# Sources are the coeffient register for the varying, the coefficient register
# for W, and the sample index (if applicable)
op("iterproj", (0x21, 0xBF, 8, _), srcs = 3, imms = [CHANNELS, INTERPOLATION])
op("iterproj", (0x21, 8, _), srcs = 3, imms = [CHANNELS, INTERPOLATION])
op("ldcf", (0xA1, 0xBF, 8, _), srcs = 1, imms = [CHANNELS])
op("ldcf", (0xA1, 8, _), srcs = 1, imms = [CHANNELS])
op("st_vary", None, dests = 0, srcs = 2, can_eliminate = False)
op("no_varyings", (0x80000051, 0xFFFFFFFF, 4, _), dests = 0, can_eliminate = False)
op("stop", (0x88, 0xFFFF, 2, _), dests = 0, can_eliminate = False,
op("no_varyings", (0x80000051, 4, _), dests = 0, can_eliminate = False)
op("stop", (0x88, 2, _), dests = 0, can_eliminate = False,
schedule_class = "invalid")
op("trap", (0x08, 0xFFFF, 2, _), dests = 0, can_eliminate = False,
op("trap", (0x08, 2, _), dests = 0, can_eliminate = False,
schedule_class = "invalid")
# These are modelled as total barriers since they can guard global memory
# access too, and even need to be properly ordered with loads.
op("wait_pix", (0x48, 0xFF, 4, _), dests = 0, imms = [WRITEOUT],
op("wait_pix", (0x48, 4, _), dests = 0, imms = [WRITEOUT],
can_eliminate = False, schedule_class = "barrier")
op("signal_pix", (0x58, 0xFF, 4, _), dests = 0, imms = [WRITEOUT],
op("signal_pix", (0x58, 4, _), dests = 0, imms = [WRITEOUT],
can_eliminate = False, schedule_class = "barrier")
# Sources are the data vector, the coordinate vector, the LOD, the bindless
# table if present (zero for texture state registers), and texture index.
op("image_write", (0xF1 | (1 << 23), 0xFF, 6, 8), dests = 0, srcs = 5, imms
op("image_write", (0xF1 | (1 << 23), 6, 8), dests = 0, srcs = 5, imms
= [DIM, COHERENT], can_eliminate = False, schedule_class = "store")
# Sources are the image base, image index, the offset within shared memory, and
# the coordinates (or just the layer if implicit).
# TODO: Do we need the short encoding?
op("block_image_store", (0xB1, 0xFF, 10, _), dests = 0, srcs = 4,
op("block_image_store", (0xB1, 10, _), dests = 0, srcs = 4,
imms = [FORMAT, DIM, EXPLICIT_COORDS], can_eliminate = False, schedule_class = "store")
# Barriers
op("threadgroup_barrier", (0x0068, 0xFFFF, 2, _), dests = 0, srcs = 0,
op("threadgroup_barrier", (0x0068, 2, _), dests = 0, srcs = 0,
can_eliminate = False, schedule_class = "barrier")
def memory_barrier(name, a, b, c):
op(name, (0xF5 | (a << 10) | (b << 8) | (c << 12), 0xFFFF, 2, _), dests = 0, srcs = 0,
op(name, (0xF5 | (a << 10) | (b << 8) | (c << 12), 2, _), dests = 0, srcs = 0,
can_eliminate = False, schedule_class = "barrier")
memory_barrier("memory_barrier", 1, 2, 9)
@@ -476,26 +422,23 @@ memory_barrier("unknown_barrier_2", 0, 3, 0)
memory_barrier("device_barrier_1", 3, 1, 9)
memory_barrier("device_barrier_2", 3, 2, 9)
op("doorbell", (0x60020 | 0x28 << 32, (1 << 48) - 1, 6, _), dests = 0,
op("doorbell", (0x60020 | 0x28 << 32, 6, _), dests = 0,
can_eliminate = False, can_reorder = False, imms = [IMM])
op("stack_unmap", (0x00075, (1 << 24) - 1, 8, _), dests = 1, srcs = 0, can_eliminate = False, can_reorder = False, imms = [IMM])
op("stack_map", (0x10075, (1 << 24) - 1, 8, _), dests = 0, srcs = 1, can_eliminate = False, can_reorder = False, imms = [IMM])
op("stack_unmap", (0x00075, 8, _), dests = 1, srcs = 0, can_eliminate = False, can_reorder = False, imms = [IMM])
op("stack_map", (0x10075, 8, _), dests = 0, srcs = 1, can_eliminate = False, can_reorder = False, imms = [IMM])
op("stack_adjust",
encoding = (0x10100b5, (1 << 26) - 1, 8, _),
op("stack_adjust", encoding = (0x10100b5, 8, _),
dests = 0, srcs = 0, can_eliminate = False, can_reorder = False,
imms = [STACK_SIZE], schedule_class = "store")
# source is offset
op("stack_load",
encoding = (0x35, (1 << 20) - 1, 6, 8),
op("stack_load", encoding = (0x35, 6, 8),
srcs = 1, imms = [FORMAT, MASK, SCOREBOARD], can_reorder = False,
schedule_class = "load")
# sources are value and offset
op("stack_store",
encoding = (0xb5, (1 << 20) - 1, 6, 8),
op("stack_store", encoding = (0xb5, 6, 8),
dests = 0, srcs = 2, imms = [FORMAT, MASK, SCOREBOARD],
can_eliminate=False, schedule_class = "store")