summaryrefslogtreecommitdiffhomepage
path: root/ir/be
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2019-03-31 10:34:19 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2019-03-31 11:20:29 +0200
commitc3edec4e6e5e0fb333c006b255c27096c861c696 (patch)
tree850659694276d0f1a44b557e42c3b60b4046c2d9 /ir/be
parent53b34aef48e05172b7089ccdd96f1c474d08b6cc (diff)
amd64: Factor out code to determine the frame offset for an x86_addr_t.
Diffstat (limited to 'ir/be')
-rw-r--r--ir/be/amd64/amd64_bearch.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/ir/be/amd64/amd64_bearch.c b/ir/be/amd64/amd64_bearch.c
index d097307..eeca642 100644
--- a/ir/be/amd64/amd64_bearch.c
+++ b/ir/be/amd64/amd64_bearch.c
@@ -520,13 +520,8 @@ static bool node_has_sp_base(ir_node const *const node,
return base_reg == &amd64_registers[REG_RSP];
}
-static void amd64_determine_frameoffset(ir_node *node, int sp_offset)
+static void amd64_determine_frameoffset_addr(ir_node *const node, x86_addr_t *const addr, int const sp_offset)
{
- if (!is_amd64_irn(node)
- || !amd64_has_addr_attr(get_amd64_attr_const(node)->op_mode))
- return;
-
- x86_addr_t *const addr = &get_amd64_addr_attr(node)->addr;
if (addr->immediate.kind == X86_IMM_FRAMEENT) {
addr->immediate.offset += get_entity_offset(addr->immediate.entity);
addr->immediate.entity = NULL;
@@ -534,9 +529,9 @@ static void amd64_determine_frameoffset(ir_node *node, int sp_offset)
}
if (addr->immediate.kind == X86_IMM_FRAMEOFFSET) {
- if (node_has_sp_base(node, addr))
+ if (node_has_sp_base(node, addr)) {
addr->immediate.offset += sp_offset;
- else {
+ } else {
/* we calculate offsets relative to the SP value at function begin,
* but RBP points after the saved old frame pointer */
addr->immediate.offset += AMD64_REGISTER_SIZE;
@@ -545,6 +540,16 @@ static void amd64_determine_frameoffset(ir_node *node, int sp_offset)
}
}
+static void amd64_determine_frameoffset(ir_node *node, int sp_offset)
+{
+ if (is_amd64_irn(node)) {
+ if (amd64_has_addr_attr(get_amd64_attr_const(node)->op_mode)) {
+ x86_addr_t *const addr = &get_amd64_addr_attr(node)->addr;
+ amd64_determine_frameoffset_addr(node, addr, sp_offset);
+ }
+ }
+}
+
static void amd64_sp_sim(ir_node *const node, stack_pointer_state_t *state)
{
/* Pop nodes modify the stack pointer before calculating destination