summaryrefslogtreecommitdiff
path: root/src/arch/register.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/register.c')
-rw-r--r--src/arch/register.c253
1 files changed, 235 insertions, 18 deletions
diff --git a/src/arch/register.c b/src/arch/register.c
index 519ecdd..3071198 100644
--- a/src/arch/register.c
+++ b/src/arch/register.c
@@ -46,8 +46,14 @@ static void g_arch_register_dispose(GArchRegister *);
/* Procède à la libération totale de la mémoire. */
static void g_arch_register_finalize(GArchRegister *);
+/* Fournit le gestionnaire de partages attribué à un type. */
+static GShareManager *get_arch_register_share_manager(const GArchRegister *);
+
/* Initialise un nouvel objet partagé avec des informations. */
-static bool g_arch_register_do_init(GArchRegister *, const void *);
+static bool g_arch_register_apply_template(GArchRegister *, const GArchRegister *);
+
+/* Réalise une copie minimale d'un contenu partagé. */
+static void g_arch_register_define_template(const GArchRegister *, GArchRegister *);
/* Fournit la valeur du compteur de partage. */
static unsigned int g_arch_register_get_references(const GArchRegister *);
@@ -59,7 +65,7 @@ static void g_arch_register_inc_references(GArchRegister *);
static void g_arch_register_dec_references(GArchRegister *);
/* Compare de façon accélérée un registre avec un autre. */
-static int g_arch_register_quickly_compare(const GArchRegister **, const GArchRegister **);
+static int g_arch_register_compare_shared(const GArchRegister * const *, const GArchRegister * const *);
@@ -78,14 +84,32 @@ static void g_register_operand_dispose(GRegisterOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_register_operand_finalize(GRegisterOperand *);
+/* Initialise un nouvel objet partagé avec des informations. */
+static bool g_register_operand_apply_template(GRegisterOperand *, const GRegisterOperand *);
+
+/* Réalise une copie minimale d'un contenu partagé. */
+static void g_register_operand_define_template(const GRegisterOperand *, GRegisterOperand *);
+
/* Compare un opérande avec un autre. */
-static int g_register_operand_compare(const GRegisterOperand **, const GRegisterOperand **);
+static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *);
/* Traduit un opérande en version humainement lisible. */
static void g_register_operand_print(const GRegisterOperand *, GBufferLine *, AsmSyntax);
+/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */
+
+
+/* Gestionnaire des partages d'instances */
+static GShareManager *_register_operand_manager = NULL;
+
+
+/* Fournit le gestionnaire de partages attribué à un type. */
+static GShareManager *get_register_operand_share_manager(void);
+
+
+
/* ---------------------------------------------------------------------------------- */
/* PUR REGISTRE DU MATERIEL */
/* ---------------------------------------------------------------------------------- */
@@ -152,20 +176,24 @@ static void g_arch_register_init(GArchRegister *reg)
static void g_arch_register_interface_init(GSharedInstanceInterface *iface)
{
- iface->init = (init_shared_fc)g_arch_register_do_init;
+ iface->get_manager = (get_share_manager_fc)get_arch_register_share_manager;
+
+ iface->apply_template = (apply_shared_template_fc)g_arch_register_apply_template;
+ iface->define_template = (define_shared_template_fc)g_arch_register_define_template;
+ iface->free_template = (free_shared_template_fc)NULL;
iface->get_ref = (get_shared_ref_fc)g_arch_register_get_references;
iface->inc_ref = (inc_shared_ref_fc)g_arch_register_inc_references;
iface->dec_ref = (dec_shared_ref_fc)g_arch_register_dec_references;
- iface->qck_cmp = (qck_compare_shared_fc)g_arch_register_quickly_compare;
+ iface->compare = (compare_shared_fc)g_arch_register_compare_shared;
}
/******************************************************************************
* *
-* Paramètres : binary = instance d'objet GLib à traiter. *
+* Paramètres : reg = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
* *
@@ -184,7 +212,7 @@ static void g_arch_register_dispose(GArchRegister *reg)
/******************************************************************************
* *
-* Paramètres : binary = instance d'objet GLib à traiter. *
+* Paramètres : reg = instance d'objet GLib à traiter. *
* *
* Description : Procède à la libération totale de la mémoire. *
* *
@@ -203,8 +231,31 @@ static void g_arch_register_finalize(GArchRegister *reg)
/******************************************************************************
* *
-* Paramètres : reg = objet partagé à initialiser. *
-* info = information à utiliser pour la mise en place. *
+* Paramètres : reg = instance partagée à consulter. *
+* *
+* Description : Fournit le gestionnaire de partages attribué à un type. *
+* *
+* Retour : Gestionnaire de partages en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GShareManager *get_arch_register_share_manager(const GArchRegister *reg)
+{
+ GShareManager *result; /* Instance à retourner */
+
+ result = G_ARCH_REGISTER_GET_CLASS(reg)->get_manager();
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = objet partagé à initialiser. *
+* template = information à utiliser pour la mise en place. *
* *
* Description : Initialise un nouvel objet partagé avec des informations. *
* *
@@ -214,11 +265,21 @@ static void g_arch_register_finalize(GArchRegister *reg)
* *
******************************************************************************/
-static bool g_arch_register_do_init(GArchRegister *reg, const void *info)
+static bool g_arch_register_apply_template(GArchRegister *reg, const GArchRegister *template)
{
bool result; /* Bilan à retourner */
+ apply_register_template_fc func; /* Fonction à appeler */
- result = G_ARCH_REGISTER_GET_CLASS(reg)->init(G_SHARED_INSTANCE(reg), info);
+ func = G_ARCH_REGISTER_GET_CLASS(reg)->apply_template;
+
+ if (func != NULL)
+ result = func(reg, template);
+
+ else
+ {
+ G_ARCH_REGISTER_GET_CLASS(reg)->define_template(template, reg);
+ result = true;
+ }
return result;
@@ -227,6 +288,26 @@ static bool g_arch_register_do_init(GArchRegister *reg, const void *info)
/******************************************************************************
* *
+* Paramètres : reg = objet partagé à consulter. *
+* template = informations à retrouver intégralement. *
+* *
+* Description : Réalise une copie minimale d'un contenu partagé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arch_register_define_template(const GArchRegister *reg, GArchRegister *template)
+{
+ G_ARCH_REGISTER_GET_CLASS(reg)->define_template(reg, template);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : reg = objet partagé à consulter. *
* *
* Description : Fournit la valeur du compteur de partage. *
@@ -295,11 +376,11 @@ static void g_arch_register_dec_references(GArchRegister *reg)
* *
******************************************************************************/
-static int g_arch_register_quickly_compare(const GArchRegister **a, const GArchRegister **b)
+static int g_arch_register_compare_shared(const GArchRegister * const *a, const GArchRegister * const *b)
{
int result; /* Bilan à faire remonter */
- result = G_ARCH_REGISTER_GET_CLASS(*a)->compare(a, b);
+ result = G_ARCH_REGISTER_GET_CLASS(*a)->compare(*a, *b);
return result;
@@ -338,9 +419,9 @@ guint g_arch_register_hash(const GArchRegister *reg)
* *
******************************************************************************/
-int g_arch_register_compare(const GArchRegister * const *a, const GArchRegister * const *b)
+int g_arch_register_compare(const GArchRegister *a, const GArchRegister *b)
{
- return G_ARCH_REGISTER_GET_CLASS(*a)->compare(a, b);
+ return G_ARCH_REGISTER_GET_CLASS(a)->compare(a, b);
}
@@ -451,6 +532,12 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_register_operand_dispose;
object->finalize = (GObjectFinalizeFunc)g_register_operand_finalize;
+ operand->get_manager = (get_operand_manager_fc)get_register_operand_share_manager;
+
+ operand->apply_template = (apply_operand_template_fc)g_register_operand_apply_template;
+ operand->define_template = (define_operand_template_fc)g_register_operand_define_template;
+ operand->free_template = (free_operand_template_fc)NULL;
+
operand->compare = (operand_compare_fc)g_register_operand_compare;
operand->print = (operand_print_fc)g_register_operand_print;
@@ -518,6 +605,52 @@ static void g_register_operand_finalize(GRegisterOperand *operand)
/******************************************************************************
* *
+* Paramètres : operand = objet partagé à initialiser. *
+* template = information à utiliser pour la mise en place. *
+* *
+* Description : Initialise un nouvel objet partagé avec des informations. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_register_operand_apply_template(GRegisterOperand *operand, const GRegisterOperand *template)
+{
+ g_register_operand_define_template(template, operand);
+
+ g_object_ref(G_OBJECT(operand->reg));
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = objet partagé à consulter. *
+* template = informations à retrouver intégralement. *
+* *
+* Description : Réalise une copie minimale d'un contenu partagé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_register_operand_define_template(const GRegisterOperand *operand, GRegisterOperand *template)
+{
+ template->reg = operand->reg;
+
+ template->is_written = operand->is_written;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : reg = registre déjà en place. *
* *
* Description : Crée un opérande visant un registre. *
@@ -575,12 +708,11 @@ GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand)
* *
******************************************************************************/
-static int g_register_operand_compare(const GRegisterOperand **a, const GRegisterOperand **b)
+static int g_register_operand_compare(const GRegisterOperand *a, const GRegisterOperand *b)
{
int result; /* Bilan à retourner */
- result = g_arch_register_compare((const GArchRegister * const *)&(*a)->reg,
- (const GArchRegister * const *)&(*b)->reg);
+ result = g_arch_register_compare(a->reg, b->reg);
return result;
@@ -644,3 +776,88 @@ bool g_register_operand_is_written(const GRegisterOperand *operand)
return operand->is_written;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* PARTAGES DE CONTENUS UNIQUES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit le gestionnaire de partages attribué à un type. *
+* *
+* Retour : Gestionnaire de partages en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GShareManager *get_register_operand_share_manager(void)
+{
+ return _register_operand_manager;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Met en place les mécanismes de partage des registres. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool init_register_operand_sharing(void)
+{
+ _register_operand_manager = g_share_manager_new(G_TYPE_REGISTER_OPERAND);
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Imprime des statistiques quant aux partages dans l'archi. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+#ifdef DEBUG_DUMP_STATS
+void dump_register_operand_share_stats(void)
+{
+ g_share_manager_dump_stats(_register_operand_manager);
+
+}
+#endif
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Supprime les mécanismes de partage des opérandes de registre.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void exit_register_operand_sharing(void)
+{
+ g_object_unref(G_OBJECT(_register_operand_manager));
+
+}