diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-07-12 13:07:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-07-12 13:08:42 (GMT) |
commit | a331ff258895865049bf79bc1629dbc744b7faf5 (patch) | |
tree | c4f649ba21afcacf974cc6536f03aa97663a9acd /src/arch/register.c | |
parent | 9b018cede5af54594c0a20847239233153b04ce1 (diff) |
Removed the too complex memory share system.
Diffstat (limited to 'src/arch/register.c')
-rw-r--r-- | src/arch/register.c | 398 |
1 files changed, 15 insertions, 383 deletions
diff --git a/src/arch/register.c b/src/arch/register.c index 3071198..bbad23f 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -37,37 +37,12 @@ static void g_arch_register_class_init(GArchRegisterClass *); /* Initialise une instance de registre. */ static void g_arch_register_init(GArchRegister *); -/* Procède à l'initialisation de l'interface de partage. */ -static void g_arch_register_interface_init(GSharedInstanceInterface *); - /* Supprime toutes les références externes. */ 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_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 *); - -/* Incrémente le compteur de partage. */ -static void g_arch_register_inc_references(GArchRegister *); - -/* Décrémente le compteur de partage. */ -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_compare_shared(const GArchRegister * const *, const GArchRegister * const *); - - /* ------------------------- REGISTRE SOUS FORME D'OPERANDE ------------------------- */ @@ -84,12 +59,6 @@ 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 *); @@ -98,26 +67,13 @@ static void g_register_operand_print(const GRegisterOperand *, GBufferLine *, As -/* -------------------------- 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 */ /* ---------------------------------------------------------------------------------- */ /* Indique le type défini pour une représentation d'un registre. */ -G_DEFINE_TYPE_WITH_CODE(GArchRegister, g_arch_register, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_SHARED_INSTANCE, g_arch_register_interface_init)); +G_DEFINE_TYPE(GArchRegister, g_arch_register, G_TYPE_OBJECT); /****************************************************************************** @@ -164,35 +120,6 @@ static void g_arch_register_init(GArchRegister *reg) /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * -* * -* Description : Procède à l'initialisation de l'interface de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arch_register_interface_init(GSharedInstanceInterface *iface) -{ - 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->compare = (compare_shared_fc)g_arch_register_compare_shared; - -} - - -/****************************************************************************** -* * * Paramètres : reg = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * @@ -231,164 +158,6 @@ static void g_arch_register_finalize(GArchRegister *reg) /****************************************************************************** * * -* 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. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool g_arch_register_apply_template(GArchRegister *reg, const GArchRegister *template) -{ - bool result; /* Bilan à retourner */ - apply_register_template_fc func; /* Fonction à appeler */ - - 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; - -} - - -/****************************************************************************** -* * -* 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. * -* * -* Retour : Nombre de partages courant. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static unsigned int g_arch_register_get_references(const GArchRegister *reg) -{ - return reg->shared_count; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = objet partagé à modifier. * -* * -* Description : Incrémente le compteur de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arch_register_inc_references(GArchRegister *reg) -{ - reg->shared_count++; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = objet partagé à modifier. * -* * -* Description : Décrémente le compteur de partage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arch_register_dec_references(GArchRegister *reg) -{ - reg->shared_count--; - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier registre à consulter. * -* b = second registre à consulter. * -* * -* Description : Compare de façon accélérée un registre avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -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); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : reg = opérande à consulter pour le calcul. * * * * Description : Produit une empreinte à partir d'un registre. * @@ -532,12 +301,6 @@ 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; @@ -605,34 +368,35 @@ static void g_register_operand_finalize(GRegisterOperand *operand) /****************************************************************************** * * -* Paramètres : operand = objet partagé à initialiser. * -* template = information à utiliser pour la mise en place. * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * * * -* Description : Initialise un nouvel objet partagé avec des informations. * +* Description : Compare un opérande avec un autre. * * * -* Retour : Bilan de l'opération. * +* Retour : Bilan de la comparaison. * * * * Remarques : - * * * ******************************************************************************/ -static bool g_register_operand_apply_template(GRegisterOperand *operand, const GRegisterOperand *template) +static int g_register_operand_compare(const GRegisterOperand *a, const GRegisterOperand *b) { - g_register_operand_define_template(template, operand); + int result; /* Bilan à retourner */ - g_object_ref(G_OBJECT(operand->reg)); + result = g_arch_register_compare(a->reg, b->reg); - return true; + return result; } /****************************************************************************** * * -* Paramètres : operand = objet partagé à consulter. * -* template = informations à retrouver intégralement. * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * * * -* Description : Réalise une copie minimale d'un contenu partagé. * +* Description : Traduit un opérande en version humainement lisible. * * * * Retour : - * * * @@ -640,11 +404,9 @@ static bool g_register_operand_apply_template(GRegisterOperand *operand, const G * * ******************************************************************************/ -static void g_register_operand_define_template(const GRegisterOperand *operand, GRegisterOperand *template) +static void g_register_operand_print(const GRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) { - template->reg = operand->reg; - - template->is_written = operand->is_written; + g_arch_register_print(operand->reg, line, syntax); } @@ -697,51 +459,6 @@ GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand) /****************************************************************************** * * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_register_operand_compare(const GRegisterOperand *a, const GRegisterOperand *b) -{ - int result; /* Bilan à retourner */ - - result = g_arch_register_compare(a->reg, b->reg); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_register_operand_print(const GRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - g_arch_register_print(operand->reg, line, syntax); - -} - - -/****************************************************************************** -* * * Paramètres : operand = opérande représentant un registre à mettre à jour. * * * * Description : Marque l'opérande comme étant écrit plutôt que consulté. * @@ -776,88 +493,3 @@ 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)); - -} |