2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Helper functions for handling ABI constraints in the code
24 * @author Matthias Braun
27 #ifndef FIRM_BE_BEABI_HELPER_H
28 #define FIRM_BE_BEABI_HELPER_H
30 #include "firm_types.h"
34 typedef struct beabi_helper_env_t beabi_helper_env_t;
36 beabi_helper_env_t *be_abihelper_prepare(ir_graph *irg);
38 void be_abihelper_finish(beabi_helper_env_t *env);
41 * Mark a registers value at the beginning of the function as significant.
42 * This is necessary for things like:
43 * - Callee-Save registers (we need to restore that value at the end)
44 * - Parameters passed in registers
45 * - stack pointer, base pointer, ...
46 * It is possible to specify additional irn flags (usefull to mark a value
47 * as ignore or produces_sp).
49 void be_prolog_add_reg(beabi_helper_env_t *env, const arch_register_t *reg,
50 arch_register_req_type_t flags);
53 * Creates a start node.
54 * Must be called after all prolog_add_reg calls
56 ir_node *be_prolog_create_start(beabi_helper_env_t *env, dbg_info *dbgi,
60 * Creates a barrier node which lets all registers specified by prolog_add_reg
63 ir_node *be_prolog_create_barrier(beabi_helper_env_t *env, ir_node *block);
66 * Get "value" of a register.
67 * This usually creates a Proj node for the start-node or barrier-node.
68 * Or returns the value set by a abi_helper_set_reg_value call
70 ir_node *be_prolog_get_reg_value(beabi_helper_env_t *env,
71 const arch_register_t *reg);
73 ir_node *be_prolog_get_memory(beabi_helper_env_t *env);
76 * Set current register value.
78 void be_prolog_set_reg_value(beabi_helper_env_t *env,
79 const arch_register_t *reg, ir_node *value);
81 void be_prolog_set_memory(beabi_helper_env_t *env, ir_node *value);
84 * Set value of register at the end of the function. Necessary for:
85 * - Callee-save registers
86 * - Return values in registers
87 * - stack pointer, base pointer
89 void be_epilog_add_reg(beabi_helper_env_t *env, const arch_register_t *reg,
90 arch_register_req_type_t flags, ir_node *value);
92 void be_epilog_set_reg_value(beabi_helper_env_t *env,
93 const arch_register_t *reg, ir_node *value);
95 ir_node *be_epilog_get_reg_value(beabi_helper_env_t *env,
96 const arch_register_t *reg);
98 void be_epilog_set_memory(beabi_helper_env_t *env, ir_node *value);
100 ir_node *be_epilog_get_memory(beabi_helper_env_t *env);
102 void be_epilog_begin(beabi_helper_env_t *env);
104 ir_node *be_epilog_create_barrier(beabi_helper_env_t *env, ir_node *block);
107 * Create return node and finishes epilog handling
109 ir_node *be_epilog_create_return(beabi_helper_env_t *env, dbg_info *dbgi,
113 * Adds a X->Proj->Keep for each output value of X which has no Proj yet
115 void be_add_missing_keeps(ir_graph *irg);
118 * Collect firm nodes that will probably modify the stack.
119 * Put them into an order that respects all their dependencies.
121 void be_collect_stacknodes(beabi_helper_env_t *env);
124 * return node that should produce the predecessor stack node in a block.
125 * returns NULL if there's no predecessor in the current block.
127 ir_node *be_get_stack_pred(const beabi_helper_env_t *env, const ir_node *node);