entrypoints.rs 12.4 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
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
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
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)
    };
57
    
qinsoon's avatar
qinsoon committed
58
    // impl: runtime_asm_ARCH_OS.s
qinsoon's avatar
qinsoon committed
59
    // decl: thread.rs
60
61
62
63
    pub static ref SWAP_BACK_TO_NATIVE_STACK : RuntimeEntrypoint = RuntimeEntrypoint {
        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, String::from("muentry_swap_back_to_native_stack")),
67
68
        jit: RwLock::new(None),
    };
69
70
71
72
73
74
75
76
77
78
79

    // 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)
    };
80
    
qinsoon's avatar
qinsoon committed
81
    // impl/decl: gc/lib.rs
82
83
84
    pub static ref ALLOC_SLOW : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
85
            ret_tys: vec![ADDRESS_TYPE.clone()],
qinsoon's avatar
qinsoon committed
86
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
87
        }),
qinsoon's avatar
qinsoon committed
88
89
90
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_slow")),
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
91
92
93
94
95
96
97
98
99
100
101

    // 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)
    };
102
103
104
105
106
107
108
109
110
111
112

    // 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
113
114
115
116
117
118
119
120
121
122
123

    // 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![],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_init_hybrid")),
        jit: RwLock::new(None)
    };
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

    // 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
146
147
148
149
150
151
152
153
154
    
    // impl/decl: exception.rs
    pub static ref THROW_EXCEPTION : 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_throw_exception")),
155
156
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
157
158

    // impl/decl: math.rs
159
    pub static ref FREM32 : RuntimeEntrypoint = RuntimeEntrypoint {
qinsoon's avatar
qinsoon committed
160
161
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
162
163
            ret_tys: vec![FLOAT_TYPE.clone()],
            arg_tys: vec![FLOAT_TYPE.clone(), FLOAT_TYPE.clone()]
qinsoon's avatar
qinsoon committed
164
        }),
165
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem32")),
166
167
168
        jit: RwLock::new(None)
    };

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

180
181
182
    pub static ref UDIV_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
183
184
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
185
186
187
188
189
190
191
192
        }),
        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()),
193
194
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
195
196
197
198
199
200
201
202
        }),
        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()),
203
204
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
205
206
207
208
209
210
211
212
        }),
        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()),
213
214
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
215
216
217
218
219
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_srem_i128")),
        jit: RwLock::new(None)
    };

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
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
    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)
    };

299
300
301
302
303
304
305
306
307
308
    // 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)
    };
309
310
311
312
313
314
315
316
317
318
319
320

    // 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)
    };

321
}