b952b527f95c8e38937fec5bd7a596711d373b3e
[libfirm] / ir / be / arm / arm_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_ARM_ARM_CCONV_H
27 #define FIRM_BE_ARM_ARM_CCONV_H
28
29 #include "firm_types.h"
30 #include "../be_types.h"
31 #include "gen_arm_regalloc_if.h"
32
33 static const arch_register_t *const callee_saves[] = {
34         &arm_registers[REG_R4],
35         &arm_registers[REG_R5],
36         &arm_registers[REG_R6],
37         &arm_registers[REG_R7],
38         &arm_registers[REG_R8],
39         &arm_registers[REG_R9],
40         &arm_registers[REG_R10],
41         &arm_registers[REG_R11],
42         &arm_registers[REG_LR],
43 };
44
45 static const arch_register_t *const caller_saves[] = {
46         &arm_registers[REG_R0],
47         &arm_registers[REG_R1],
48         &arm_registers[REG_R2],
49         &arm_registers[REG_R3],
50         &arm_registers[REG_LR],
51
52         &arm_registers[REG_F0],
53         &arm_registers[REG_F1],
54         &arm_registers[REG_F2],
55         &arm_registers[REG_F3],
56         &arm_registers[REG_F4],
57         &arm_registers[REG_F5],
58         &arm_registers[REG_F6],
59         &arm_registers[REG_F7],
60 };
61
62 static const arch_register_t* const param_regs[] = {
63         &arm_registers[REG_R0],
64         &arm_registers[REG_R1],
65         &arm_registers[REG_R2],
66         &arm_registers[REG_R3]
67 };
68
69 static const arch_register_t* const result_regs[] = {
70         &arm_registers[REG_R0],
71         &arm_registers[REG_R1],
72         &arm_registers[REG_R2],
73         &arm_registers[REG_R3]
74 };
75
76 static const arch_register_t* const float_result_regs[] = {
77         &arm_registers[REG_F0],
78         &arm_registers[REG_F1]
79 };
80
81 /** information about a single parameter or result */
82 typedef struct reg_or_stackslot_t
83 {
84         const arch_register_t *reg0;   /**< if != NULL, the first register used for this parameter. */
85         const arch_register_t *reg1;   /**< if != NULL, the second register used. */
86         ir_type               *type;   /**< indicates that an entity of the specific
87                                                                             type is needed */
88         int                    offset; /**< if transmitted via stack, the offset for this parameter. */
89         ir_entity             *entity; /**< entity in frame type */
90 } reg_or_stackslot_t;
91
92 /** The calling convention info for one call site. */
93 typedef struct calling_convention_t
94 {
95         reg_or_stackslot_t *parameters;        /**< parameter info. */
96         int                 param_stack_size;  /**< needed stack size for parameters */
97         reg_or_stackslot_t *results;           /**< result info. */
98 } calling_convention_t;
99
100 /**
101  * determine how function parameters and return values are passed.
102  * Decides what goes to register or to stack and what stack offsets/
103  * datatypes are used.
104  */
105 calling_convention_t *arm_decide_calling_convention(ir_type *function_type);
106
107 /**
108  * free memory used by a calling_convention_t
109  */
110 void arm_free_calling_convention(calling_convention_t *cconv);
111
112 #endif