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

amd64: Implement fldz,fld1

parent 140afeb6
......@@ -367,6 +367,8 @@ emit_reg_in0:;
amd64_emit_immediate32(false, &attr->addr.immediate);
return;
case AMD64_OP_X87:
return;
case AMD64_OP_IMM64:
case AMD64_OP_NONE:
case AMD64_OP_SHIFT_REG:
......
......@@ -73,8 +73,9 @@ static const char *get_op_mode_string(amd64_op_mode_t mode)
case AMD64_OP_REG: return "reg";
case AMD64_OP_SHIFT_IMM: return "shift_imm";
case AMD64_OP_SHIFT_REG: return "shift_reg";
case AMD64_OP_X87: return "x87";
}
panic("invalid op_mode");
return "invalid op_mode";
}
static const char *get_insn_mode_string(amd64_insn_mode_t mode)
......@@ -87,7 +88,7 @@ static const char *get_insn_mode_string(amd64_insn_mode_t mode)
case INSN_MODE_128: return "128";
case INSN_MODE_INVALID: break;
}
panic("invalid insn_mode");
return "invalid insn_mode";
}
/**
......
......@@ -54,6 +54,7 @@ typedef enum {
AMD64_OP_ADDR_IMM,
AMD64_OP_SHIFT_REG,
AMD64_OP_SHIFT_IMM,
AMD64_OP_X87,
} amd64_op_mode_t;
enum {
......
......@@ -215,6 +215,15 @@ my $movopx = {
attr => "amd64_op_mode_t op_mode, amd64_addr_t addr",
};
my $x87const = {
op_flags => [ "constlike" ],
irn_flags => [ "rematerializable" ],
out_reqs => [ "x87" ],
outs => [ "res" ],
fixed => "amd64_op_mode_t op_mode = AMD64_OP_X87;\n",
mode => $mode_x87,
};
%nodes = (
push_am => {
op_flags => [ "uses_memory" ],
......@@ -707,4 +716,14 @@ haddpd => {
emit => "haddpd %AM",
},
fldz => {
template => $x87const,
emit => "fldz",
},
fld1 => {
template => $x87const,
emit => "fld1",
},
);
......@@ -371,6 +371,18 @@ ir_tarval *create_sign_tv(ir_mode *mode)
return tarval_bitcast(sign, mode);
}
static ir_node *gen_x87_Const(ir_node *const block, ir_tarval *const tv)
{
/* TODO: avoid code duplication with ia32 backend */
if (tarval_is_null(tv)) {
return new_bd_amd64_fldz(NULL, block);
} else if (tarval_is_one(tv)) {
return new_bd_amd64_fld1(NULL, block);
} else {
panic("x87 const NIY");
}
}
static ir_node *gen_Const(ir_node *const node)
{
ir_node *block = be_transform_nodes_block(node);
......@@ -379,10 +391,11 @@ static ir_node *gen_Const(ir_node *const node)
ir_tarval *tv = get_Const_tarval(node);
if (!mode_needs_gp_reg(mode)) {
if (tarval_is_null(tv)) {
if (mode == x86_mode_E) {
return gen_x87_Const(block, tv);
} else if (tarval_is_null(tv)) {
return new_bd_amd64_xorpd_0(dbgi, block);
}
return create_float_const(dbgi, block, tv);
}
......
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