bestack.h 1.66 KB
Newer Older
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 */

/**
 * @file
 * @brief       Helper functions for handling offsets into stack frames/
 *              activation records.
 * @author      Matthias Braun
 */
#ifndef FIRM_BE_BESTACK_H
#define FIRM_BE_BESTACK_H

#include "firm_types.h"
#include "be_types.h"

18
19
20
21
22
23
24
25
26
27
28
/**
 * this constant is returned by the get_sp_bias_func functions if the stack
 * is reset (usually because the frame pointer is copied to the stack
 * pointer
 */
#define SP_BIAS_RESET      INT_MIN

typedef void (*set_frame_offset_func)(ir_node *node, int offset);

typedef int (*get_sp_bias_func)(const ir_node *node);

29
30
/**
 * Rewire all stack modifying nodes and their users to assure SSA property.
31
 * @param sp    The stack pointer register
32
 */
33
void be_fix_stack_nodes(ir_graph *irg, arch_register_t const *sp);
34
35
36
37

/**
 * Fix the stack bias for all nodes accessing the stack frame using the
 * stack pointer.
38
39
40
41
42
43
44
 * @p get_sp_bias should return the delta of the stackpointer for nodes
 * that increment or decrement the stackpointer with constant values.
 * (Such as push and pop variants, be_IncSP, ...). A positive value stands
 * for an expanding stack area, a negative value for a shrinking one,
 * regardless of the actual stack direction of the calling convention.
 * Note that the code already contains a special case for IncSP nodes so the
 * callback does not need to handle them.
45
 */
46
47
void be_abi_fix_stack_bias(ir_graph *irg, get_sp_bias_func get_sp_bias,
                           set_frame_offset_func set_frame_offset);
48
49
50
51
52

int be_get_stack_entity_offset(be_stack_layout_t *frame, ir_entity *ent,
                               int bias);

#endif