summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/operands/it.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/operands/it.c')
-rw-r--r--plugins/arm/v7/operands/it.c333
1 files changed, 232 insertions, 101 deletions
diff --git a/plugins/arm/v7/operands/it.c b/plugins/arm/v7/operands/it.c
index 6fab598..46e1b4c 100644
--- a/plugins/arm/v7/operands/it.c
+++ b/plugins/arm/v7/operands/it.c
@@ -27,27 +27,55 @@
#include <assert.h>
-#include <arch/operand-int.h>
#include <common/sort.h>
-#include <gtkext/gtkblockdisplay.h>
+#include <core/columns.h>
+#include "../operand-int.h"
-/* Définition d'un opérande organisant l'application d'une instruction IT (instance) */
-struct _GArmV7ITCondOperand
+
+
+/* -------------------------- DEFINITION D'UN NOUVEAU TYPE -------------------------- */
+
+
+/* Informations glissées dans la structure GObject de GArchOperand */
+typedef struct _a7itcop_extra_data_t
{
- GArchOperand parent; /* Instance parente */
+ operand_extra_data_t parent; /* A laisser en premier */
ArmCondCode firstcond; /* Condition première */
uint8_t mask; /* Masque de l'interprétation */
+} a7itcop_extra_data_t;
+
+
+/* Définition d'un opérande organisant l'application d'une instruction IT (instance) */
+struct _GArmV7ITCondOperand
+{
+ GArmV7Operand parent; /* Instance parente */
+
};
+/**
+ * Accès aux informations éventuellement déportées.
+ */
+
+#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__
+
+# define GET_ARMV7_ITCOND_OP_EXTRA(op) ((a7itcop_extra_data_t *)&((GArchOperand *)op)->extra)
+
+#else
+
+# define GET_ARMV7_ITCOND_OP_EXTRA(op) GET_GOBJECT_EXTRA(G_OBJECT(op), a7itcop_extra_data_t)
+
+#endif
+
+
/* Définition d'un opérande organisant l'application d'une instruction IT (classe) */
struct _GArmV7ITCondOperandClass
{
- GArchOperandClass parent; /* Classe parente */
+ GArmV7OperandClass parent; /* Classe parente */
};
@@ -64,27 +92,35 @@ static void g_armv7_itcond_operand_dispose(GArmV7ITCondOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_armv7_itcond_operand_finalize(GArmV7ITCondOperand *);
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
/* Compare un opérande avec un autre. */
-static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *, const GArmV7ITCondOperand *);
+static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *, const GArmV7ITCondOperand *, bool);
/* Traduit un opérande en version humainement lisible. */
static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *, GBufferLine *);
+/* Fournit l'empreinte d'un candidat à une centralisation. */
+static guint g_armv7_itcond_operand_hash(const GArmV7ITCondOperand *, bool);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_armv7_itcond_operand_load(GArmV7ITCondOperand *, GObjectStorage *, packed_buffer_t *);
-/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_armv7_itcond_operand_store(GArmV7ITCondOperand *, GObjectStorage *, packed_buffer_t *);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
-
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_armv7_itcond_operand_serialize(const GArmV7ITCondOperand *, GAsmStorage *, packed_buffer_t *);
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION D'UN NOUVEAU TYPE */
+/* ---------------------------------------------------------------------------------- */
/* Indique le type défini par la GLib pour l'application d'une instruction IT. */
-G_DEFINE_TYPE(GArmV7ITCondOperand, g_armv7_itcond_operand, G_TYPE_ARCH_OPERAND);
+G_DEFINE_TYPE(GArmV7ITCondOperand, g_armv7_itcond_operand, G_TYPE_ARMV7_OPERAND);
/******************************************************************************
@@ -105,16 +141,20 @@ static void g_armv7_itcond_operand_class_init(GArmV7ITCondOperandClass *klass)
GArchOperandClass *operand; /* Version de classe parente */
object = G_OBJECT_CLASS(klass);
- operand = G_ARCH_OPERAND_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_itcond_operand_dispose;
object->finalize = (GObjectFinalizeFunc)g_armv7_itcond_operand_finalize;
+ operand = G_ARCH_OPERAND_CLASS(klass);
+
operand->compare = (operand_compare_fc)g_armv7_itcond_operand_compare;
+
operand->print = (operand_print_fc)g_armv7_itcond_operand_print;
- operand->unserialize = (unserialize_operand_fc)g_armv7_itcond_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_armv7_itcond_operand_serialize;
+ operand->hash = (operand_hash_fc)g_armv7_itcond_operand_hash;
+
+ operand->load = (load_operand_fc)g_armv7_itcond_operand_load;
+ operand->store = (store_operand_fc)g_armv7_itcond_operand_store;
}
@@ -177,8 +217,100 @@ static void g_armv7_itcond_operand_finalize(GArmV7ITCondOperand *operand)
/******************************************************************************
* *
-* Paramètres : a = premier opérande à consulter. *
-* b = second opérande à consulter. *
+* Paramètres : firstcond = valeur brute de la condition d'exécution. *
+* mask = masque d'interprétation pour l'instruction. *
+* *
+* Description : Crée un opérande lié à une instruction IT. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv7_itcond_operand_new(uint8_t firstcond, uint8_t mask)
+{
+ GArmV7ITCondOperand *result; /* Structure à retourner */
+ a7itcop_extra_data_t *extra; /* Données insérées à modifier */
+
+ if (firstcond > ACC_NV)
+ return NULL;
+
+ result = g_object_new(G_TYPE_ARMV7_ITCOND_OPERAND, NULL);
+
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(result);
+
+ extra->firstcond = firstcond;
+ extra->mask = mask;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Fournit la condition associée à l'opérande. *
+* *
+* Retour : Condition classique pour ARMv7. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *operand)
+{
+ ArmCondCode result; /* Condition à renvoyer */
+ a7itcop_extra_data_t *extra; /* Données insérées à modifier */
+
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
+
+ result = extra->firstcond;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Fournit le masque d'interprétation de la condition. *
+* *
+* Retour : Masque de bits. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand)
+{
+ uint8_t result; /* Valeur à retourner */
+ a7itcop_extra_data_t *extra; /* Données insérées à modifier */
+
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
+
+ result = extra->mask;
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* lock = précise le besoin en verrouillage. *
* *
* Description : Compare un opérande avec un autre. *
* *
@@ -188,14 +320,38 @@ static void g_armv7_itcond_operand_finalize(GArmV7ITCondOperand *operand)
* *
******************************************************************************/
-static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *a, const GArmV7ITCondOperand *b)
+static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *a, const GArmV7ITCondOperand *b, bool lock)
{
int result; /* Bilan à faire remonter */
+ a7itcop_extra_data_t *ea; /* Données insérées à consulter*/
+ a7itcop_extra_data_t *eb; /* Données insérées à consulter*/
+ GArchOperandClass *class; /* Classe parente normalisée */
+
+ ea = GET_ARMV7_ITCOND_OP_EXTRA(a);
+ eb = GET_ARMV7_ITCOND_OP_EXTRA(b);
+
+ if (lock)
+ {
+ LOCK_GOBJECT_EXTRA(ea);
+ LOCK_GOBJECT_EXTRA(eb);
+ }
+
+ result = sort_boolean(ea->firstcond, eb->firstcond);
- result = sort_boolean(a->firstcond, b->firstcond);
+ if (result == 0)
+ result = sort_unsigned_long(ea->mask, eb->mask);
if (result == 0)
- result = sort_unsigned_long(a->mask, b->mask);
+ {
+ class = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class);
+ result = class->compare(G_ARCH_OPERAND(a), G_ARCH_OPERAND(b), false);
+ }
+
+ if (lock)
+ {
+ UNLOCK_GOBJECT_EXTRA(eb);
+ UNLOCK_GOBJECT_EXTRA(ea);
+ }
return result;
@@ -217,9 +373,12 @@ static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *a, const GA
static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *operand, GBufferLine *line)
{
+ a7itcop_extra_data_t *extra; /* Données insérées à consulter*/
const char *kw; /* Mot clef à imprimer */
- switch (operand->firstcond)
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
+
+ switch (extra->firstcond)
{
case ACC_EQ: kw = "EQ"; break;
case ACC_NE: kw = "NE"; break;
@@ -253,51 +412,37 @@ static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *operand, GBu
/******************************************************************************
* *
-* Paramètres : firstcond = valeur brute de la condition d'exécution. *
-* mask = masque d'interprétation pour l'instruction. *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* lock = précise le besoin en verrouillage. *
* *
-* Description : Crée un opérande lié à une instruction IT. *
+* Description : Fournit l'empreinte d'un candidat à une centralisation. *
* *
-* Retour : Opérande mis en place. *
+* Retour : Empreinte de l'élément représenté. *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchOperand *g_armv7_itcond_operand_new(uint8_t firstcond, uint8_t mask)
+static guint g_armv7_itcond_operand_hash(const GArmV7ITCondOperand *operand, bool lock)
{
- GArmV7ITCondOperand *result; /* Structure à retourner */
+ guint result; /* Valeur à retourner */
+ a7itcop_extra_data_t *extra; /* Données internes à manipuler*/
+ GArchOperandClass *class; /* Classe parente normalisée */
- if (firstcond > ACC_NV)
- return NULL;
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
- result = g_object_new(G_TYPE_ARMV7_ITCOND_OPERAND, NULL);
+ if (lock)
+ LOCK_GOBJECT_EXTRA(extra);
- result->firstcond = firstcond;
- result->mask = mask;
+ class = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class);
+ result = class->hash(G_ARCH_OPERAND(operand), false);
- return G_ARCH_OPERAND(result);
+ result ^= extra->firstcond;
-}
+ result ^= extra->mask;
-
-/******************************************************************************
-* *
-* Paramètres : operand = opérande à consulter. *
-* *
-* Description : Fournit la condition associée à l'opérande. *
-* *
-* Retour : Condition classique pour ARMv7. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *operand)
-{
- ArmCondCode result; /* Condition à renvoyer */
-
- result = operand->firstcond;
+ if (lock)
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -306,41 +451,11 @@ ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *oper
/******************************************************************************
* *
-* Paramètres : operand = opérande à consulter. *
-* *
-* Description : Fournit le masque d'interprétation de la condition. *
-* *
-* Retour : Masque de bits. *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand)
-{
- uint8_t result; /* Valeur à retourner */
-
- result = operand->mask;
-
- return result;
-
-}
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
-* Paramètres : operand = opérande d'assemblage à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
-* pbuf = zone tampon à remplir. *
-* *
-* Description : Charge un opérande depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -348,20 +463,30 @@ uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand)
* *
******************************************************************************/
-static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_armv7_itcond_operand_load(GArmV7ITCondOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
+ uleb128_t value; /* Valeur ULEB128 à charger */
+ a7itcop_extra_data_t *extra; /* Données insérées à modifier */
parent = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class);
- result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+ result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
- result = extract_packed_buffer(pbuf, &operand->firstcond, sizeof(ArmCondCode), true);
+ {
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
- if (result)
- result = extract_packed_buffer(pbuf, &operand->mask, sizeof(uint8_t), false);
+ result = unpack_uleb128(&value, pbuf);
+
+ if (result)
+ extra->firstcond = value;
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &extra->mask, sizeof(uint8_t), false);
+
+ }
return result;
@@ -370,11 +495,11 @@ static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAs
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -382,20 +507,26 @@ static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAs
* *
******************************************************************************/
-static bool g_armv7_itcond_operand_serialize(const GArmV7ITCondOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_armv7_itcond_operand_store(GArmV7ITCondOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
+ a7itcop_extra_data_t *extra; /* Données insérées à modifier */
parent = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class);
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
- result = extend_packed_buffer(pbuf, &operand->firstcond, sizeof(ArmCondCode), true);
+ {
+ extra = GET_ARMV7_ITCOND_OP_EXTRA(operand);
- if (result)
- result = extend_packed_buffer(pbuf, &operand->mask, sizeof(uint8_t), false);
+ result = pack_uleb128((uleb128_t []){ extra->firstcond }, pbuf);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &extra->mask, sizeof(uint8_t), false);
+
+ }
return result;