Commit c60f2966 authored by Matthias Braun's avatar Matthias Braun
Browse files

irmode: Remove arithmetic argument from new_{int|reference}_mode()

Your only choice is irma_twos_complement anyway now.
parent a14e8740
...@@ -62,7 +62,6 @@ typedef enum float_int_conversion_overflow_style_t { ...@@ -62,7 +62,6 @@ typedef enum float_int_conversion_overflow_style_t {
* Creates a new mode. * Creates a new mode.
* *
* @param name the name of the mode to be created * @param name the name of the mode to be created
* @param arithmetic arithmetic operations possible with a mode
* @param bit_size number of bits this mode allocate * @param bit_size number of bits this mode allocate
* @param sign non-zero if this is a signed mode * @param sign non-zero if this is a signed mode
* @param modulo_shift Is ignored for modes other than integer. * @param modulo_shift Is ignored for modes other than integer.
...@@ -70,22 +69,21 @@ typedef enum float_int_conversion_overflow_style_t { ...@@ -70,22 +69,21 @@ typedef enum float_int_conversion_overflow_style_t {
* This function constructs a new mode given by the parameters. * This function constructs a new mode given by the parameters.
* If the parameters match an already defined mode, this mode is returned * If the parameters match an already defined mode, this mode is returned
* (including the default modes). * (including the default modes).
* Arithmetic of int modes is irma_twos_complement.
* *
* @return * @return
* The new mode or NULL on error. * The new mode or NULL on error.
*/ */
FIRM_API ir_mode *new_int_mode(const char *name, FIRM_API ir_mode *new_int_mode(const char *name,
ir_mode_arithmetic arithmetic,
unsigned bit_size, int sign, unsigned bit_size, int sign,
unsigned modulo_shift); unsigned modulo_shift);
/** /**
* Create a new reference mode. * Create a new reference mode.
*
* Reference modes are always unsigned. * Reference modes are always unsigned.
* Arithmetic of reference modes is irma_twos_complement.
*/ */
FIRM_API ir_mode *new_reference_mode(const char *name, FIRM_API ir_mode *new_reference_mode(const char *name,
ir_mode_arithmetic arithmetic,
unsigned bit_size, unsigned bit_size,
unsigned modulo_shift); unsigned modulo_shift);
......
...@@ -776,12 +776,12 @@ static int amd64_is_valid_clobber(const char *clobber) ...@@ -776,12 +776,12 @@ static int amd64_is_valid_clobber(const char *clobber)
static void amd64_init_types(void) static void amd64_init_types(void)
{ {
ir_mode *const ptr_mode = new_reference_mode("p64", irma_twos_complement, 64, 64); ir_mode *const ptr_mode = new_reference_mode("p64", 64, 64);
set_modeP(ptr_mode); set_modeP(ptr_mode);
/* use an int128 mode for xmm registers for now, so that firm allows us to /* use an int128 mode for xmm registers for now, so that firm allows us to
* create constants with the xmm mode... */ * create constants with the xmm mode... */
amd64_mode_xmm = new_int_mode("x86_xmm", irma_twos_complement, 128, 0, 0); amd64_mode_xmm = new_int_mode("x86_xmm", 128, 0, 0);
ir_type *const type_f80 = x86_init_x87_type(); ir_type *const type_f80 = x86_init_x87_type();
amd64_backend_params.type_long_double = type_f80; amd64_backend_params.type_long_double = type_f80;
......
...@@ -129,10 +129,9 @@ static void arm_create_runtime_entities(void) ...@@ -129,10 +129,9 @@ static void arm_create_runtime_entities(void)
if (divsi3 != NULL) if (divsi3 != NULL)
return; return;
ir_mode *mode_int = new_int_mode("arm_be_int", irma_twos_complement, ir_mode *mode_int = new_int_mode("arm_be_int", ARM_MACHINE_SIZE, true,
ARM_MACHINE_SIZE, true, ARM_MODULO_SHIFT); ARM_MODULO_SHIFT);
ir_mode *mode_uint = new_int_mode("arm_be_int", irma_twos_complement, ir_mode *mode_uint = new_int_mode("arm_be_int", ARM_MACHINE_SIZE, false,
ARM_MACHINE_SIZE, false,
ARM_MODULO_SHIFT); ARM_MODULO_SHIFT);
ir_type *int_tp = get_type_for_mode(mode_int); ir_type *int_tp = get_type_for_mode(mode_int);
...@@ -291,11 +290,11 @@ static const backend_params *arm_get_libfirm_params(void) ...@@ -291,11 +290,11 @@ static const backend_params *arm_get_libfirm_params(void)
static void arm_init(void) static void arm_init(void)
{ {
arm_mode_gp = new_int_mode("arm_gp", irma_twos_complement, arm_mode_gp = new_int_mode("arm_gp", ARM_MACHINE_SIZE, 0,
ARM_MACHINE_SIZE, 0, ARM_MODULO_SHIFT); ARM_MODULO_SHIFT);
arm_mode_flags = new_non_arithmetic_mode("arm_flags", 32); arm_mode_flags = new_non_arithmetic_mode("arm_flags", 32);
set_modeP(new_reference_mode("p32", irma_twos_complement, ARM_MACHINE_SIZE, ARM_MODULO_SHIFT)); set_modeP(new_reference_mode("p32", ARM_MACHINE_SIZE, ARM_MODULO_SHIFT));
arm_register_init(); arm_register_init();
arm_create_opcodes(); arm_create_opcodes();
......
...@@ -1379,7 +1379,7 @@ static void ia32_init(void) ...@@ -1379,7 +1379,7 @@ static void ia32_init(void)
ia32_mode_fpcw = new_non_arithmetic_mode("fpcw", 16); ia32_mode_fpcw = new_non_arithmetic_mode("fpcw", 16);
ia32_mode_flags = new_non_arithmetic_mode("flags", 32); ia32_mode_flags = new_non_arithmetic_mode("flags", 32);
ia32_mode_gp = new_int_mode("gp", irma_twos_complement, 32, 0, 32); ia32_mode_gp = new_int_mode("gp", 32, 0, 32);
ia32_mode_float64 = new_float_mode("fp64", irma_ieee754, 11, 52, ia32_mode_float64 = new_float_mode("fp64", irma_ieee754, 11, 52,
ir_overflow_indefinite); ir_overflow_indefinite);
ia32_mode_float32 = new_float_mode("fp32", irma_ieee754, 8, 23, ia32_mode_float32 = new_float_mode("fp32", irma_ieee754, 8, 23,
......
...@@ -2101,18 +2101,20 @@ static void read_modes(read_env_t *env) ...@@ -2101,18 +2101,20 @@ static void read_modes(read_env_t *env)
case kw_int_mode: { case kw_int_mode: {
const char *name = read_string(env); const char *name = read_string(env);
ir_mode_arithmetic arith = read_mode_arithmetic(env); ir_mode_arithmetic arith = read_mode_arithmetic(env);
assert(arith == irma_twos_complement);
int size = read_long(env); int size = read_long(env);
int sign = read_long(env); int sign = read_long(env);
unsigned modulo_shift = read_long(env); unsigned modulo_shift = read_long(env);
new_int_mode(name, arith, size, sign, modulo_shift); new_int_mode(name, size, sign, modulo_shift);
break; break;
} }
case kw_reference_mode: { case kw_reference_mode: {
const char *name = read_string(env); const char *name = read_string(env);
ir_mode_arithmetic arith = read_mode_arithmetic(env); ir_mode_arithmetic arith = read_mode_arithmetic(env);
assert(arith == irma_twos_complement);
int size = read_long(env); int size = read_long(env);
unsigned modulo_shift = read_long(env); unsigned modulo_shift = read_long(env);
ir_mode *mode = new_reference_mode(name, arith, size, modulo_shift); ir_mode *mode = new_reference_mode(name, size, modulo_shift);
set_reference_offset_mode(mode, read_mode_ref(env)); set_reference_offset_mode(mode, read_mode_ref(env));
int is_mode_P = read_int(env); int is_mode_P = read_int(env);
if (is_mode_P) if (is_mode_P)
......
...@@ -139,33 +139,32 @@ static ir_mode *register_mode(ir_mode *mode) ...@@ -139,33 +139,32 @@ static ir_mode *register_mode(ir_mode *mode)
return mode; return mode;
} }
ir_mode *new_int_mode(const char *name, ir_mode_arithmetic arithmetic, ir_mode *new_int_mode(const char *name, unsigned bit_size, int sign,
unsigned bit_size, int sign, unsigned modulo_shift) unsigned modulo_shift)
{ {
if (bit_size >= (unsigned)sc_get_precision()) if (bit_size >= (unsigned)sc_get_precision())
panic("cannot create mode: more bits than tarval module maximum"); panic("cannot create mode: more bits than tarval module maximum");
ir_mode *result = alloc_mode(name, irms_int_number, arithmetic, bit_size, ir_mode *result = alloc_mode(name, irms_int_number, irma_twos_complement,
sign, modulo_shift); bit_size, sign, modulo_shift);
return register_mode(result); return register_mode(result);
} }
ir_mode *new_reference_mode(const char *name, ir_mode_arithmetic arithmetic, ir_mode *new_reference_mode(const char *name, unsigned bit_size,
unsigned bit_size, unsigned modulo_shift) unsigned modulo_shift)
{ {
if (bit_size >= (unsigned)sc_get_precision()) if (bit_size >= (unsigned)sc_get_precision())
panic("cannot create mode: more bits than tarval module maximum"); panic("cannot create mode: more bits than tarval module maximum");
ir_mode *result = alloc_mode(name, irms_reference, arithmetic, bit_size, ir_mode *result = alloc_mode(name, irms_reference, irma_twos_complement,
0, modulo_shift); bit_size, 0, modulo_shift);
ir_mode *res = register_mode(result); ir_mode *res = register_mode(result);
/* Construct offset mode if none is set yet. */ /* Construct offset mode if none is set yet. */
if (res->offset_mode == NULL) { if (res->offset_mode == NULL) {
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "%s_i", name); snprintf(buf, sizeof(buf), "%s_i", name);
ir_mode *offset_mode = new_int_mode(buf, arithmetic, bit_size, 1, ir_mode *offset_mode = new_int_mode(buf, bit_size, 1, modulo_shift);
modulo_shift);
res->offset_mode = offset_mode; res->offset_mode = offset_mode;
} }
return res; return res;
...@@ -449,16 +448,16 @@ void init_mode(void) ...@@ -449,16 +448,16 @@ void init_mode(void)
mode_F = new_float_mode("F", irma_ieee754, 8, 23, ir_overflow_min_max); mode_F = new_float_mode("F", irma_ieee754, 8, 23, ir_overflow_min_max);
mode_D = new_float_mode("D", irma_ieee754, 11, 52, ir_overflow_min_max); mode_D = new_float_mode("D", irma_ieee754, 11, 52, ir_overflow_min_max);
mode_Bs = new_int_mode("Bs", irma_twos_complement, 8, 1, 32); mode_Bs = new_int_mode("Bs", 8, 1, 32);
mode_Bu = new_int_mode("Bu", irma_twos_complement, 8, 0, 32); mode_Bu = new_int_mode("Bu", 8, 0, 32);
mode_Hs = new_int_mode("Hs", irma_twos_complement, 16, 1, 32); mode_Hs = new_int_mode("Hs", 16, 1, 32);
mode_Hu = new_int_mode("Hu", irma_twos_complement, 16, 0, 32); mode_Hu = new_int_mode("Hu", 16, 0, 32);
mode_Is = new_int_mode("Is", irma_twos_complement, 32, 1, 32); mode_Is = new_int_mode("Is", 32, 1, 32);
mode_Iu = new_int_mode("Iu", irma_twos_complement, 32, 0, 32); mode_Iu = new_int_mode("Iu", 32, 0, 32);
mode_Ls = new_int_mode("Ls", irma_twos_complement, 64, 1, 64); mode_Ls = new_int_mode("Ls", 64, 1, 64);
mode_Lu = new_int_mode("Lu", irma_twos_complement, 64, 0, 64); mode_Lu = new_int_mode("Lu", 64, 0, 64);
mode_P = new_reference_mode("P", irma_twos_complement, 32, 32); mode_P = new_reference_mode("P", 32, 32);
} }
ir_mode *find_unsigned_mode(const ir_mode *mode) ir_mode *find_unsigned_mode(const ir_mode *mode)
......
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