Based on the discussions in D130345,
AMDGPUDisassembler should emit warnings when v_cmpx*
instructions are disassembled with a non-exec destination,
except when the source is an immediate zero operand.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It seems like target disassemblers in general do not emit warnings, and are lacking the machinery to emit them as proper diagnostics with location information.
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | ||
---|---|---|
720 | Warnings should go to errs() shouldn't they? | |
llvm/test/MC/Disassembler/AMDGPU/gfx10_vop3cx.txt | ||
1071 | Might be better to do this by changing the RUN lines to use FileCheck --implicit-check-not="Warning:", to catch all unexpected warnings. |
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | ||
---|---|---|
720 | What if to instead say what is expected? Also, I guess it may be helpful if we emit the instruction itself and maybe its address as well? Might save the user some time and nerves locating the problematic instruction, especially if the warning doesn't go to that same stream we direct disassembled code to. |
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | ||
---|---|---|
717–718 | We could reuse isVCMPX64 here. It may be defined in AMDGPUBaseInfo and reused where necessary. | |
718 | Why is MI.getNumOperands() >= 5 important? | |
719 | This code checks operands of decoded MCInst, but decoded instruction does not provide any information about what dst was encoded in the original binary representation. To check the dst value, we have to work with the original binary code. | |
llvm/test/MC/Disassembler/AMDGPU/gfx10_vop3cx.txt | ||
1071 | I agree. Also, I suggest creating a separate file gfx10_vop3cx_errs.txt and add new tests for this feature there. The tests should include regular dst values (0x7e and 0), as well as a couple of values that trigger the warning. |
The summary should be corrected.
except when the source is an immediate zero operand
We should allow dst=EXEC and dst=0. The latter encoding has been used for a while for historical reasons, and we should not warn in this case.
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | ||
---|---|---|
719 | Do you mean use Bytes instead? |
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | ||
---|---|---|
719 | Yes, we should use Bytes. |
I cannot quite parse 64-bit v_cmpx* instructions after reading the ISA docs several times. I need to implement checks for the source and destination operands. Any pointers?
Why is MI.getNumOperands() >= 5 important?