@@ -89,6 +89,24 @@ fn T_task() -> TypeRef {
89
89
) ) ;
90
90
}
91
91
92
+ fn T_crate ( ) -> TypeRef {
93
+ ret T_struct ( vec ( T_int ( ) , // ptrdiff_t image_base_off
94
+ T_int ( ) , // uintptr_t self_addr
95
+ T_int ( ) , // ptrdiff_t debug_abbrev_off
96
+ T_int ( ) , // size_t debug_abbrev_sz
97
+ T_int ( ) , // ptrdiff_t debug_info_off
98
+ T_int ( ) , // size_t debug_info_sz
99
+ T_int ( ) , // size_t activate_glue_off
100
+ T_int ( ) , // size_t yield_glue_off
101
+ T_int ( ) , // size_t unwind_glue_off
102
+ T_int ( ) , // size_t gc_glue_off
103
+ T_int ( ) , // size_t main_exit_task_glue_off
104
+ T_int ( ) , // int n_rust_syms
105
+ T_int ( ) , // int n_c_syms
106
+ T_int ( ) //int n_libs
107
+ ) ) ;
108
+ }
109
+
92
110
fn T_double ( ) -> TypeRef {
93
111
ret llvm. LLVMDoubleType ( ) ;
94
112
}
@@ -263,6 +281,49 @@ fn trans_mod(@trans_ctxt cx, &ast._mod m) {
263
281
}
264
282
}
265
283
284
+ fn crate_constant( @trans_ctxt cx) -> ValueRef {
285
+
286
+ let ValueRef crate_ptr =
287
+ llvm. LLVMAddGlobal ( cx. llmod, T_ptr( T_crate ( ) ) ,
288
+ _str. buf( "rust_crate" ) ) ;
289
+
290
+ fn p2i( ValueRef v) -> ValueRef {
291
+ ret llvm. LLVMConstPtrToInt ( v, T_int( ) ) ;
292
+ }
293
+
294
+ let ValueRef crate_addr = p2i( crate_ptr) ;
295
+
296
+ let ValueRef activate_glue_off =
297
+ llvm. LLVMConstSub ( p2i( cx. glues. activate_glue) , crate_addr) ;
298
+
299
+ let ValueRef yield_glue_off =
300
+ llvm. LLVMConstSub ( p2i( cx. glues. yield_glue) , crate_addr) ;
301
+
302
+ // FIXME: we aren't generating the exit-task glue yet.
303
+ // llvm.LLVMConstSub(p2i(cx.glues.exit_task_glue), crate_addr);
304
+ let ValueRef exit_task_glue_off = C_null ( T_int ( ) ) ;
305
+
306
+ let ValueRef crate_val =
307
+ C_struct ( vec( C_null ( T_int ( ) ) , // ptrdiff_t image_base_off
308
+ crate_ptr, // uintptr_t self_addr
309
+ C_null ( T_int ( ) ) , // ptrdiff_t debug_abbrev_off
310
+ C_null ( T_int ( ) ) , // size_t debug_abbrev_sz
311
+ C_null ( T_int ( ) ) , // ptrdiff_t debug_info_off
312
+ C_null ( T_int ( ) ) , // size_t debug_info_sz
313
+ activate_glue_off, // size_t activate_glue_off
314
+ yield_glue_off, // size_t yield_glue_off
315
+ C_null ( T_int ( ) ) , // size_t unwind_glue_off
316
+ C_null ( T_int ( ) ) , // size_t gc_glue_off
317
+ exit_task_glue_off, // size_t main_exit_task_glue_off
318
+ C_null ( T_int ( ) ) , // int n_rust_syms
319
+ C_null ( T_int ( ) ) , // int n_c_syms
320
+ C_null ( T_int ( ) ) // int n_libs
321
+ ) ) ;
322
+
323
+ llvm. LLVMSetInitializer ( crate_ptr, crate_val) ;
324
+ ret crate_ptr;
325
+ }
326
+
266
327
fn trans_crate( session. session sess, ast. crate crate ) {
267
328
auto llmod =
268
329
llvm. LLVMModuleCreateWithNameInContext ( _str. buf( "rust_out") ,
@@ -281,7 +342,7 @@ fn trans_crate(session.session sess, ast.crate crate) {
281
342
llmod = llmod,
282
343
upcalls = new_str_hash[ ValueRef ] ( ) ,
283
344
glues = glues,
284
- path = "" ) ;
345
+ path = "_rust ") ;
285
346
286
347
trans_mod( cx, crate . module) ;
287
348
0 commit comments