Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/startup_gfx2hlsl_scalar_m0_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
SOP2_AND_B64 = 0x0f
SOP2_LSHL_B32 = 0x1e
SOP2_BFM_B32 = 0x24
SOP2_NAND_B32 = 0x18
SOP2_NOR_B32 = 0x1a
SOP2_XNOR_B32 = 0x1c

SOPK_MOVK_I32 = 0x00

Expand Down Expand Up @@ -183,6 +186,19 @@ def controls():
st_bfm_const = run_seq(encode_sop2(SOP2_BFM_B32, M0, 5, 128 + 2))
assert st_bfm_const.lines == ['m0 = 0x0000003cu;'], st_bfm_const.lines

# s_nand_b32 / s_nor_b32 / s_xnor_b32: the 32-bit complement logic ops, SCC = result != 0 (#1919).
# The sources a fixture stage folds to a constant are not the point here: the complement form and the
# SCC update are.
for opcode, operator in ((SOP2_NAND_B32, '&'), (SOP2_NOR_B32, '|'), (SOP2_XNOR_B32, '^')):
st_logic = run_seq(encode_sop2(opcode, 28, 5, 6))
assert len(st_logic.lines) == 2, st_logic.lines
assert st_logic.lines[0].startswith('s28 = ~(') and ' %s ' % operator in st_logic.lines[0], st_logic.lines
assert st_logic.lines[1] == 'scc = s28 != 0;', st_logic.lines

# The neighbour stays as it was: a plain AND with the same SCC rule, no complement.
st_and = run_seq(encode_sop2(0x0e, 28, 5, 6))
assert not st_and.lines[0].startswith('s28 = ~(') and st_and.lines[1] == 'scc = s28 != 0;', st_and.lines

st_bfm_dyn = run_seq(encode_sop2(SOP2_BFM_B32, M0, 8, 128 + 2))
assert any(line.startswith('m0 = ') and 'ud1' in line for line in st_bfm_dyn.lines), st_bfm_dyn.lines

Expand Down
2 changes: 2 additions & 0 deletions tools/startup/gfx2hlsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,8 @@ def declarations(self):
's_mov_b32': ('{0}', None), 's_mov_b64': ('{0}', None), 's_movk_i32': ('{0}', None),
's_and_b32': ('{0} & {1}', '$ != 0'), 's_or_b32': ('{0} | {1}', '$ != 0'), 's_xor_b32': ('{0} ^ {1}', '$ != 0'),
's_andn2_b32': ('{0} & ~{1}', '$ != 0'), 's_orn2_b32': ('{0} | ~{1}', '$ != 0'), 's_not_b32': ('~{0}', '$ != 0'),
's_nand_b32': ('~({0} & {1})', '$ != 0'), 's_nor_b32': ('~({0} | {1})', '$ != 0'),
's_xnor_b32': ('~({0} ^ {1})', '$ != 0'),
's_and_b64': ('{0} & {1}', '$ != 0'), 's_or_b64': ('{0} | {1}', '$ != 0'), 's_xor_b64': ('{0} ^ {1}', '$ != 0'),
's_andn2_b64': ('{0} & ~{1}', '$ != 0'), 's_orn2_b64': ('{0} | ~{1}', '$ != 0'), 's_not_b64': ('~{0}', '$ != 0'),
's_nand_b64': ('~({0} & {1})', '$ != 0'), 's_nor_b64': ('~({0} | {1})', '$ != 0'), 's_xnor_b64': ('~({0} ^ {1})', '$ != 0'),
Expand Down
Loading