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
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::Context;
use cretonne_codegen::{binemit, ir};
use std::marker;
use DataContext;
use Linkage;
use ModuleNamespace;
use ModuleResult;
pub trait Backend
where
Self: marker::Sized,
{
type Builder;
type CompiledFunction;
type CompiledData;
type FinalizedFunction;
type FinalizedData;
type Product;
fn new(Self::Builder) -> Self;
fn isa(&self) -> &TargetIsa;
fn declare_function(&mut self, name: &str, linkage: Linkage);
fn declare_data(&mut self, name: &str, linkage: Linkage, writable: bool);
fn define_function(
&mut self,
name: &str,
ctx: &Context,
namespace: &ModuleNamespace<Self>,
code_size: u32,
) -> ModuleResult<Self::CompiledFunction>;
fn define_data(
&mut self,
name: &str,
data_ctx: &DataContext,
namespace: &ModuleNamespace<Self>,
) -> ModuleResult<Self::CompiledData>;
fn write_data_funcaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: ir::FuncRef,
);
fn write_data_dataaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: ir::GlobalValue,
addend: binemit::Addend,
);
fn finalize_function(
&mut self,
func: &Self::CompiledFunction,
namespace: &ModuleNamespace<Self>,
) -> Self::FinalizedFunction;
fn finalize_data(
&mut self,
data: &Self::CompiledData,
namespace: &ModuleNamespace<Self>,
) -> Self::FinalizedData;
fn finish(self) -> Self::Product;
}