mbox series

[v3,0/24] Convert nanoMIPS disassembler from C++ to C

Message ID 20220912122635.74032-1-milica.lazarevic@syrmia.com (mailing list archive)
Headers show
Series Convert nanoMIPS disassembler from C++ to C | expand

Message

Milica Lazarevic Sept. 12, 2022, 12:26 p.m. UTC
Hi,

This patchset converts the nanomips disassembler to plain C. C++ features
like class, std::string type, exception handling, and function overloading
have been removed and replaced with the equivalent C code. 
===========
Changes since previous version:
    (3) disas/nanomips: Delete NMD class field
      The deletion of two NMD class fields is separated into two commits. 
      The only use of the m_requested_instruction_categories field is within
      the if statement. Also, the field always has the same value making the
      if condition false. Therefore field and its use are completely removed.
    (4) disas/nanomips: Delete NMD class second field
      The deletion of two NMD class fields is separated into two commits. The
      Dis_info struct is introduced here. The struct currently has just one 
      field, m_pc.
    (8) disas/nanomips: Remove Pool tables from the class
      Mark all Pool tables as const.
    (13) disas/nanomips: Delete copy functions
      This is a new patch compared to the previous version. There were some 
      functions of the following form:
       T f(T arg){
        return arg;
       }
      These have been deleted, and all calls to f(arg) have been replaced with
      arg.
    (14) disas/nanomips: Delete wrapper functions
      This is a new patch compared to the previous version. Functions that 
      simply wrap the other function have been deleted. Instead, we're directly
      calling the wrapped function.
    (15) disas/nanomips: Replace std::string type
      Changed the implementation of the save_restore_list function by using 
      g_strjoinv instead of strcat. 
      Changed the interface of the Disassemble function. The type of the dis 
      parameter now is a pointer to the char *(char** dis) instead of char * 
      which makes the rest of the disassembler interface easier.
    (16) disas/nanomips: Remove IMMEDIATE functions
      This is a new patch compared to the previous version. Both versions of the 
      IMMEDIATE function have been deleted. Before, we've been practically calling the
      img_format twice on the integer values, which is not necessary anymore. Therefore,
      calls to IMMEDIATE have been deleted, and the second(now the only) call to 
      img_format is slightly changed.
    (17) disas/nanomips: Remove CPR function
      This is a new patch compared to the previous version. Same as in (16); calls to 
      CPR have been deleted, and the second(now the only) call to img_format is slightly
      changed.

Regards, 
Milica

Milica Lazarevic (24):
      disas/nanomips: Remove namespace img
      disas/nanomips: Extract enums out of the NMD class
      disas/nanomips: Delete NMD class field
      disas/nanomips: Delete NMD class second field
      disas/nanomips: Remove helper methods from class
      disas/nanomips: Remove __cond methods from class
      disas/nanomips: Remove disasm methods from class
      disas/nanomips: Remove Pool tables from the class
      disas/nanomips: Remove NMD class
      disas/nanomips: Move typedefs etc to nanomips.cpp
      disas/nanomips: Delete nanomips.h
      disas/nanomips: Remove #inlcude <sstream>
      disas/nanomips: Delete copy functions
      disas/nanomips: Delete wrapper functions
      disas/nanomips: Replace std::string type
      disas/nanomips: Remove IMMEDIATE functions
      disas/nanomips: Remove CPR function
      disas/nanomips: Prevent memory leaking
      disas/nanomips: Remove function overloading
      disas/nanomips: Expand Dis_info struct
      disas/nanomips: Replace exception handling
      disas/nanomips: Replace Cpp enums for C enums
      disas/nanomips: Remove argument passing by ref
      disas/nanomips: Rename nanomips.cpp to nanomips.c

 disas/meson.build                  |    2 +-
 disas/{nanomips.cpp => nanomips.c} | 7392 +++++++++++++++++-------------------
 disas/nanomips.h                   | 1072 ------
 3 files changed, 3510 insertions(+), 4956 deletions(-)

Comments

Thomas Huth Oct. 27, 2022, 7:25 a.m. UTC | #1
On 12/09/2022 14.26, Milica Lazarevic wrote:
> Hi,
> 
> This patchset converts the nanomips disassembler to plain C. C++ features
> like class, std::string type, exception handling, and function overloading
> have been removed and replaced with the equivalent C code.

  Hi Philippe, hi Stefan,

as far as I can see, this patch set has been completely reviewed, and IMHO 
it would be nice to get this into QEMU 7.2 to finally get rid of the C++ 
dependency in the QEMU code ... could one of you pick this up and send a 
pull request with the patches? Or is there still anything left to do here?

  Thomas
Philippe Mathieu-Daudé Oct. 27, 2022, 10:55 a.m. UTC | #2
On 27/10/22 09:25, Thomas Huth wrote:
> On 12/09/2022 14.26, Milica Lazarevic wrote:
>> Hi,
>>
>> This patchset converts the nanomips disassembler to plain C. C++ features
>> like class, std::string type, exception handling, and function 
>> overloading
>> have been removed and replaced with the equivalent C code.
> 
>   Hi Philippe, hi Stefan,
> 
> as far as I can see, this patch set has been completely reviewed, and 
> IMHO it would be nice to get this into QEMU 7.2 to finally get rid of 
> the C++ dependency in the QEMU code ... could one of you pick this up 
> and send a pull request with the patches? Or is there still anything 
> left to do here?

Sorry I lost track of this series. I'm preparing a pull request and will
look at it later today. Thanks for the reminder!

Phil.