add some doxygen docu.
[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_gp_regs[REG_R4],
35         &arm_gp_regs[REG_R5],
36         &arm_gp_regs[REG_R6],
37         &arm_gp_regs[REG_R7],
38         &arm_gp_regs[REG_R8],
39         &arm_gp_regs[REG_R9],
40         &arm_gp_regs[REG_R10],
41         &arm_gp_regs[REG_R11],
42         &arm_gp_regs[REG_LR],
43 };
44
45 static const arch_register_t *const caller_saves[] = {
46         &arm_gp_regs[REG_R0],
47         &arm_gp_regs[REG_R1],
48         &arm_gp_regs[REG_R2],
49         &arm_gp_regs[REG_R3],
50         &arm_gp_regs[REG_LR]
51 };
52
53 static const arch_register_t* const param_regs[] = {
54         &arm_gp_regs[REG_R0],
55         &arm_gp_regs[REG_R1],
56         &arm_gp_regs[REG_R2],
57         &arm_gp_regs[REG_R3]
58 };
59
60 static const arch_register_t* const result_regs[] = {
61         &arm_gp_regs[REG_R0],
62         &arm_gp_regs[REG_R1],
63         &arm_gp_regs[REG_R2],
64         &arm_gp_regs[REG_R3]
65 };
66
67 /** information about a single parameter or result */
68 typedef struct reg_or_stackslot_t
69 {
70         const arch_register_t *reg0;   /**< if != NULL, the first register used for this parameter. */
71         const arch_register_t *reg1;   /**< if != NULL, the second register used. */
72         ir_type               *type;   /**< indicates that an entity of the specific
73                                                                             type is needed */
74         int                    offset; /**< if transmitted via stack, the offset for this parameter. */
75         ir_entity             *entity; /**< entity in frame type */
76 } reg_or_stackslot_t;
77
78 /** The calling convention info for one call site. */
79 typedef struct calling_convention_t
80 {
81         reg_or_stackslot_t *parameters;        /**< parameter info. */
82         int                 param_stack_size;  /**< needed stack size for parameters */
83         reg_or_stackslot_t *results;           /**< result info. */
84 } calling_convention_t;
85
86 /**
87  * determine how function parameters and return values are passed.
88  * Decides what goes to register or to stack and what stack offsets/
89  * datatypes are used.
90  */
91 calling_convention_t *decide_calling_convention(ir_type *function_type);
92
93 /**
94  * free memory used by a calling_convention_t
95  */
96 void free_calling_convention(calling_convention_t *cconv);
97
98 #endif