be.h 3.07 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Christian Würdig's avatar
Christian Würdig committed
20
21
22
23
24
25
26
27
/**
 * @file
 * @brief       Generic backend types and interfaces.
 * @author      Sebastian Hack
 * @version     $Id$
 */
#ifndef FIRM_BE_MAIN_H
#define FIRM_BE_MAIN_H
28

Christian Würdig's avatar
Christian Würdig committed
29
#include <stdio.h>
30
31
32
#include "irarch.h"
#include "archop.h"
#include "lower_dw.h"
Christian Würdig's avatar
Christian Würdig committed
33
#include "dbginfo.h"
34
#include "iroptimize.h"
Christian Würdig's avatar
Christian Würdig committed
35

36
37
#include <libcore/lc_timing.h>

Christian Würdig's avatar
Christian Würdig committed
38
#define LC_STOP_AND_RESET_TIMER(timer) do { lc_timer_stop(timer); lc_timer_reset(timer); } while(0)
39

40
41
42
/** For inline assembler: get a register from a name and encode it into a backend specific value. */
typedef unsigned (get_register_fkt)(const char *reg);

43
44
45
46
47
/**
 * This structure contains parameters that should be
 * propagated to the libFirm parameter set.
 */
typedef struct backend_params {
48
49
50
51
52
	/** if set, the backend cannot handle DWORD access */
	unsigned do_dw_lowering:1;
	/** if set, the backend supports inline assembly */
	unsigned support_inline_asm:1;

53
54
55
56
57
58
59
60
	/** Additional opcodes settings. */
	const arch_ops_info *arch_op_settings;

	/** Settings for architecture dependent optimizations */
	const arch_dep_params_t *dep_param;

	/** the architecture specific intrinsic function creator */
	create_intrinsic_fkt *arch_create_intrinsic_fkt;
61
62
63
64

	/** the context parameter for the create intrinsic function */
	void *create_intrinsic_ctx;

Christian Würdig's avatar
Christian Würdig committed
65
	/** backend settings for if-conversion */
Christian Würdig's avatar
Christian Würdig committed
66
	const opt_if_conv_info_t *if_conv_info;
67
68
69

	/** get the backend specific register encoding for a register name */
	get_register_fkt *get_register_from_name;
70
71
} backend_params;

72
73
74
75
76
77
78
79
80
81
82
83
/**
 * Register the Firm backend command line options.
 */
void be_opt_register(void);

/**
 * Parse one backend argument.
 */
int be_parse_arg(const char *arg);

/**
 * Initialize the Firm backend. Must be run BEFORE init_firm()!
84
85
86
 *
 * @return libFirm configuration parameters for the selected
 *         backend
87
 */
88
const backend_params *be_init(void);
Michael Beck's avatar
Michael Beck committed
89
90
91
92

/**
 * Main interface to the frontend.
 */
Michael Beck's avatar
Michael Beck committed
93
void be_main(FILE *file_handle, const char *cup_name);
94

Michael Beck's avatar
Michael Beck committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** The type of the debug info retriever function. */
typedef const char *(*retrieve_dbg_func)(const dbg_info *dbg, unsigned *line);

/**
 * Sets a debug info retriever.
 *
 * @param func   the debug retriever function.
 */
void be_set_debug_retrieve(retrieve_dbg_func func);

/**
 * Retrieve the debug info.
 */
const char *be_retrieve_dbg_info(const dbg_info *dbg, unsigned *line);

110
111
typedef struct be_main_env_t be_main_env_t;
typedef struct be_options_t  be_options_t;
Sebastian Hack's avatar
Sebastian Hack committed
112

Christian Würdig's avatar
Christian Würdig committed
113
#endif /* FIRM_BE_MAIN_H */