-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AVR] Add AVR MOVW/ADIW/SUBIW disassembly #146360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
@Patryk27 I hope you don't mind that I have a question again about the LLVM code base. I made a number of PRs which complete disassembly of AVR files with so the opcode mnemonic and register are OK, but the immediate is not. Any hints? |
|
Nice! I think it throws
Since this doesn't make sense from assembly's point of view (where Inst.setOpcode((Insn & 0xff00) == 0x9600 ? AVR::ADIWRdK : AVR::SUBIWRdK);
Inst.addOperand(MCOperand::createReg(RegVal));
Inst.addOperand(MCOperand::createReg(RegVal));
unsigned imm = ((Insn & 0x00C0) >> 2) | (Insn & 0xF);
Inst.addOperand(MCOperand::createImm(imm));
return MCDisassembler::Success; |
|
@Patryk27 Aha, that makes sense. All is OK now. Thanks! |
|
@benshi001 Hi, can you please have a look? With this and the other PRs |
|
I can add a comment up-front - is it possible to test this code? Not sure if we have some tests for the disassembler (away from the keyboard at the moment), but I'd expect a couple. |
We have decoding tests, such as |
Thanks for your patch, I really appreciate your investigation into this issue. But I do not think this is a good solution. Since llvm can disassemble However there is still an underlying issue, which I have recorded as #146451 . |
benshi001
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to #146451 for my suggestion.
|
The PRs I create are often triggered by issues I encounter when using llvm/rust. I used llvm-objdump on a test program output. Will investigate which instructions are missing with the objdump flag -mcpu |
|
@benshi001 -mcpu=avr128db28 looks to generate correct output for my test program |
I did not find any existing tests. |
Oh, I haven't played with the disassembler before, so I didn't even realize LLVM is supposed to (mostly) auto-disassemble instructions. I think your suggestion is correct, i.e. the fundamental issue is that not all instructions are included in the base instruction set and LLVM will fail to "auto-disassemble" those which require to be opt-in (or so I think). *.elf files can already encode different AVR architectures (EF_AVR_ARCH), so what we should probably do is teach llvm-objdump to read that field. |
|
@Patryk27 I also did not realize that llvm-objdump needs that flag, probably because AVR support is marginal in other places (-mrelax, newer device issues, etc). Wonder if llvm-objdump also needs a flag for eg arm devices? |
Fix
<unknown>inllvm-objdump -doutput