Commit a5e1011f authored by Michael Beck's avatar Michael Beck
Browse files

Experimental support for double word irarch.

include/libfirm/irarch.h
- give the mode to the eval function

ir/be/ia32/bearch_ia32.c
- the maximum allowed shift is 63 (for double-word shifts) on x86, not 31

ir/be/ia32/ia32_architecture.c
ir/be/ia32/ia32_architecture.h
- estimate the cost for 64bit operations

ir/ir/irarch.c
- pass the mode

[r28081]
parent c09f6076
......@@ -47,11 +47,12 @@ typedef enum instr {
* A Callback for evaluating the costs of an instruction.
*
* @param kind the instruction
* @param mode the mode of the instruction
* @param tv for MUL instruction, the multiplication constant
*
* @return the costs of this instruction
*/
typedef int (*evaluate_costs_func)(insn_kind kind, ir_tarval *tv);
typedef int (*evaluate_costs_func)(insn_kind kind, const ir_mode *mode, ir_tarval *tv);
/**
* A parameter structure that drives the machine dependent Firm
......
......@@ -2123,7 +2123,7 @@ static const backend_params *ia32_get_libfirm_params(void)
static const ir_settings_arch_dep_t ad = {
1, /* also use subs */
4, /* maximum shifts */
31, /* maximum shift amount */
63, /* maximum shift amount */
ia32_evaluate_insn, /* evaluate the instruction sequence */
1, /* allow Mulhs */
......
......@@ -438,13 +438,13 @@ static void set_arch_costs(void)
}
/* Evaluate the costs of an instruction. */
int ia32_evaluate_insn(insn_kind kind, ir_tarval *tv)
int ia32_evaluate_insn(insn_kind kind, const ir_mode *mode, ir_tarval *tv)
{
int cost;
switch (kind) {
case MUL:
cost = arch_costs->cost_mul_start;
cost = arch_costs->cost_mul_start;
if (arch_costs->cost_mul_bit > 0) {
char *bitstr = get_tarval_bitpattern(tv);
int i;
......@@ -456,14 +456,26 @@ int ia32_evaluate_insn(insn_kind kind, ir_tarval *tv)
}
free(bitstr);
}
return cost;
if (get_mode_size_bits(mode) <= 32)
return cost;
/* 64bit mul supported, approx 4times of a 32bit mul*/
return 4 * cost;
case LEA:
return arch_costs->lea_cost;
/* lea is only supported for 32 bit */
if (get_mode_size_bits(mode) <= 32)
return arch_costs->lea_cost;
return 0x10000;
case ADD:
case SUB:
return arch_costs->add_cost;
if (get_mode_size_bits(mode) <= 32)
return arch_costs->add_cost;
/* 64bit add/sub supported, double the cost */
return 2 * arch_costs->add_cost;
case SHIFT:
return arch_costs->const_shf_cost;
if (get_mode_size_bits(mode) <= 32)
return arch_costs->const_shf_cost;
/* 64bit shift supported, double the cost */
return 2 * arch_costs->const_shf_cost;
case ZERO:
return arch_costs->add_cost;
default:
......
......@@ -115,10 +115,11 @@ void ia32_setup_cg_config(void);
* lowerer.
*
* @param kind the instruction
* @param mode the mode of the instruction
* @param tv for MUL instruction, the multiplication constant
*
* @return the cost
*/
int ia32_evaluate_insn(insn_kind kind, ir_tarval *tv);
int ia32_evaluate_insn(insn_kind kind, const ir_mode *mode, ir_tarval *tv);
#endif
......@@ -104,8 +104,9 @@ typedef struct mul_env {
* Some kind of default evaluator. Return the cost of
* instructions.
*/
static int default_evaluate(insn_kind kind, ir_tarval *tv)
static int default_evaluate(insn_kind kind, const ir_mode *mode, ir_tarval *tv)
{
(void) mode;
(void) tv;
if (kind == MUL)
......@@ -485,7 +486,7 @@ static int evaluate_insn(mul_env *env, instruction *inst)
case ADD:
costs = evaluate_insn(env, inst->in[0]);
costs += evaluate_insn(env, inst->in[1]);
costs += env->evaluate(inst->kind, NULL);
costs += env->evaluate(inst->kind, env->mode, NULL);
inst->costs = costs;
return costs;
case SHIFT:
......@@ -496,11 +497,11 @@ static int evaluate_insn(mul_env *env, instruction *inst)
else
--env->n_shift;
costs = evaluate_insn(env, inst->in[0]);
costs += env->evaluate(inst->kind, NULL);
costs += env->evaluate(inst->kind, env->mode, NULL);
inst->costs = costs;
return costs;
case ZERO:
inst->costs = costs = env->evaluate(inst->kind, NULL);
inst->costs = costs = env->evaluate(inst->kind, env->mode, NULL);
return costs;
case MUL:
case ROOT:
......@@ -544,7 +545,7 @@ static ir_node *do_decomposition(ir_node *irn, ir_node *operand, ir_tarval *tv)
inst = decompose_mul(&env, R, r, tv);
/* the paper suggests 70% here */
mul_costs = (env.evaluate(MUL, tv) * 7 + 5) / 10;
mul_costs = (env.evaluate(MUL, env.mode, tv) * 7 + 5) / 10;
if (evaluate_insn(&env, inst) <= mul_costs && !env.fail) {
env.op = operand;
env.blk = get_nodes_block(irn);
......
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