summaryrefslogtreecommitdiff
path: root/src/arch/immediate.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-10-29 11:55:02 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-10-29 11:55:02 (GMT)
commit945f58cb1e1b8b6dc444dd0668bd1a2986cd899e (patch)
tree1fc255ced81920e46036699cc55ffc9962807cc2 /src/arch/immediate.c
parent38e455ebbbbf90ddbf552f95a1dfb3c544907587 (diff)
Told GCC to pack enumerations to save memory space.
Diffstat (limited to 'src/arch/immediate.c')
-rw-r--r--src/arch/immediate.c144
1 files changed, 4 insertions, 140 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index 777ae14..9de8c39 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -44,32 +44,8 @@ struct _GImmOperand
{
GArchOperand parent; /* Instance parente */
- MemoryDataSize size; /* Taille de l'opérande */
uint64_t raw; /* Valeur transtypée */
-
- /**
- * Note : dans le cas d'une valeur signée,
- * signed_imm contient la valeur lue/donnée, et
- * unsigned_imm la valeur humainement lisible (ie. positive).
- */
-
- union
- {
- uint8_t val8; /* Valeur sur 8 bits */
- uint16_t val16; /* Valeur sur 16 bits */
- uint32_t val32; /* Valeur sur 32 bits */
- uint64_t val64; /* Valeur sur 64 bits */
-
- } unsigned_imm;
-
- union
- {
- int8_t val8; /* Valeur sur 8 bits */
- int16_t val16; /* Valeur sur 16 bits */
- int32_t val32; /* Valeur sur 32 bits */
- int64_t val64; /* Valeur sur 64 bits */
-
- } signed_imm;
+ MemoryDataSize size; /* Taille de l'opérande */
bool zpad; /* Ajoute des 0 à l'impression */
ImmOperandDisplay def_display; /* Type par défaut d'affichage */
@@ -1009,31 +985,7 @@ void g_imm_operand_as_uleb128(const GImmOperand *operand, uleb128_t *val)
bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr)
{
- bool result; /* Bilan à renvoyer */
-
- result = true;
-
- switch (operand->size)
- {
- case MDS_4_BITS_UNSIGNED:
- case MDS_8_BITS_UNSIGNED:
- *addr = operand->unsigned_imm.val8;
- break;
- case MDS_16_BITS_UNSIGNED:
- *addr = operand->unsigned_imm.val16;
- break;
- case MDS_32_BITS_UNSIGNED:
- *addr = operand->unsigned_imm.val32;
- break;
- case MDS_64_BITS_UNSIGNED:
- *addr = operand->unsigned_imm.val64;
- break;
- default:
- result = false;
- break;
- }
-
- return result;
+ return false;
}
@@ -1054,51 +1006,7 @@ bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr)
bool g_imm_operand_to_size_t(const GImmOperand *operand, size_t *value, bool *negative)
{
- bool result; /* Bilan à renvoyer */
-
- *negative = g_imm_operand_is_negative(operand);
-
- switch (operand->size)
- {
- case MDS_4_BITS_UNSIGNED:
- case MDS_8_BITS_UNSIGNED:
- result = (sizeof(size_t) >= 1);
- if (result) *value = operand->unsigned_imm.val8;
- break;
- case MDS_16_BITS_UNSIGNED:
- result = (sizeof(size_t) >= 2);
- if (result) *value = operand->unsigned_imm.val16;
- break;
- case MDS_32_BITS_UNSIGNED:
- result = (sizeof(size_t) >= 4);
- if (result) *value = operand->unsigned_imm.val32;
- break;
- case MDS_64_BITS_UNSIGNED:
- result = (sizeof(size_t) >= 8);
- if (result) *value = operand->unsigned_imm.val64;
- break;
- case MDS_8_BITS_SIGNED:
- result = (sizeof(size_t) >= 1);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val8;
- break;
- case MDS_16_BITS_SIGNED:
- result = (sizeof(size_t) >= 2);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val16;
- break;
- case MDS_32_BITS_SIGNED:
- result = (sizeof(size_t) >= 4);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val32;
- break;
- case MDS_64_BITS_SIGNED:
- result = (sizeof(size_t) >= 8);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val64;
- break;
- default:
- result = false;
- break;
- }
-
- return result;
+ return false;
}
@@ -1119,50 +1027,6 @@ bool g_imm_operand_to_size_t(const GImmOperand *operand, size_t *value, bool *ne
bool g_imm_operand_to_off_t(const GImmOperand *operand, off_t *value, bool *negative)
{
- bool result; /* Bilan à renvoyer */
-
- *negative = g_imm_operand_is_negative(operand);
-
- switch (operand->size)
- {
- case MDS_4_BITS_UNSIGNED:
- case MDS_8_BITS_UNSIGNED:
- result = (sizeof(off_t) >= 1);
- if (result) *value = operand->unsigned_imm.val8;
- break;
- case MDS_16_BITS_UNSIGNED:
- result = (sizeof(off_t) >= 2);
- if (result) *value = operand->unsigned_imm.val16;
- break;
- case MDS_32_BITS_UNSIGNED:
- result = (sizeof(off_t) >= 4);
- if (result) *value = operand->unsigned_imm.val32;
- break;
- case MDS_64_BITS_UNSIGNED:
- result = (sizeof(off_t) >= 8);
- if (result) *value = operand->unsigned_imm.val64;
- break;
- case MDS_8_BITS_SIGNED:
- result = (sizeof(off_t) >= 1);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val8;
- break;
- case MDS_16_BITS_SIGNED:
- result = (sizeof(off_t) >= 2);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val16;
- break;
- case MDS_32_BITS_SIGNED:
- result = (sizeof(off_t) >= 4);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val32;
- break;
- case MDS_64_BITS_SIGNED:
- result = (sizeof(off_t) >= 8);
- if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val64;
- break;
- default:
- result = false;
- break;
- }
-
- return result;
+ return false;
}