-
Notifications
You must be signed in to change notification settings - Fork 0
/
Backends.html
112 lines (112 loc) · 5.17 KB
/
Backends.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Firm - Backends</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link rel="stylesheet" type="text/css" href="pygments.css"/>
<link rel="icon" type="image/png" href="logo-simple.png"/>
</head>
<body>
<div class="layout-header">
<a href="index.html"><img src="logo.png" alt="Firm Logo" /></a>
</div>
<div class="layout-content-wrapper">
<div class="layout-content">
<div class="layout-sidebar">
<ul>
<li><a href="index.html">About</a></li>
<li><a href="Features">Features</a></li>
<li><a href="Download">Download</a></li>
<li><a href="Documentation">Documentation</a></li>
<li><a href="Projects">Projects</a></li>
<li><a href="Development">Development</a></li>
<li><a href="Contact">Contact</a></li>
</ul>
<ul class="external">
<li><a href="http://pp.info.uni-karlsruhe.de/projects/firm_publications.php">Publications</a></li>
</ul>
</div>
<div class="layout-document">
<h1>Backends</h1>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>I want a backend X, how hard would it be to create one for lib<span class="algo"><span class="algo">Firm</span></span>?</p></div>
<div class="paragraph"><p>In our experience starting with a new backend is quite easy.
We provide the TEMPLATE backend as a starting point and the sparc and arm backends should be easy enough to understand.
How complex the backend becomes in the end heavily depends on how irregular the architecture is, how complicated are the address modi, do the address modi of different instructions behave differently, how complicated are the calling conventions, so far each architecture had its own set of features which make writing a backend a little challenge, these problems are there for every compiler, you just have to deal with them with custom code.
Some examples of what We have seen before:</p></div>
<div class="ulist"><ul>
<li>
<p>
On sparc you always have to leave 92 bytes of stack space reserved between the stack pointer and the stuff you actually put on the stack.
</p>
</li>
<li>
<p>
Sparc/Arm calling conventions pass floating point values in integere registers by default
</p>
</li>
<li>
<p>
x86 fpu code uses a stack and not registers
</p>
</li>
<li>
<p>
sparc needs custom logic to fill in delay slots which are somewhat tricky in terms of data dependencies
</p>
</li>
<li>
<p>
arm immediates are quite limited and require strange hacks if your spill area or function exceeds the immediate limit (about 1024)
</p>
</li>
</ul></div>
<div class="paragraph"><p>Anyway apart from such unforseen problems writing a backend is quite easy:</p></div>
<div class="ulist"><ul>
<li>
<p>
Create a specification of architecture specific firm nodes.
Usually 1 node per target machine instruction.
Specify the register requirements.
</p>
</li>
<li>
<p>
Create a code selection pass:
This pass matches patterns in the firm graph and replaces them with architecture specific nodes.
</p>
</li>
<li>
<p>
Create some callbacks to allow spill, reload creation, handling of calling conventions
</p>
</li>
<li>
<p>
Register allocation and spillslot management can be left to the generic backend infrastructure
</p>
</li>
<li>
<p>
Create emitter code which emits assembly based on the machine specific nodes
</p>
</li>
</ul></div>
<div class="paragraph"><p>We’d be happy to assist you and provide you with more details.</p></div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<div class="layout-footer">
<span><a href="https://lists.ira.uni-karlsruhe.de/mailman/listinfo/firm">Mailing list</a>: <a href="mailto:firm@ipd.info.uni-karlsruhe.de">firm@ipd.info.uni-karlsruhe.de</a></span>
| <span>IRC: #firm on <a href="http://webchat.freenode.net/?channels=firm">Freenode</a></span>
| <span><a href="http://pp.info.uni-karlsruhe.de/~firm/bugs">Bugtracker</a></span>
</div>
</body>
</html>