All of lore.kernel.org
 help / color / mirror / Atom feed
From: Milica Lazarevic <milica.lazarevic@syrmia.com>
To: thuth@redhat.com
Cc: qemu-devel@nongnu.org, cfontana@suse.de, berrange@redhat.com,
	pbonzini@redhat.com, vince.delvecchio@mediatek.com,
	richard.henderson@linaro.org, peter.maydell@linaro.org,
	djordje.todorovic@syrmia.com, mips32r2@gmail.com,
	dragan.mladjenovic@syrmia.com,
	Milica Lazarevic <milica.lazarevic@syrmia.com>
Subject: [PATCH 05/20] disas/nanomips: Remove __cond methods from class
Date: Mon, 15 Aug 2022 09:26:14 +0200	[thread overview]
Message-ID: <20220815072629.12865-6-milica.lazarevic@syrmia.com> (raw)
In-Reply-To: <20220815072629.12865-1-milica.lazarevic@syrmia.com>

NMD class methods with the conditional_function type like
NMD::ADDIU_32__cond, NMD::ADDIU_RS5__cond, etc. are removed from the NMD
class. They're now declared global static functions. Therefore, typedef
of the function pointer, conditional_function is defined outside of the
class.

Now that conditional_function type functions are not part of the NMD
class we can't access them using the this pointer. Thus, the use of
the this pointer has been deleted.

Signed-off-by: Milica Lazarevic <milica.lazarevic@syrmia.com>
---
 disas/nanomips.cpp | 42 +++++++++++++++++++++---------------------
 disas/nanomips.h   | 14 ++------------
 2 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp
