entrypoints.rs 13.3 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
qinsoon's avatar
qinsoon committed
2
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3
4
5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
qinsoon's avatar
qinsoon committed
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
qinsoon's avatar
qinsoon committed
8
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9
10
11
12
13
14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

15
16
17
18
19
use runtime::ValueLocation;

use ast::ir;
use ast::ir::*;
use ast::ptr::*;
qinsoon's avatar
qinsoon committed
20
use ast::types::*;
21
22
23
24
25
26
27
use compiler::backend::RegGroup;

use std::sync::RwLock;

pub type EntryFuncSig = MuFuncSig;

pub struct RuntimeEntrypoint {
28
29
    pub sig: P<MuFuncSig>,
    pub aot: ValueLocation,
30
    pub jit: RwLock<Option<ValueLocation>>
31
32
33
}

lazy_static! {
qinsoon's avatar
qinsoon committed
34
35
    // impl: runtime_x64_macos.c
    // decl: thread.rs
36
37
38
    pub static ref GET_THREAD_LOCAL : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
39
            ret_tys: vec![ADDRESS_TYPE.clone()],
40
41
            arg_tys: vec![]
        }),
qinsoon's avatar
qinsoon committed
42
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_get_thread_local")),
43
44
        jit: RwLock::new(None),
    };
45
46
47
48
49
50
51
52
53
54
55
56

    // impl: runtime_x64_sysv.c
    // decl: thread.rs
    pub static ref SET_RETVAL : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![UINT32_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_set_retval")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
57

qinsoon's avatar
qinsoon committed
58
    // impl: runtime_asm_ARCH_OS.s
qinsoon's avatar
qinsoon committed
59
    // decl: thread.rs
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
60
    pub static ref THREAD_EXIT : RuntimeEntrypoint = RuntimeEntrypoint {
61
62
63
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
64
            arg_tys: vec![ADDRESS_TYPE.clone()]
65
        }),
qinsoon's avatar
qinsoon committed
66
        aot: ValueLocation::Relocatable(RegGroup::GPR,
67
68
69
                                        String::from("muentry_thread_exit")),
        jit: RwLock::new(None),
    };
70

71
    // impl/decl: thread.rs
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
72
    pub static ref NEW_STACK: RuntimeEntrypoint = RuntimeEntrypoint {
73
74
75
76
77
78
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![STACKREF_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_new_stack")),
79
80
        jit: RwLock::new(None),
    };
81

Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
82
83
84
85
86
87
88
89
90
91
92
    // impl/decl: thread.rs
    pub static ref KILL_STACK: RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![STACKREF_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_kill_stack")),
        jit: RwLock::new(None),
    };

93
94
95
96
97
98
99
100
101
102
    // impl/decl: gc/lib.rs
    pub static ref ALLOC_FAST : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_fast")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
103

qinsoon's avatar
qinsoon committed
104
    // impl/decl: gc/lib.rs
105
106
107
    pub static ref ALLOC_SLOW : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
108
            ret_tys: vec![ADDRESS_TYPE.clone()],
qinsoon's avatar
qinsoon committed
109
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
110
        }),
qinsoon's avatar
qinsoon committed
111
112
113
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_slow")),
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
114
115
116
117
118
119
120
121
122
123
124

    // impl/decl: gc/lib.rs
    pub static ref ALLOC_LARGE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_large")),
        jit: RwLock::new(None)
    };
125
126
127
128
129
130
131
132
133
134
135

    // impl/decl: gc/lib.rs
    pub static ref INIT_OBJ : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_init_object")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
136
137
138
139
140
141

    // impl/decl: gc/lib.rs
    pub static ref INIT_HYBRID : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
142
143
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone(),
                          UINT64_TYPE.clone(), UINT64_TYPE.clone()]
