Skip to content

Commit 62a1592

Browse files
committed
---
yaml --- r: 720 b: refs/heads/master c: d53209c h: refs/heads/master v: v3
1 parent 00181f8 commit 62a1592

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b69a0c137c344ae722abc176f9d7ea27f7bddd3e
2+
refs/heads/master: d53209c9277be20991ed2e6b80fbacb1bf5be424

trunk/src/comp/middle/trans.rs

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ fn T_task() -> TypeRef {
8989
));
9090
}
9191

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+
92110
fn T_double() -> TypeRef {
93111
ret llvm.LLVMDoubleType();
94112
}
@@ -263,6 +281,49 @@ fn trans_mod(@trans_ctxt cx, &ast._mod m) {
263281
}
264282
}
265283

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+
266327
fn trans_crate(session.session sess, ast.crate crate) {
267328
auto llmod =
268329
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
@@ -281,7 +342,7 @@ fn trans_crate(session.session sess, ast.crate crate) {
281342
llmod = llmod,
282343
upcalls = new_str_hash[ValueRef](),
283344
glues = glues,
284-
path = "");
345+
path = "_rust");
285346

286347
trans_mod(cx, crate.module);
287348

0 commit comments

Comments
 (0)