index 039c353d0b..9e720d0e8d 100644
--- a/disas/nanomips.cpp
+++ b/disas/nanomips.cpp
@@ -787,7 +787,7 @@ int NMD::Disassemble(const uint16 * data, std::string & dis,
             if ((op_code & table[i].mask) == table[i].value) {
                 /* possible match */
                 conditional_function cond = table[i].condition;
-                if ((cond == 0) || (this->*cond)(op_code)) {
+                if ((cond == 0) || (cond)(op_code)) {
                     try
                     {
                         if (table[i].type == pool) {
@@ -1685,28 +1685,28 @@ static uint64 extract_u_3_2_1_0__s1(uint64 instruction)
 
 
 
-bool NMD::ADDIU_32__cond(uint64 instruction)
+static bool ADDIU_32__cond(uint64 instruction)
 {
     uint64 rt = extract_rt_25_24_23_22_21(instruction);
     return rt != 0;
 }
 
 
-bool NMD::ADDIU_RS5__cond(uint64 instruction)
+static bool ADDIU_RS5__cond(uint64 instruction)
 {
     uint64 rt = extract_rt_9_8_7_6_5(instruction);
     return rt != 0;
 }
 
 
-bool NMD::BALRSC_cond(uint64 instruction)
+static bool BALRSC_cond(uint64 instruction)
 {
     uint64 rt = extract_rt_25_24_23_22_21(instruction);
     return rt != 0;
 }
 
 
-bool NMD::BEQC_16__cond(uint64 instruction)
+static bool BEQC_16__cond(uint64 instruction)
 {
     uint64 rs3 = extract_rs3_6_5_4(instruction);
     uint64 rt3 = extract_rt3_9_8_7(instruction);
@@ -1715,7 +1715,7 @@ bool NMD::BEQC_16__cond(uint64 instruction)
 }
 
 
-bool NMD::BNEC_16__cond(uint64 instruction)
+static bool BNEC_16__cond(uint64 instruction)
 {
     uint64 rs3 = extract_rs3_6_5_4(instruction);
     uint64 rt3 = extract_rt3_9_8_7(instruction);
@@ -1724,35 +1724,35 @@ bool NMD::BNEC_16__cond(uint64 instruction)
 }
 
 
-bool NMD::MOVE_cond(uint64 instruction)
+static bool MOVE_cond(uint64 instruction)
 {
     uint64 rt = extract_rt_9_8_7_6_5(instruction);
     return rt != 0;
 }
 
 
-bool NMD::P16_BR1_cond(uint64 instruction)
+static bool P16_BR1_cond(uint64 instruction)
 {
     uint64 u = extract_u_3_2_1_0__s1(instruction);
     return u != 0;
 }
 
 
-bool NMD::PREF_S9__cond(uint64 instruction)
+static bool PREF_S9__cond(uint64 instruction)
 {
     uint64 hint = extract_hint_25_24_23_22_21(instruction);
     return hint != 31;
 }
 
 
-bool NMD::PREFE_cond(uint64 instruction)
+static bool PREFE_cond(uint64 instruction)
 {
     uint64 hint = extract_hint_25_24_23_22_21(instruction);
     return hint != 31;
 }
 
 
-bool NMD::SLTU_cond(uint64 instruction)
+static bool SLTU_cond(uint64 instruction)
 {
     uint64 rd = extract_rd_15_14_13_12_11(instruction);
     return rd != 0;
@@ -16705,7 +16705,7 @@ NMD::Pool NMD::P_ADDIU[2] = {
        0xffe00000, 0x00000000, 0                      , 0,
        0x0                 },        /* P.RI */
     { instruction         , 0                   , 0   , 32,
-       0xfc000000, 0x00000000, &NMD::ADDIU_32_        , &NMD::ADDIU_32__cond   ,
+       0xfc000000, 0x00000000, &NMD::ADDIU_32_        , &ADDIU_32__cond   ,
        0x0                 },        /* ADDIU[32] */
 };
 
@@ -16803,7 +16803,7 @@ NMD::Pool NMD::P_SLTU[2] = {
        0xfc00fbff, 0x20000390, 0                      , 0,
        0x0                 },        /* P.DVP */
     { instruction         , 0                   , 0   , 32,
-       0xfc0003ff, 0x20000390, &NMD::SLTU             , &NMD::SLTU_cond        ,
+       0xfc0003ff, 0x20000390, &NMD::SLTU             , &SLTU_cond        ,
        0x0                 },        /* SLTU */
 };
 
@@ -21348,7 +21348,7 @@ NMD::Pool NMD::P_PREF_S9_[2] = {
        0xffe07f00, 0xa7e01800, &NMD::SYNCI            , 0,
        0x0                 },        /* SYNCI */
     { instruction         , 0                   , 0   , 32,
-       0xfc007f00, 0xa4001800, &NMD::PREF_S9_         , &NMD::PREF_S9__cond    ,
+       0xfc007f00, 0xa4001800, &NMD::PREF_S9_         , &PREF_S9__cond    ,
        0x0                 },        /* PREF[S9] */
 };
 
@@ -21560,7 +21560,7 @@ NMD::Pool NMD::P_PREFE[2] = {
        0xffe07f00, 0xa7e01a00, &NMD::SYNCIE           , 0,
        CP0_ | EVA_         },        /* SYNCIE */
     { instruction         , 0                   , 0   , 32,
-       0xfc007f00, 0xa4001a00, &NMD::PREFE            , &NMD::PREFE_cond       ,
+       0xfc007f00, 0xa4001a00, &NMD::PREFE            , &PREFE_cond       ,
        CP0_ | EVA_         },        /* PREFE */
 };
 
@@ -21732,7 +21732,7 @@ NMD::Pool NMD::P_BALRSC[2] = {
        0xffe0f000, 0x48008000, &NMD::BRSC             , 0,
        0x0                 },        /* BRSC */
     { call_instruction    , 0                   , 0   , 32,
-       0xfc00f000, 0x48008000, &NMD::BALRSC           , &NMD::BALRSC_cond      ,
+       0xfc00f000, 0x48008000, &NMD::BALRSC           , &BALRSC_cond      ,
        0x0                 },        /* BALRSC */
 };
 
@@ -22080,7 +22080,7 @@ NMD::Pool NMD::P16_MV[2] = {
        0xffe0    , 0x1000    , 0                      , 0,
        0x0                 },        /* P16.RI */
     { instruction         , 0                   , 0   , 16,
-       0xfc00    , 0x1000    , &NMD::MOVE             , &NMD::MOVE_cond        ,
+       0xfc00    , 0x1000    , &NMD::MOVE             , &MOVE_cond        ,
        0x0                 },        /* MOVE */
 };
 
@@ -22146,7 +22146,7 @@ NMD::Pool NMD::P_ADDIU_RS5_[2] = {
        0xffe8    , 0x9008    , &NMD::NOP_16_          , 0,
        0x0                 },        /* NOP[16] */
     { instruction         , 0                   , 0   , 16,
-       0xfc08    , 0x9008    , &NMD::ADDIU_RS5_       , &NMD::ADDIU_RS5__cond  ,
+       0xfc08    , 0x9008    , &NMD::ADDIU_RS5_       , &ADDIU_RS5__cond  ,
        0x0                 },        /* ADDIU[RS5] */
 };
 
