C99 feature removed.
[libfirm] / ir / be / sparc / sparc_cconv.h
1 /*
2  * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   support functions for calling conventions
23  * @author  Matthias Braun
24  * @version $Id$
25  */
26 #ifndef FIRM_BE_SPARC_SPARC_CCONV_H
27 #define FIRM_BE_SPARC_SPARC_CCONV_H
28
29 #include "firm_types.h"
30 #include "../be_types.h"
31 #include "gen_sparc_regalloc_if.h"
32
33 static const arch_register_t *const caller_saves[] = {
34         &sparc_gp_regs[REG_G1],
35         &sparc_gp_regs[REG_G2],
36         &sparc_gp_regs[REG_G3],
37         &sparc_gp_regs[REG_G4],
38         &sparc_gp_regs[REG_O0],
39         &sparc_gp_regs[REG_O1],
40         &sparc_gp_regs[REG_O2],
41         &sparc_gp_regs[REG_O3],
42         &sparc_gp_regs[REG_O4],
43         &sparc_gp_regs[REG_O5],
44
45         &sparc_fp_regs[REG_F0],
46         &sparc_fp_regs[REG_F1],
47         &sparc_fp_regs[REG_F2],
48         &sparc_fp_regs[REG_F3],
49         &sparc_fp_regs[REG_F4],
50         &sparc_fp_regs[REG_F5],
51         &sparc_fp_regs[REG_F6],
52         &sparc_fp_regs[REG_F7],
53         &sparc_fp_regs[REG_F8],
54         &sparc_fp_regs[REG_F9],
55         &sparc_fp_regs[REG_F10],
56         &sparc_fp_regs[REG_F11],
57         &sparc_fp_regs[REG_F12],
58         &sparc_fp_regs[REG_F13],
59         &sparc_fp_regs[REG_F14],
60         &sparc_fp_regs[REG_F15],
61         &sparc_fp_regs[REG_F16],
62         &sparc_fp_regs[REG_F17],
63         &sparc_fp_regs[REG_F18],
64         &sparc_fp_regs[REG_F19],
65         &sparc_fp_regs[REG_F20],
66         &sparc_fp_regs[REG_F21],
67         &sparc_fp_regs[REG_F22],
68         &sparc_fp_regs[REG_F23],
69         &sparc_fp_regs[REG_F24],
70         &sparc_fp_regs[REG_F25],
71         &sparc_fp_regs[REG_F26],
72         &sparc_fp_regs[REG_F27],
73         &sparc_fp_regs[REG_F28],
74         &sparc_fp_regs[REG_F29],
75         &sparc_fp_regs[REG_F30],
76         &sparc_fp_regs[REG_F31],
77 };
78
79 static const arch_register_t* const param_regs[] = {
80         &sparc_gp_regs[REG_I0],
81         &sparc_gp_regs[REG_I1],
82         &sparc_gp_regs[REG_I2],
83         &sparc_gp_regs[REG_I3],
84         &sparc_gp_regs[REG_I4],
85         &sparc_gp_regs[REG_I5],
86 };
87
88 static const arch_register_t* const float_result_regs[] = {
89         &sparc_fp_regs[REG_F0],
90         &sparc_fp_regs[REG_F1],
91         &sparc_fp_regs[REG_F2],
92         &sparc_fp_regs[REG_F3],
93 };
94
95 /** information about a single parameter or result */
96 typedef struct reg_or_stackslot_t
97 {
98         const arch_register_t *reg0;   /**< if != NULL, the first register used for
99                                             this parameter. */
100         const arch_register_t *reg1;   /**< if != NULL, the second register used. */
101         ir_type               *type;   /**< indicates that an entity of the specific
102                                                                             type is needed */
103         int                    offset; /**< if transmitted via stack, the offset for
104                                             this parameter. */
105         ir_entity             *entity; /**< entity in frame type */
106 } reg_or_stackslot_t;
107
108 /** The calling convention info for one call site. */
109 typedef struct calling_convention_t
110 {
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;
115
116 /**
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.
120  *
121  * @param function_type  the type of the caller/callee function
122  * @param caller         true for convention for the caller, false for callee
123  */
124 calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
125                                                       bool caller);
126
127 /**
128  * free memory used by a calling_convention_t
129  */
130 void sparc_free_calling_convention(calling_convention_t *cconv);
131
132 #endif