qinsoon's avatar
qinsoon committed
144
145
146
147
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_init_hybrid")),
        jit: RwLock::new(None)
    };
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

    // impl/decl: gc/lib.rs
    pub static ref PIN_OBJECT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_pin_object")),
        jit: RwLock::new(None)
    };

    // impl/decl: gc/lib.rs
    pub static ref UNPIN_OBJECT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_unpin_object")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
170

qinsoon's avatar
qinsoon committed
171
172
173
174
175
    // impl/decl: exception.rs
    pub static ref THROW_EXCEPTION : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
176
            arg_tys: vec![ADDRESS_TYPE.clone()]
qinsoon's avatar
qinsoon committed
177
178
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_throw_exception")),
179
180
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
181
182

    // impl/decl: math.rs
183
    pub static ref FREM32 : RuntimeEntrypoint = RuntimeEntrypoint {
qinsoon's avatar
qinsoon committed
184
185
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
186
187
            ret_tys: vec![FLOAT_TYPE.clone()],
            arg_tys: vec![FLOAT_TYPE.clone(), FLOAT_TYPE.clone()]
qinsoon's avatar
qinsoon committed
188
        }),
189
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem32")),
190
191
192
        jit: RwLock::new(None)
    };

193
194
    // impl/decl: math.rs
    pub static ref FREM64 : RuntimeEntrypoint = RuntimeEntrypoint {
195
196
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
197
198
            ret_tys: vec![DOUBLE_TYPE.clone()],
            arg_tys: vec![DOUBLE_TYPE.clone(), DOUBLE_TYPE.clone()]
199
        }),
200
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem64")),
qinsoon's avatar
qinsoon committed
201
202
        jit: RwLock::new(None)
    };
203

204
205
206
    pub static ref UDIV_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
207
208
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
209
210
211
212
213
214
215
216
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_udiv_u128")),
        jit: RwLock::new(None)
    };

    pub static ref SDIV_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
217
218
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
219
220
221
222
223
224
225
226
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sdiv_i128")),
        jit: RwLock::new(None)
    };

    pub static ref UREM_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
227
228
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
229
230
231
232
233
234
235
236
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_urem_u128")),
        jit: RwLock::new(None)
    };

    pub static ref SREM_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
237
238
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
239
240
241
242
243
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_srem_i128")),
        jit: RwLock::new(None)
    };

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    pub static ref FPTOUI_DOUBLE_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![DOUBLE_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptoui_double_u128")),
        jit: RwLock::new(None)
    };

    pub static ref FPTOSI_DOUBLE_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![DOUBLE_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptosi_double_i128")),
        jit: RwLock::new(None)
    };
    pub static ref UITOFP_U128_DOUBLE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![DOUBLE_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_uitofp_u128_double")),
        jit: RwLock::new(None)
    };

    pub static ref SITOFP_I128_DOUBLE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![DOUBLE_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sitofp_i128_double")),
        jit: RwLock::new(None)
    };

    // Conversion to/from int<128> from/to float
        pub static ref FPTOUI_FLOAT_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![FLOAT_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptoui_float_u128")),
        jit: RwLock::new(None)
    };

    pub static ref FPTOSI_FLOAT_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![FLOAT_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptosi_float_i128")),
        jit: RwLock::new(None)
    };
    pub static ref UITOFP_U128_FLOAT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![FLOAT_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_uitofp_u128_float")),
        jit: RwLock::new(None)
    };

    pub static ref SITOFP_I128_FLOAT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![FLOAT_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sitofp_i128_float")),
        jit: RwLock::new(None)
    };

323
324
325
326
327
328
329
330
331
332
    // impl/decl: mod.rs
    pub static ref PRINT_HEX : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_print_hex")),
        jit: RwLock::new(None)
    };
333
334
335
336
337
338
339
340
341
342
343

    // impl/decl: mod.rs
    pub static ref MEM_ZERO : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![IREF_VOID_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_mem_zero")),
        jit: RwLock::new(None)
    };
344
}