2 * Copyright (C) 1995-2010 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 support functions for calling conventions
23 * @author Matthias Braun
26 #ifndef FIRM_BE_SPARC_SPARC_CCONV_H
27 #define FIRM_BE_SPARC_SPARC_CCONV_H
29 #include "firm_types.h"
30 #include "../be_types.h"
31 #include "gen_sparc_regalloc_if.h"
33 static const arch_register_t *const caller_saves[] = {
34 &sparc_registers[REG_G1],
35 &sparc_registers[REG_G2],
36 &sparc_registers[REG_G3],
37 &sparc_registers[REG_G4],
38 &sparc_registers[REG_O0],
39 &sparc_registers[REG_O1],
40 &sparc_registers[REG_O2],
41 &sparc_registers[REG_O3],
42 &sparc_registers[REG_O4],
43 &sparc_registers[REG_O5],
45 &sparc_registers[REG_F0],
46 &sparc_registers[REG_F1],
47 &sparc_registers[REG_F2],
48 &sparc_registers[REG_F3],
49 &sparc_registers[REG_F4],
50 &sparc_registers[REG_F5],
51 &sparc_registers[REG_F6],
52 &sparc_registers[REG_F7],
53 &sparc_registers[REG_F8],
54 &sparc_registers[REG_F9],
55 &sparc_registers[REG_F10],
56 &sparc_registers[REG_F11],
57 &sparc_registers[REG_F12],
58 &sparc_registers[REG_F13],
59 &sparc_registers[REG_F14],
60 &sparc_registers[REG_F15],
61 &sparc_registers[REG_F16],
62 &sparc_registers[REG_F17],
63 &sparc_registers[REG_F18],
64 &sparc_registers[REG_F19],
65 &sparc_registers[REG_F20],
66 &sparc_registers[REG_F21],
67 &sparc_registers[REG_F22],
68 &sparc_registers[REG_F23],
69 &sparc_registers[REG_F24],
70 &sparc_registers[REG_F25],
71 &sparc_registers[REG_F26],
72 &sparc_registers[REG_F27],
73 &sparc_registers[REG_F28],
74 &sparc_registers[REG_F29],
75 &sparc_registers[REG_F30],
76 &sparc_registers[REG_F31],
79 static const arch_register_t* const param_regs[] = {
80 &sparc_registers[REG_I0],
81 &sparc_registers[REG_I1],
82 &sparc_registers[REG_I2],
83 &sparc_registers[REG_I3],
84 &sparc_registers[REG_I4],
85 &sparc_registers[REG_I5],
88 static const arch_register_t* const float_result_regs[] = {
89 &sparc_registers[REG_F0],
90 &sparc_registers[REG_F1],
91 &sparc_registers[REG_F2],
92 &sparc_registers[REG_F3],
95 /** information about a single parameter or result */
96 typedef struct reg_or_stackslot_t
98 const arch_register_t *reg0; /**< if != NULL, the first register used for
100 const arch_register_t *reg1; /**< if != NULL, the second register used. */
101 ir_type *type; /**< indicates that an entity of the specific
103 int offset; /**< if transmitted via stack, the offset for
105 ir_entity *entity; /**< entity in frame type */
106 } reg_or_stackslot_t;
108 /** The calling convention info for one call site. */
109 typedef struct calling_convention_t
111 reg_or_stackslot_t *parameters; /**< parameter info. */
112 int param_stack_size; /**< stack size for parameters */
113 reg_or_stackslot_t *results; /**< result info. */
114 } calling_convention_t;
117 * Determine how function parameters and return values are passed.
118 * Decides what goes to register or to stack and what stack offsets/
119 * datatypes are used.
121 * @param function_type the type of the caller/callee function
122 * @param caller true for convention for the caller, false for callee
124 calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
128 * free memory used by a calling_convention_t
130 void sparc_free_calling_convention(calling_convention_t *cconv);