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

amd64: use symbolic constants instead of numbers, fix wrong constants

parent 0cd0a913
......@@ -16,6 +16,14 @@
#include "amd64_nodes_attr.h"
#include "gen_amd64_new_nodes.h"
enum {
pn_amd64_Call_mem = 0,
pn_amd64_Call_first_res = 1,
};
enum {
n_amd64_Return_stack = 1,
};
static inline amd64_attr_t *get_amd64_attr(ir_node *node)
{
assert(is_amd64_irn(node));
......
......@@ -1455,9 +1455,10 @@ static ir_node *gen_Return(ir_node *node)
reqs[p] = arch_no_register_req;
++p;
in[p] = sp;
reqs[p] = amd64_registers[REG_RSP].single_req;
++p;
unsigned spp = p++;
assert(spp == n_amd64_Return_stack);
in[spp] = sp;
reqs[spp] = amd64_registers[REG_RSP].single_req;
/* result values */
for (size_t i = 0; i < n_res; ++i) {
......@@ -1685,8 +1686,13 @@ static ir_node *gen_Call(ir_node *node)
/* create output register reqs */
int o = 0;
arch_set_irn_register_req_out(call, o++, arch_no_register_req);
int memo = o++;
arch_set_irn_register_req_out(call, memo, arch_no_register_req);
assert(memo == pn_amd64_Call_mem);
/* add register requirements for the result regs */
assert(o == pn_amd64_Call_first_res);
for (size_t r = 0; r < n_ress; ++r) {
const reg_or_stackslot_t *result_info = &cconv->results[r];
const arch_register_req_t *req = result_info->req;
......@@ -1730,7 +1736,7 @@ static ir_node *gen_Proj_Call(ir_node *node)
ir_node *new_call = be_transform_node(call);
switch ((pn_Call)pn) {
case pn_Call_M:
return new_r_Proj(new_call, mode_M, 0);
return new_r_Proj(new_call, mode_M, pn_amd64_Call_mem);
case pn_Call_X_regular:
case pn_Call_X_except:
case pn_Call_T_result:
......@@ -1746,9 +1752,9 @@ static ir_node *gen_Proj_Proj_Call(ir_node *node)
ir_node *new_call = be_transform_node(call);
ir_type *tp = get_Call_type(call);
amd64_cconv_t *cconv = amd64_decide_calling_convention(tp, NULL);
const reg_or_stackslot_t *res = &cconv->results[pn];
ir_mode *mode = get_irn_mode(node);
unsigned new_pn = 1 + res->reg_offset;
const reg_or_stackslot_t *res = &cconv->results[pn];
ir_mode *mode = get_irn_mode(node);
unsigned new_pn = pn_amd64_Call_first_res+res->reg_offset;
assert(res->req != NULL);
if (mode_needs_gp_reg(mode))
......
......@@ -529,7 +529,7 @@ static void introduce_epilogue(ir_node *ret)
ir_type *frame_type = get_irg_frame_type(irg);
unsigned frame_size = get_type_size_bytes(frame_type);
be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
ir_node *first_sp = get_irn_n(ret, n_be_Return_sp);
ir_node *first_sp = get_irn_n(ret, n_amd64_Return_stack);
ir_node *curr_sp = first_sp;
ir_mode *mode_gp = mode_Lu;
......@@ -553,7 +553,7 @@ static void introduce_epilogue(ir_node *ret)
curr_sp = incsp;
}
}
set_irn_n(ret, n_be_Return_sp, curr_sp);
set_irn_n(ret, n_amd64_Return_stack, curr_sp);
/* keep verifier happy... */
if (get_irn_n_edges(first_sp) == 0 && is_Proj(first_sp)) {
......@@ -615,7 +615,7 @@ static void introduce_prologue_epilogue(ir_graph *irg)
/* introduce epilogue for every return node */
foreach_irn_in(get_irg_end_block(irg), i, ret) {
assert(be_is_Return(ret) || is_amd64_Return(ret));
assert(is_amd64_Return(ret));
introduce_epilogue(ret);
}
}
......
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