@@ -22183,10 +22183,10 @@ NMD::Pool NMD::P16_JRC[2] = {
 
 NMD::Pool NMD::P16_BR1[2] = {
     { branch_instruction  , 0                   , 0   , 16,
-       0xfc00    , 0xd800    , &NMD::BEQC_16_         , &NMD::BEQC_16__cond    ,
+       0xfc00    , 0xd800    , &NMD::BEQC_16_         , &BEQC_16__cond    ,
        XMMS_               },        /* BEQC[16] */
     { branch_instruction  , 0                   , 0   , 16,
-       0xfc00    , 0xd800    , &NMD::BNEC_16_         , &NMD::BNEC_16__cond    ,
+       0xfc00    , 0xd800    , &NMD::BNEC_16_         , &BNEC_16__cond    ,
        XMMS_               },        /* BNEC[16] */
 };
 
@@ -22196,7 +22196,7 @@ NMD::Pool NMD::P16_BR[2] = {
        0xfc0f    , 0xd800    , 0                      , 0,
        0x0                 },        /* P16.JRC */
     { pool                , P16_BR1             , 2   , 16,
-       0xfc00    , 0xd800    , 0                      , &NMD::P16_BR1_cond     ,
+       0xfc00    , 0xd800    , 0                      , &P16_BR1_cond     ,
        0x0                 },        /* P16.BR1 */
 };
 
diff --git a/disas/nanomips.h b/disas/nanomips.h
index a795ed44e8..0e6670adf5 100644
--- a/disas/nanomips.h
+++ b/disas/nanomips.h
@@ -31,6 +31,8 @@ typedef uint32_t uint32;
 typedef uint16_t uint16;
 typedef uint64_t img_address;
 
