summaryrefslogtreecommitdiffhomepage
path: root/ir/be/sparc/sparc_cconv.h
blob: 6e839e2584774766fd20b6361d4663990df4780b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * This file is part of libFirm.
 * Copyright (C) 2012 University of Karlsruhe.
 */

/**
 * @file
 * @brief   support functions for calling conventions
 * @author  Matthias Braun
 */
#ifndef FIRM_BE_SPARC_SPARC_CCONV_H
#define FIRM_BE_SPARC_SPARC_CCONV_H

#include "firm_types.h"
#include "be_types.h"
#include "benode.h"
#include "gen_sparc_regalloc_if.h"
#include "sparc_bearch_t.h"

/** information about a single parameter or result */
typedef struct reg_or_stackslot_t
{
	const arch_register_req_t *req0; /**< if != NULL, register requirements
	                                      for this parameter (or the first
	                                      part of it). */
	const arch_register_req_t *req1; /**< if != NULL, register requirements
	                                      for the 2nd part of the parameter */
	const arch_register_t *reg0;
	const arch_register_t *reg1;
	/** indicates that an entity of the specific type is needed */
	ir_type               *type;
	/** If transmitted via stack, the offset for this parameter.
	 * The offset is relative to the end of the space that contains all
	 * parameters (which is relative to SP + SPARC_MIN_STACK_SIZE immediately
	 * before the call). */
	int                    offset;
	bool                   already_stored;
	ir_entity             *entity; /**< entity in frame type */
} reg_or_stackslot_t;

/** The calling convention info for one call site. */
struct calling_convention_t
{
	bool                omit_fp;          /**< do not use frame pointer (and no
	                                           save/restore) */
	unsigned            n_parameters;     /**< number of parameters */
	reg_or_stackslot_t *parameters;       /**< parameter info. */
	unsigned            param_stack_size; /**< stack size for parameters */
	unsigned            n_param_regs;     /**< number of values passed in a
	                                           register */
	reg_or_stackslot_t *results;          /**< result info. */
	unsigned            n_reg_results;
	unsigned           *caller_saves;     /**< bitset of caller save registers */
	ir_entity          *va_start_addr;
};

/**
 * Determine how function parameters and return values are passed.
 * Decides what goes to register or to stack and what stack offsets/
 * datatypes are used.
 *
 * @param function_type  the type of the caller/callee function
 * @param caller         true for convention for the caller, false for callee
 */
calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
                                                      ir_graph *irg);

/**
 * free memory used by a calling_convention_t
 */
void sparc_free_calling_convention(calling_convention_t *cconv);

void sparc_cconv_init(void);

#endif