custom stack bias code for sparc
[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 "bearch_sparc_t.h"
31 #include "../be_types.h"
32 #include "../benode.h"
33 #include "gen_sparc_regalloc_if.h"
34
35 /** information about a single parameter or result */
36 typedef struct reg_or_stackslot_t
37 {
38         const arch_register_req_t *req0; /**< if != NULL, register requirements
39                                               for this parameter (or the first
40                                               part of it). */
41         const arch_register_req_t *req1; /**< if != NULL, register requirements
42                                               for the 2nd part of the parameter */
43         const arch_register_t *reg0;
44         const arch_register_t *reg1;
45         size_t                 reg_offset;
46         ir_type               *type;   /**< indicates that an entity of the specific
47                                                                             type is needed */
48         unsigned               offset; /**< if transmitted via stack, the offset for
49                                             this parameter. */
50         ir_entity             *entity; /**< entity in frame type */
51 } reg_or_stackslot_t;
52
53 /** The calling convention info for one call site. */
54 struct calling_convention_t
55 {
56         bool                omit_fp;          /**< do not use frame pointer (and no
57                                                    save/restore) */
58         reg_or_stackslot_t *parameters;       /**< parameter info. */
59         unsigned            param_stack_size; /**< stack size for parameters */
60         unsigned            n_param_regs;     /**< number of values passed in a
61                                                    register */
62         reg_or_stackslot_t *results;          /**< result info. */
63         unsigned            n_reg_results;
64         unsigned           *caller_saves;     /**< bitset of caller save registers */
65 };
66
67 /**
68  * Determine how function parameters and return values are passed.
69  * Decides what goes to register or to stack and what stack offsets/
70  * datatypes are used.
71  *
72  * @param function_type  the type of the caller/callee function
73  * @param caller         true for convention for the caller, false for callee
74  */
75 calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
76                                                       ir_graph *irg);
77
78 /**
79  * free memory used by a calling_convention_t
80  */
81 void sparc_free_calling_convention(calling_convention_t *cconv);
82
83 void sparc_cconv_init(void);
84
85 #endif