@@ -40,10 +40,8 @@ import syntax::codemap::span;
40
40
import lib:: llvm:: llvm;
41
41
import lib:: llvm:: builder;
42
42
import lib:: llvm:: target_data;
43
- import lib:: llvm:: type_handle;
44
43
import lib:: llvm:: type_names;
45
44
import lib:: llvm:: mk_target_data;
46
- import lib:: llvm:: mk_type_handle;
47
45
import lib:: llvm:: mk_type_names;
48
46
import lib:: llvm:: llvm:: ModuleRef ;
49
47
import lib:: llvm:: llvm:: ValueRef ;
@@ -475,18 +473,29 @@ fn T_struct(&TypeRef[] elts) -> TypeRef {
475
473
False ) ;
476
474
}
477
475
478
- fn T_opaque ( ) -> TypeRef { ret llvm:: LLVMOpaqueType ( ) ; }
476
+ fn T_named_struct ( & str name) -> TypeRef {
477
+ auto c = llvm:: LLVMGetGlobalContext ( ) ;
478
+ ret llvm:: LLVMStructCreateNamed ( c, str:: buf ( name) ) ;
479
+ }
480
+
481
+ fn set_struct_body( TypeRef t, & TypeRef [ ] elts) {
482
+ llvm:: LLVMStructSetBody ( t, std:: ivec:: to_ptr ( elts) , std:: ivec:: len ( elts) ,
483
+ False ) ;
484
+ }
479
485
480
486
fn T_empty_struct ( ) -> TypeRef { ret T_struct ( ~[ ] ) ; }
481
487
482
488
fn T_rust_object ( ) -> TypeRef {
483
- auto e = T_ptr ( T_empty_struct ( ) ) ;
484
- ret T_struct ( ~[ e, e] ) ;
489
+ auto t = T_named_struct ( "rust_object" ) ;
490
+ auto e = T_ptr ( T_empty_struct ( ) ) ;
491
+ set_struct_body ( t, ~[ e, e] ) ;
492
+ ret t;
485
493
}
486
494
487
495
fn T_task ( ) -> TypeRef {
488
- auto t =
489
- T_struct ( ~[ T_int ( ) , // Refcount
496
+ auto t = T_named_struct ( "task" ) ;
497
+
498
+ auto elems = ~[ T_int ( ) , // Refcount
490
499
T_int ( ) , // Delegate pointer
491
500
T_int ( ) , // Stack segment pointer
492
501
T_int ( ) , // Runtime SP
@@ -495,7 +504,8 @@ fn T_task() -> TypeRef {
495
504
496
505
T_int ( ) , // Domain pointer
497
506
// Crate cache pointer
498
- T_int ( ) ] ) ;
507
+ T_int ( ) ] ;
508
+ set_struct_body ( t, elems) ;
499
509
ret t;
500
510
}
501
511
@@ -532,18 +542,17 @@ fn T_cmp_glue_fn(&crate_ctxt cx) -> TypeRef {
532
542
}
533
543
534
544
fn T_tydesc ( TypeRef taskptr_type ) -> TypeRef {
535
- auto th = mk_type_handle ( ) ;
536
- auto abs_tydesc = llvm:: LLVMResolveTypeHandle ( th. llth ) ;
537
- auto tydescpp = T_ptr ( T_ptr ( abs_tydesc) ) ;
545
+ auto tydesc = T_named_struct ( "tydesc" ) ;
546
+ auto tydescpp = T_ptr ( T_ptr ( tydesc) ) ;
538
547
auto pvoid = T_ptr ( T_i8 ( ) ) ;
539
548
auto glue_fn_ty =
540
549
T_ptr ( T_fn ( ~[ T_ptr ( T_nil ( ) ) , taskptr_type, T_ptr ( T_nil ( ) ) , tydescpp,
541
550
pvoid] , T_void ( ) ) ) ;
542
551
auto cmp_glue_fn_ty =
543
552
T_ptr ( T_fn ( ~[ T_ptr ( T_i1 ( ) ) , taskptr_type, T_ptr ( T_nil ( ) ) , tydescpp,
544
553
pvoid, pvoid, T_i8 ( ) ] , T_void ( ) ) ) ;
545
- auto tydesc =
546
- T_struct ( ~[ tydescpp, // first_param
554
+
555
+ auto elems = ~[ tydescpp, // first_param
547
556
T_int ( ) , // size
548
557
T_int ( ) , // align
549
558
glue_fn_ty, // copy_glue
@@ -553,11 +562,9 @@ fn T_tydesc(TypeRef taskptr_type) -> TypeRef {
553
562
glue_fn_ty, // mark_glue
554
563
glue_fn_ty, // obj_drop_glue
555
564
glue_fn_ty, // is_stateful
556
- cmp_glue_fn_ty] ) ; // cmp_glue
557
-
558
- llvm:: LLVMRefineType ( abs_tydesc, tydesc) ;
559
- auto t = llvm:: LLVMResolveTypeHandle ( th. llth ) ;
560
- ret t;
565
+ cmp_glue_fn_ty] ;
566
+ set_struct_body ( tydesc, elems) ;
567
+ ret tydesc;
561
568
}
562
569
563
570
fn T_array ( TypeRef t, uint n) -> TypeRef { ret llvm:: LLVMArrayType ( t, n) ; }
@@ -915,10 +922,6 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
915
922
case ( ty:: ty_type) { llty = T_ptr ( cx. tydesc_type ) ; }
916
923
}
917
924
assert ( llty as int != 0 ) ;
918
- if ( cx. sess . get_opts ( ) . save_temps ) {
919
- llvm:: LLVMAddTypeName ( cx. llmod , str:: buf ( ty_to_short_str ( cx. tcx , t) ) ,
920
- llty) ;
921
- }
922
925
cx. lltypes . insert ( t, llty) ;
923
926
ret llty;
924
927
}
@@ -1096,6 +1099,11 @@ fn C_struct(&ValueRef[] elts) -> ValueRef {
1096
1099
False ) ;
1097
1100
}
1098
1101
1102
+ fn C_named_struct ( TypeRef T , & ValueRef [ ] elts) -> ValueRef {
1103
+ ret llvm:: LLVMConstNamedStruct ( T , std:: ivec:: to_ptr ( elts ) ,
1104
+ std:: ivec:: len ( elts ) ) ;
1105
+ }
1106
+
1099
1107
fn C_array ( TypeRef ty, & ValueRef [ ] elts) -> ValueRef {
1100
1108
ret llvm:: LLVMConstArray ( ty , std:: ivec:: to_ptr ( elts ) ,
1101
1109
std:: ivec:: len ( elts ) ) ;
@@ -1971,7 +1979,8 @@ fn emit_tydescs(&@crate_ctxt ccx) {
1971
1979
case ( some( ?v) ) { ccx. stats. n_real_glues += 1 u; v }
1972
1980
} ;
1973
1981
auto tydesc =
1974
- C_struct ( ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type) ) ) , ti. size,
1982
+ C_named_struct ( ccx. tydesc_type,
1983
+ ~[ C_null ( T_ptr ( T_ptr ( ccx. tydesc_type) ) ) , ti. size,
1975
1984
ti. align, copy_glue, // copy_glue
1976
1985
drop_glue, // drop_glue
1977
1986
free_glue, // free_glue
@@ -9074,11 +9083,6 @@ fn i2p(ValueRef v, TypeRef t) -> ValueRef {
9074
9083
ret llvm:: LLVMConstIntToPtr ( v, t) ;
9075
9084
}
9076
9085
9077
- fn create_typedefs( & @crate_ctxt cx) {
9078
- llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "task") , cx. task_type) ;
9079
- llvm:: LLVMAddTypeName ( cx. llmod, str :: buf( "tydesc") , cx. tydesc_type) ;
9080
- }
9081
-
9082
9086
fn declare_intrinsics( ModuleRef llmod) -> hashmap[ str , ValueRef ] {
9083
9087
let TypeRef [ ] T_memmove32_args =
9084
9088
~[ T_ptr ( T_i8 ( ) ) , T_ptr ( T_i8 ( ) ) , T_i32 ( ) , T_i32 ( ) , T_i1 ( ) ] ;
@@ -9298,7 +9302,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
9298
9302
tydesc_type=tydesc_type,
9299
9303
task_type=task_type) ;
9300
9304
auto cx = new_local_ctxt( ccx) ;
9301
- create_typedefs( ccx) ;
9302
9305
collect_items( ccx, crate ) ;
9303
9306
collect_tag_ctors( ccx, crate ) ;
9304
9307
trans_constants( ccx, crate ) ;
0 commit comments