+typedef bool(*conditional_function)(uint64 instruction);
+
 enum TABLE_ENTRY_TYPE {
     instruction,
     call_instruction,
@@ -71,7 +73,6 @@ public:
 private:
 
     typedef std::string(NMD:: *disassembly_function)(uint64 instruction);
-    typedef bool(NMD:: *conditional_function)(uint64 instruction);
 
     struct Pool {
         TABLE_ENTRY_TYPE     type;
@@ -89,17 +90,6 @@ private:
     int Disassemble(const uint16 *data, std::string & dis,
                     TABLE_ENTRY_TYPE & type, const Pool *table, int table_size);
 
-    bool ADDIU_32__cond(uint64 instruction);
-    bool ADDIU_RS5__cond(uint64 instruction);
-    bool BALRSC_cond(uint64 instruction);
-    bool BEQC_16__cond(uint64 instruction);
-    bool BNEC_16__cond(uint64 instruction);
-    bool MOVE_cond(uint64 instruction);
-    bool P16_BR1_cond(uint64 instruction);
-    bool PREF_S9__cond(uint64 instruction);
-    bool PREFE_cond(uint64 instruction);
-    bool SLTU_cond(uint64 instruction);
-
     std::string ABS_D(uint64 instruction);
     std::string ABS_S(uint64 instruction);
     std::string ABSQ_S_PH(uint64 instruction);
-- 
2.25.1



  parent reply	other threads:[~2022-08-15  7:56 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15  7:26 [PATCH 0/20] Convert nanoMIPS disassembler from C++ to C Milica Lazarevic
2022-08-15  7:26 ` [PATCH 01/20] disas/nanomips: Remove namespace img Milica Lazarevic
2022-08-15 13:55   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 02/20] disas/nanomips: Extract enums out of the NMD class Milica Lazarevic
2022-08-15 13:59   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 03/20] disas/nanomips: Delete NMD class fields Milica Lazarevic
2022-08-15 10:59   ` Philippe Mathieu-Daudé via
2022-08-15 15:02   ` Richard Henderson
2022-08-15  7:26 ` [PATCH 04/20] disas/nanomips: Remove helper methods from class Milica Lazarevic
2022-08-15 16:41   ` Thomas Huth
2022-08-16  0:19   ` Philippe Mathieu-Daudé via
2022-08-16  5:46     ` Thomas Huth
2022-08-15  7:26 ` Milica Lazarevic [this message]
2022-08-15 11:07   ` [PATCH 05/20] disas/nanomips: Remove __cond " Philippe Mathieu-Daudé via
2022-08-15 14:20     ` Thomas Huth
2022-08-16  0:14       ` Philippe Mathieu-Daudé via
2022-08-15  7:26 ` [PATCH 06/20] disas/nanomips: Remove disasm " Milica Lazarevic
2022-08-15 11:45   ` Philippe Mathieu-Daudé via
2022-08-15  7:26 ` [PATCH 07/20] disas/nanomips: Remove Pool tables from the class Milica Lazarevic
2022-08-16  0:12   ` Philippe Mathieu-Daudé via
2022-08-15  7:26 ` [PATCH 08/20] disas/nanomips: Remove NMD class Milica Lazarevic
2022-08-15  7:26 ` [PATCH 09/20] disas/nanomips: Move typedefs etc to nanomips.cpp Milica Lazarevic
2022-08-16  0:13   ` Philippe Mathieu-Daudé via
2022-08-15  7:26 ` [PATCH 10/20] disas/nanomips: Delete nanomips.h Milica Lazarevic
2022-08-16  0:14   ` Philippe Mathieu-Daudé via
2022-08-15  7:26 ` [PATCH 11/20] disas/nanomips: Remove #inlcude <sstream> Milica Lazarevic
2022-08-15 14:05   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 12/20] disas/nanomips: Replace std::string type Milica Lazarevic
2022-08-26  7:58   ` Milica Lazarevic
2022-08-27  7:38   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 13/20] disas/nanomips: Add free() calls Milica Lazarevic
2022-08-26  7:59   ` Milica Lazarevic
2022-08-27  7:45   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 14/20] disas/nanomips: Remove function overloading Milica Lazarevic
2022-08-27  7:51   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 15/20] disas/nanomips: Replace exception handling Milica Lazarevic
2022-08-26  7:59   ` Milica Lazarevic
2022-08-27  8:34   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 16/20] disas/nanomips: Replace Cpp enums for C enums Milica Lazarevic
2022-08-27  8:35   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 17/20] disas/nanomips: Remove argument passing by ref Milica Lazarevic
2022-08-27  8:36   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 18/20] disas/nanomips: Add struct keyword Milica Lazarevic
2022-08-27  8:37   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 19/20] disas/nanomips: Add modifier static Milica Lazarevic
2022-08-16  0:22   ` Philippe Mathieu-Daudé via
2022-08-18  7:58     ` Milica Lazarevic
2022-08-27  8:38   ` Thomas Huth
2022-08-15  7:26 ` [PATCH 20/20] disas/nanomips: Rename nanomips.cpp to nanomips.c Milica Lazarevic
2022-08-27  8:39   ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220815072629.12865-6-milica.lazarevic@syrmia.com \
    --to=milica.lazarevic@syrmia.com \
    --cc=berrange@redhat.com \
    --cc=cfontana@suse.de \
    --cc=djordje.todorovic@syrmia.com \
    --cc=dragan.mladjenovic@syrmia.com \
    --cc=mips32r2@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=vince.delvecchio@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.