summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/operands/register-int.h46
-rw-r--r--src/arch/operands/register.c26
2 files changed, 68 insertions, 4 deletions
diff --git a/src/arch/operands/register-int.h b/src/arch/operands/register-int.h
index c728be7..bf3e9d4 100644
--- a/src/arch/operands/register-int.h
+++ b/src/arch/operands/register-int.h
@@ -29,19 +29,63 @@
#include "../operand-int.h"
+#include "../../glibext/objhole.h"
+/* Informations glissées dans la structure GObject de GArchInstruction */
+typedef union _regop_obj_extra
+{
+ struct
+ {
+ bool is_written; /* Changement de contenu */
+
+ };
+
+ gint lock; /* Gestion d'accès aux fanions */
+
+} regop_obj_extra;
+
/* Définition d'un opérande visant un registre (instance) */
struct _GRegisterOperand
{
GArchOperand parent; /* Instance parente */
GArchRegister *reg; /* Registre représenté */
- bool is_written; /* Changement de contenu */
+
+#if __SIZEOF_INT__ == __SIZEOF_LONG__
+
+ /**
+ * L'inclusion des informations suivantes dépend de l'architecture.
+ *
+ * Si la structure GObject possède un trou, on remplit de préférence
+ * ce dernier.
+ */
+
+ regop_obj_extra extra; /* Externalisation embarquée */
+
+#endif
};
+/**
+ * Accès aux informations éventuellement déportées.
+ */
+
+#if __SIZEOF_INT__ == __SIZEOF_LONG__
+
+# define INIT_REG_OP_EXTRA(op) op->extra.lock = 0
+
+# define GET_REG_OP_EXTRA(op) &op->extra
+
+#else
+
+# define INIT_REG_OP_EXTRA(op) INIT_GOBJECT_EXTRA(G_OBJECT(op))
+
+# define GET_REG_OP_EXTRA(op) GET_GOBJECT_EXTRA(G_OBJECT(op), regop_obj_extra)
+
+#endif
+
/* Définition d'un opérande visant un registre (classe) */
struct _GRegisterOperandClass
{
diff --git a/src/arch/operands/register.c b/src/arch/operands/register.c
index d755dbb..81608a3 100644
--- a/src/arch/operands/register.c
+++ b/src/arch/operands/register.c
@@ -121,7 +121,8 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass)
static void g_register_operand_init(GRegisterOperand *operand)
{
operand->reg = NULL;
- operand->is_written = false;
+
+ INIT_REG_OP_EXTRA(operand);
}
@@ -250,7 +251,15 @@ GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand)
void g_register_operand_mark_as_written(GRegisterOperand *operand)
{
- operand->is_written = true;
+ regop_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_REG_OP_EXTRA(operand);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ extra->is_written = true;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
@@ -269,7 +278,18 @@ void g_register_operand_mark_as_written(GRegisterOperand *operand)
bool g_register_operand_is_written(const GRegisterOperand *operand)
{
- return operand->is_written;
+ bool result; /* Statut à retourner */
+ regop_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_REG_OP_EXTRA(operand);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = extra->is_written;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
}