Commit 49abde26 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ia32: Add and use ia32_is_8bit_val().

parent 9cd833e4
......@@ -129,4 +129,9 @@ void ia32_adjust_pic(ir_graph *irg);
ir_node *ia32_get_pic_base(ir_graph *irg);
static inline bool ia32_is_8bit_val(int32_t const v)
{
return -128 <= v && v < 128;
}
#endif
......@@ -37,13 +37,13 @@ static bool check_immediate_constraint(long val, char immediate_constraint_type)
case 'i':
case 'n': return true;
case 'I': return 0 <= val && val <= 31;
case 'J': return 0 <= val && val <= 63;
case 'K': return -128 <= val && val <= 127;
case 'I': return 0 <= val && val <= 31;
case 'J': return 0 <= val && val <= 63;
case 'K': return ia32_is_8bit_val(val);
case 'L': return val == 0xff || val == 0xffff;
case 'M': return 0 <= val && val <= 3;
case 'N': return 0 <= val && val <= 255;
case 'O': return 0 <= val && val <= 127;
case 'M': return 0 <= val && val <= 3;
case 'N': return 0 <= val && val <= 255;
case 'O': return 0 <= val && val <= 127;
default: panic("Invalid immediate constraint found");
}
......
......@@ -1920,7 +1920,7 @@ static void bemit_modrm8(reg_modifier_t high_part, const arch_register_t *reg)
*/
static unsigned get_signed_imm_size(int offset)
{
if (-128 <= offset && offset < 128) {
if (ia32_is_8bit_val(offset)) {
return 1;
} else if (-32768 <= offset && offset < 32768) {
return 2;
......@@ -1956,7 +1956,7 @@ static void bemit_mod_am(unsigned reg, const ir_node *node)
} else if (offs == 0) {
modrm |= MOD_IND;
emitoffs = 0;
} else if (-128 <= offs && offs < 128) {
} else if (ia32_is_8bit_val(offs)) {
modrm |= MOD_IND_BYTE_OFS;
emitoffs = 8;
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment