Skip to content
Merged
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
13 changes: 13 additions & 0 deletions tests/rdna2_tools_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5023,6 +5023,19 @@ def scan():
result = scan()
self.assertIn("Full Shaders Accepted by Translator: 0", result.stdout)

def test_parse_assembly_file_skips_bom_and_commented_labels(self):
"""A UTF-8 BOM and llc-style commented labels are not instructions; a ':' in a comment keeps the line."""
from scan_unsupported_shaders import parse_assembly_file
with tempfile.TemporaryDirectory() as tmp:
bom = Path(tmp) / "bom.s"
bom.write_bytes(b"\xef\xbb\xbfs_endpgm\n")
self.assertEqual(parse_assembly_file(bom), ["s_endpgm"])
labels = Path(tmp) / "labels.s"
labels.write_text("pixel: ; @pixel\n"
".LBB0_1: ; %bb.1\n"
"s_endpgm ; done:\n", encoding="utf-8")
self.assertEqual(parse_assembly_file(labels), ["s_endpgm ; done:"])

def test_binary_scan_recognizes_vop1_cvt_off_sat_pack_and_swap_opcodes(self):
"""The scan report names the four VOP1 forms instead of listing v_vop1_NN as unknown opcodes."""
shader = bytes.fromhex(
Expand Down
5 changes: 3 additions & 2 deletions tools/scan_unsupported_shaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,16 @@ def analyze_shader_instructions(shader_name: str, instructions: list[str], *,
def parse_assembly_file(path: Path) -> list[str]:
"""Read assembly instructions from a text file (.s, .asm, .txt)."""
lines = []
with path.open("r", encoding="utf-8", errors="replace") as f:
with path.open("r", encoding="utf-8-sig", errors="replace") as f:
for line in f:
stripped = line.strip()
if not stripped or stripped.startswith(("//", ";", "#", "@")):
continue
# Symbol metadata emits no instruction. Keep data and alignment directives visible.
if stripped == ".text" or stripped.split(None, 1)[0] in (".globl", ".global", ".type", ".size"):
continue
if stripped.endswith(":") and " " not in stripped:
code = re.split(r"//|[;#]", stripped)[0].strip() # same comment rule as extract_opcode
if code.endswith(":") and " " not in code:
continue
lines.append(stripped)
return lines
Expand Down
Loading