Disassembler location
A message that is not in the archive (sent off-list or not yet received): [email protected]
I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.
Any advice?
Thanks,
Michael
Quoted 8 lines · Michael Morrell
I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.
loongarch puts it in target/<arch>/ because it reuses some code between disassembler and translator.
The others are not hosts, only targets. By putting the file in target/<arch>/, they do not need to add it to the "disassemblers" variable in meson.build---but they add it anyway. :)
All in all, if you're not in the loongarch situation I'd put it in disas/.
Paolo
Quoted 1 line · Paolo Bonzini
The others are not hosts, only targets. By putting the file in target/<arch>/, they do not need to add it to the "disassemblers" variable in meson.build---but they add it anyway. :)
We should clean that up. :-)
r~
Quoted 3 lines · Michael Morrell
I'm working on a port to a new architecture and was noticing a discrepancy in where the disassembler code lives. There is a file "target/<arch>/disas.c" for 4 architectures (avr, loongarch, openrisc, and rx), but a file "disas/<arch>.c" for 14 architectures (if I counted right). It seems the 4 architectures using "target/<arch>/disas.c" are more recently added so I was wondering if that is now the preferred location. I couldn't find information on this, but I wasn't sure where to look.
Any advice?
The older disas/arch.c files come from binutils, prior to the GPLv3 license change. These are generally very old architectures, or not up to date.
The newer target/arch/disas.c are for architectures for which the translator and the disassembler share generated code via decodetree. If you're implementing a new architecture from scratch, this is your best choice.
The "best" supported are those with support in system libcapstone. :-)
r~
Fyi please note that LoongArch support was recently added to Capstone (https://github.com/capstone-engine/capstone/pull/2349).
Also, if you want to add support for a new architecture in Capstone and it is supported in LLVM, you can use our new Auto-Sync updater. See https://github.com/capstone-engine/capstone/issues/2015.