2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Backend ABI implementation.
9 * @author Sebastian Hack
11 #ifndef FIRM_BE_BEABI_H
12 #define FIRM_BE_BEABI_H
17 #include "firm_types.h"
19 struct be_abi_call_flags_t {
20 bool try_omit_fp : 1; /**< Try to omit the frame pointer. */
21 bool call_has_imm : 1; /**< A call can take the callee's address as an
25 struct be_abi_callbacks_t {
27 * Get the between type for that call.
28 * @param self The callback object.
29 * @return The between type of for that call.
31 ir_type *(*get_between_type)(ir_graph *irg);
35 * Set the flags for a call.
36 * @param call The call.
37 * @param flags Some flags to be set.
38 * @param cb The call callbacks for that call.
39 * @note The ABI phase might change the flags due to analysis.
41 void be_abi_call_set_flags(be_abi_call_t *call, be_abi_call_flags_t flags, const be_abi_callbacks_t *cb);
44 * Sets the number of bytes the stackframe is shrinked by the callee on return
46 void be_abi_call_set_pop(be_abi_call_t *call, int pop);
49 * The ABI can change when we call a function vs. when we have
53 ABI_CONTEXT_CALLEE = 1 << 0,
54 ABI_CONTEXT_CALLER = 1 << 1,
55 ABI_CONTEXT_BOTH = ABI_CONTEXT_CALLEE | ABI_CONTEXT_CALLER
59 * Record the that ABI transmits call argument pos on the stack. Modifies the abi object.
61 * @param call the abi call object
62 * @param pos the parameter position
63 * @param load_mode load the parameter with this mode (if the parameter mode is different from this mode a Conv is inserted)
64 * @param alignment stack alignment for the parameter on the current architecture
65 * @param space_before size of allocated additional space before the parameter
66 * @param space_after size of allocated additional space after the parameter
68 void be_abi_call_param_stack(be_abi_call_t *call, int pos, ir_mode *load_mode,
69 unsigned alignment, unsigned space_before,
70 unsigned space_after, be_abi_context_t context);
73 * Record the that ABI transmits call argument pos in the given register.
75 * @param call the abi call object
76 * @param pos the parameter position
77 * @param reg the register used
79 void be_abi_call_param_reg(be_abi_call_t *call, int pos,
80 const arch_register_t *reg,
81 be_abi_context_t context);
84 * Record the that ABI transmits return value pos in the given register.
86 * @param call the abi call object
87 * @param pos the return value position
88 * @param reg the register used
90 void be_abi_call_res_reg(be_abi_call_t *call, int pos,
91 const arch_register_t *reg,
92 be_abi_context_t context);
95 * Get the flags of a ABI call object.
96 * Note that the flags must not be the same as set by be_abi_call_set_flags(). Analysis may have
97 * altered several flags, so getting them from the call object is always a good idea.
98 * @param call The call object.
101 be_abi_call_flags_t be_abi_call_get_flags(const be_abi_call_t *call);
103 void be_abi_introduce(ir_graph *irg);