[llvm] [AMDGPU][RFC] Combine asm and disasm tests. (PR #90179)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 14:20:07 PDT 2024


MaskRay wrote:

> I like the general idea. We will always need some separate disassembler tests to check how the disassembler handles byte sequences that the assembler never generates (e.g. invalid encodings).
> 
> Instead of teaching the disassembler to extract hex bytes from `encoding: [...]`, I think I'd prefer creating a new assembler option `-filetype=hex` (subject to bikeshedding) that would produce output in the form that the disassembler expects:
> 
> ```
> $ llvm-mc -filetype=hex file.s
> 0x01,0x02,0x03,0x04
> $ llvm-mc -filetype=hex file.s | llvm-mv -disassemble
> ...
> ```
> 
> One more thing we could check is a form of round tripping. If you assemble an instruction to an encoding, then disassembling+assembling that encoding should round-trip perfectly. I.e. `asm file.s` should produce identical output to `asm file.s | dis | asm`.
> 
> The converse should probably be true, i.e. `dis file.txt` should produce identical output to `dis file.txt | asm | dis`.

I see that @kosarev created #90214 for evaluation. As someone who has worked a lot on MC, I'd hope that we do not lightly introduce another `MCStreamer` derivative whose purpose is only for testing.

`llvm-mc -filetype=obj ... | llvm-objdump -d ` is possibly a good choice for this functionality. I am also not sure about hard encoding `encoding: ` in llvm-mc -disassemble.

https://github.com/llvm/llvm-project/pull/90179


More information about the llvm-commits mailing list