diff options
Diffstat (limited to 'plugins/arm/v7/operands/shift.c')
-rw-r--r-- | plugins/arm/v7/operands/shift.c | 117 |
1 files changed, 113 insertions, 4 deletions
diff --git a/plugins/arm/v7/operands/shift.c b/plugins/arm/v7/operands/shift.c index 8c00753..55f2a22 100644 --- a/plugins/arm/v7/operands/shift.c +++ b/plugins/arm/v7/operands/shift.c @@ -24,15 +24,18 @@ #include "shift.h" +#include <assert.h> #include <stdio.h> #include <string.h> -#include <arch/operand-int.h> #include <common/sort.h> #include <gtkext/gtkblockdisplay.h> +#include "../operand-int.h" + + /* -------------------------- DEFINITION D'UN NOUVEAU TYPE -------------------------- */ @@ -50,7 +53,7 @@ typedef struct _a7shiftop_extra_data_t /* Définition d'un opérande visant une opérande de décalage ARMv7 (instance) */ struct _GArmV7ShiftOperand { - GArchOperand parent; /* Instance parente */ + GArmV7Operand parent; /* Instance parente */ GArchOperand *shift_value; /* Valeur du décalage */ @@ -60,7 +63,7 @@ struct _GArmV7ShiftOperand /* Définition d'un opérande visant une opérande de décalage ARMv7 (classe) */ struct _GArmV7ShiftOperandClass { - GArchOperandClass parent; /* Classe parente */ + GArmV7OperandClass parent; /* Classe parente */ }; @@ -109,6 +112,15 @@ static GArchOperand *g_armv7_shift_operand_get_inner_operand_from_path(const GAr /* Traduit un opérande en version humainement lisible. */ static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *, GBufferLine *); +/* Fournit une liste de candidats embarqués par un candidat. */ +static GArchOperand **g_armv7_shift_operand_list_inner_instances(const GArmV7ShiftOperand *, size_t *); + +/* Met à jour une liste de candidats embarqués par un candidat. */ +static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *, GArchOperand **, size_t); + +/* Fournit l'empreinte d'un candidat à une centralisation. */ +static guint g_armv7_shift_operand_hash(const GArmV7ShiftOperand *, bool); + /* Charge un contenu depuis une mémoire tampon. */ static bool g_armv7_shift_operand_load(GArmV7ShiftOperand *, GObjectStorage *, packed_buffer_t *); @@ -123,7 +135,7 @@ static bool g_armv7_shift_operand_store(GArmV7ShiftOperand *, GObjectStorage *, /* Indique le type défini par la GLib pour une opérande de décalage ARMv7. */ -G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARCH_OPERAND); +G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARMV7_OPERAND); /****************************************************************************** @@ -156,6 +168,10 @@ static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *klass) operand->print = (operand_print_fc)g_armv7_shift_operand_print; + operand->list_inner = (operand_list_inners_fc)g_armv7_shift_operand_list_inner_instances; + operand->update_inner = (operand_update_inners_fc)g_armv7_shift_operand_update_inner_instances; + operand->hash = (operand_hash_fc)g_armv7_shift_operand_hash; + operand->load = (load_operand_fc)g_armv7_shift_operand_load; operand->store = (store_operand_fc)g_armv7_shift_operand_store; @@ -476,6 +492,99 @@ static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBuff /****************************************************************************** * * +* Paramètres : operand = objet dont l'instance se veut unique. * +* count = quantité d'instances à l'unicité internes. * +* * +* Description : Fournit une liste de candidats embarqués par un candidat. * +* * +* Retour : Liste de candidats internes ou NULL si aucun. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchOperand **g_armv7_shift_operand_list_inner_instances(const GArmV7ShiftOperand *operand, size_t *count) +{ + GArchOperand **result; /* Instances à retourner */ + + *count = 1; + + result = malloc(*count * sizeof(GArchOperand *)); + + result[0] = operand->shift_value; + g_object_ref(G_OBJECT(result[0])); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = objet dont l'instance se veut unique. * +* instances = liste de candidats internes devenus singletons. * +* count = quantité d'instances à l'unicité internes. * +* * +* Description : Met à jour une liste de candidats embarqués par un candidat. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_update_inner_instances(GArmV7ShiftOperand *operand, GArchOperand **instances, size_t count) +{ + assert(count == 1); + + g_object_unref(G_OBJECT(operand->shift_value)); + operand->shift_value = instances[0]; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = objet dont l'instance se veut unique. * +* lock = précise le besoin en verrouillage. * +* * +* Description : Fournit l'empreinte d'un candidat à une centralisation. * +* * +* Retour : Empreinte de l'élément représenté. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static guint g_armv7_shift_operand_hash(const GArmV7ShiftOperand *operand, bool lock) +{ + guint result; /* Valeur à retourner */ + lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + GArchOperandClass *class; /* Classe parente normalisée */ + a7shiftop_extra_data_t *op_extra; /* Données internes à manipuler*/ + + extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + + if (lock) + LOCK_GOBJECT_EXTRA(extra); + + class = G_ARCH_OPERAND_CLASS(g_armv7_shift_operand_parent_class); + result = class->hash(G_ARCH_OPERAND(operand), false); + + op_extra = GET_ARMV7_SHIFT_OP_EXTRA(operand); + + result ^= op_extra->shift_type; + + if (lock) + UNLOCK_GOBJECT_EXTRA(extra); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : operand = élément GLib à constuire. * * storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à lire. * |