2 * Copyright (C) 1995-2008 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 declarations for SPARC backend -- private header
23 * @author Hannes Rapp, Matthias Braun
26 #ifndef FIRM_BE_SPARC_BEARCH_SPARC_T_H
27 #define FIRM_BE_SPARC_BEARCH_SPARC_T_H
30 #include "sparc_nodes_attr.h"
33 typedef struct sparc_transform_env_t sparc_transform_env_t;
34 typedef struct sparc_isa_t sparc_isa_t;
35 typedef struct calling_convention_t calling_convention_t;
37 /** Floating point instruction set. */
38 enum sparc_fp_architectures {
39 SPARC_FPU_ARCH_NONE = 0,
40 SPARC_FPU_ARCH_FPU = 0x00000001,
41 SPARC_FPU_ARCH_SOFTFLOAT = 0x00000002,
45 arch_env_t base; /**< must be derived from arch_env_t */
47 int fpu_arch; /**< FPU architecture */
51 * this is a struct to minimize the number of parameters
52 * for transformation walker
54 struct sparc_transform_env_t {
55 dbg_info *dbg; /**< The node debug info */
56 ir_graph *irg; /**< The irg, the node should be created in */
57 ir_node *block; /**< The block, the node should belong to */
58 ir_node *irn; /**< The irn, to be transformed */
59 ir_mode *mode; /**< The mode of the irn */
62 extern const arch_irn_ops_t sparc_irn_ops;
65 * SPARC ABI requires some space which is always available at the top of
66 * the stack. It contains:
67 * 16*4 bytes space for spilling the register window
68 * 1*4 byte holding a pointer to space for aggregate returns (the space is
69 * always reserved, regardless whether we have an aggregate return
71 * 6*4 bytes Space for spilling parameters 0-5. For the cases when someone
72 * takes the address of a parameter. I guess this is also there so
73 * the implementation of va_args gets easier -> We can simply store
74 * param 0-5 in this spaces and then handle va_next by simply
75 * incrementing the stack pointer
77 #define SPARC_IMMEDIATE_MIN -4096
78 #define SPARC_IMMEDIATE_MAX 4095
79 #define SPARC_MIN_STACKSIZE 92
80 #define SPARC_AGGREGATE_RETURN_OFFSET 64
81 #define SPARC_PARAMS_SPILL_OFFSET 68
82 #define SPARC_N_PARAM_REGS 6
83 #define SPARC_STACK_ALIGNMENT 8
84 #define SPARC_REGISTER_SIZE 4
86 static inline bool sparc_is_value_imm_encodeable(int32_t value)
88 return SPARC_IMMEDIATE_MIN <= value && value <= SPARC_IMMEDIATE_MAX;
91 void sparc_finish(ir_graph *irg);
93 void sparc_introduce_prolog_epilog(ir_graph *irg);
95 void sparc_lower_64bit(void);
97 bool sparc_variadic_fixups(ir_graph *irg, calling_convention_t *cconv);
98 void sparc_create_stacklayout(ir_graph *irg, calling_convention_t *cconv);
99 void sparc_fix_stack_bias(ir_graph *irg);