[PATCH v2 0/20] Convert nanoMIPS disassembler from C++ to C

Milica Lazarevic posted 20 patches 1 year, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220905095522.66941-1-milica.lazarevic@syrmia.com
Maintainers: Stefan Pejic <stefan.pejic@syrmia.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>
There is a newer version of this series
disas/meson.build                  |    2 +-
disas/{nanomips.cpp => nanomips.c} | 7155 ++++++++++++++++++------------------
disas/nanomips.h                   | 1072 ------
3 files changed, 3557 insertions(+), 4672 deletions(-)
[PATCH v2 0/20] Convert nanoMIPS disassembler from C++ to C
Posted by Milica Lazarevic 1 year, 7 months ago
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:
    (1) disas/nanomips: Remove namespace img
      Removed comments that refer to the deleted function.
    (3) disas/nanomips: Delete NMD class fields
      Class fields were introduced as global variables in the previous version.
      Since it wasn't a thread-safe solution, in this version, one class field
      (m_requested_instruction_categories) has been replaced with the only value 
      it can have, while the other class field has been added as a parameter 
      where needed.
    (4) disas/nanomips: Remove helper methods from class
      Squashed patch #19 here.
    (5) disas/nanomips: Remove __cond methods from class
      Addressed the coding style issues.
    (6) disas/nanomips: Remove disasm methods from class
      Addressed the coding style issues.
    (12) disas/nanomips: Replace std::string type
      Changed the return types to char * when a function returns allocated memory.
      Switched to using some glib functions for memory allocation like g_malloc,
      g_strdup_vprintf, and g_strdup_printf instead of strdup.
    (13) disas/nanomips: Prevent memory leaking
      Used the g_autofree attribute for dynamically allocated strings, instead of
      calling free(). Now, this patch is much smaller than in the previous version.
    (14) disas/nanomips: Introduce Dis_info struct
      Same as in (3). Instead of using global variables, all the necessary information
      are packed into the struct and added as an argument wherever needed.

Regards, 
Milica

Milica Lazarevic (20):
      disas/nanomips: Remove namespace img
      disas/nanomips: Extract enums out of the NMD class
      disas/nanomips: Delete NMD class fields
      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: Replace std::string type
      disas/nanomips: Prevent memory leaking
      disas/nanomips: Remove function overloading
      disas/nanomips: Introduce 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: Add struct keyword
      disas/nanomips: Rename nanomips.cpp to nanomips.c

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