diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-01-30 23:23:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-01-30 23:23:16 (GMT) |
commit | 62f178cc3dcc889d56ba6d94f6fc8bba7b503c1a (patch) | |
tree | 9d0a95ea433a42351ae7aa783356aa2e30a39f34 /src/arch/instruction.c | |
parent | c1ca03be00a4e975f89d30edfb72b57fb5612282 (diff) |
Compressed some architecture instruction properties.
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 108 |
1 files changed, 97 insertions, 11 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index f571330..d3ac97e 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -139,6 +139,8 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass) static void g_arch_instruction_init(GArchInstruction *instr) { + INIT_ARCH_INSTR_EXTRA(instr); + instr->operands = NULL; instr->from = NULL; @@ -278,9 +280,20 @@ const char *g_arch_instruction_get_encoding(const GArchInstruction *instr) bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag) { - instr->flags |= flag; + bool result; /* Bilan à retourner */ + instr_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_ARCH_INSTR_EXTRA(instr); + + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + extra->flags |= flag; + + result = true; - return true; + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + return result; } @@ -301,8 +314,15 @@ bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag) bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag flag) { bool result; /* Bilan à retourner */ + instr_obj_extra *extra; /* Données insérées à consulter*/ + + extra = GET_ARCH_INSTR_EXTRA(instr); + + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); - result = (instr->flags & flag); + result = (extra->flags & flag); + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); return result; @@ -323,7 +343,46 @@ bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag fl ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) { - return instr->flags; + ArchInstrFlag result; /* Fanions à retourner */ + instr_obj_extra *extra; /* Données insérées à consulter*/ + + extra = GET_ARCH_INSTR_EXTRA(instr); + + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + result = extra->flags; + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction quelconque à consulter. * +* uid = identifiant unique par type d'instruction. * +* * +* Description : Définit l'identifiant unique pour un ensemble d'instructions.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_arch_instruction_set_unique_id(GArchInstruction *instr, itid_t uid) +{ + instr_obj_extra *extra; /* Données insérées à modifier */ + + extra = GET_ARCH_INSTR_EXTRA(instr); + + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + extra->uid = uid; + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); } @@ -343,8 +402,15 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) itid_t g_arch_instruction_get_unique_id(const GArchInstruction *instr) { itid_t result; /* Numéro à retourner */ + instr_obj_extra *extra; /* Données insérées à consulter*/ + + extra = GET_ARCH_INSTR_EXTRA(instr); - result = instr->uid; + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + result = extra->uid; + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); return result; @@ -1409,6 +1475,7 @@ static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage GArchOperand *op; /* Opérande à traiter */ instr_link_t link; /* Lien vers une instruction */ packed_buffer ins_pbuf; /* Tampon des données à écrire */ + instr_obj_extra *extra; /* Données insérées à consulter*/ result = unpack_mrange(&instr->range, pbuf); @@ -1489,10 +1556,19 @@ static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage } if (result) - result = extract_packed_buffer(pbuf, &instr->uid, sizeof(itid_t), true); + { + extra = GET_ARCH_INSTR_EXTRA(instr); - if (result) - result = extract_packed_buffer(pbuf, &instr->flags, sizeof(ArchInstrFlag), true); + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + result = extract_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); + + if (result) + result = extract_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + } return result; @@ -1561,6 +1637,7 @@ static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *s off64_t pos; /* Position dans le flux */ size_t kept; /* Nombre de liens conservés */ const instr_link_t *link; /* Lien vers une instruction */ + instr_obj_extra *extra; /* Données insérées à consulter*/ result = pack_mrange(&instr->range, pbuf); @@ -1661,10 +1738,19 @@ static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *s } if (result) - result = extend_packed_buffer(pbuf, &instr->uid, sizeof(itid_t), true); + { + extra = GET_ARCH_INSTR_EXTRA(instr); - if (result) - result = extend_packed_buffer(pbuf, &instr->flags, sizeof(ArchInstrFlag), true); + g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + result = extend_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); + + if (result) + result = extend_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); + + g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT); + + } return result; |