@@ -31,7 +31,7 @@ fn align(off: uint, ty: Type) -> uint {
3131 return align_up_to ( off, a) ;
3232}
3333
34- fn ty_align ( ty : TypeRef ) -> uint {
34+ fn ty_align ( ty : Type ) -> uint {
3535 unsafe {
3636 return match llvm:: LLVMGetTypeKind ( ty) {
3737 Integer => {
@@ -41,7 +41,7 @@ fn ty_align(ty: TypeRef) -> uint {
4141 Float => 4 ,
4242 Double => 8 ,
4343 Struct => {
44- if llvm :: LLVMIsPackedStruct ( ty ) == True {
44+ if ty . is_packed ( ) {
4545 1
4646 } else {
4747 let str_tys = struct_tys ( ty) ;
@@ -71,32 +71,31 @@ fn ty_size(ty: TypeRef) -> uint {
7171 let str_tys = struct_tys ( ty) ;
7272 str_tys. iter ( ) . fold ( 0 , |s, t| s + ty_size ( * t) )
7373 } else {
74- let str_tys = struct_tys ( ty ) ;
74+ let str_tys = ty . field_types ( ) ;
7575 let size = str_tys. iter ( ) . fold ( 0 , |s, t| align ( s, * t) + ty_size ( * t) ) ;
7676 align ( size, ty)
7777 }
7878 }
7979 Array => {
80- let len = llvm :: LLVMGetArrayLength ( ty ) as uint ;
81- let elt = llvm :: LLVMGetElementType ( ty ) ;
82- let eltsz = ty_size ( elt) ;
83- len * eltsz
80+ let len = ty . array_length ( ) ;
81+ let elt = ty . element_type ( ) ;
82+ let eltsz = ty_size ( elt) ;
83+ len * eltsz
8484 }
8585 _ => fail ! ( "ty_size: unhandled type" )
8686 } ;
8787 }
8888}
8989
90- fn classify_ret_ty ( ty : TypeRef ) -> ( LLVMType , Option < Attribute > ) {
90+ fn classify_ret_ty ( ty : Type ) -> ( LLVMType , Option < Attribute > ) {
9191 return if is_reg_ty ( ty) {
9292 ( LLVMType { cast : false , ty : ty } , None )
9393 } else {
94- ( LLVMType { cast : false , ty : T_ptr ( ty ) } , Some ( StructRetAttribute ) )
94+ ( LLVMType { cast : false , ty : ty . ptr_to ( ) } , Some ( StructRetAttribute ) )
9595 } ;
9696}
9797
98- fn classify_arg_ty ( ty : TypeRef ,
99- offset : & mut uint ) -> ( LLVMType , Option < Attribute > ) {
98+ fn classify_arg_ty ( ty : Type , offset : & mut uint ) -> ( LLVMType , Option < Attribute > ) {
10099 let orig_offset = * offset;
101100 let size = ty_size ( ty) * 8 ;
102101 let mut align = ty_align ( ty) ;
@@ -123,7 +122,7 @@ fn classify_arg_ty(ty: TypeRef,
123122
124123fn is_reg_ty ( ty : TypeRef ) -> bool {
125124 unsafe {
126- return match llvm :: LLVMGetTypeKind ( ty ) {
125+ return match ty . kind ( ) {
127126 Integer
128127 | Pointer
129128 | Float
@@ -133,16 +132,16 @@ fn is_reg_ty(ty: TypeRef) -> bool {
133132 }
134133}
135134
136- fn padding_ty ( align : uint , offset : uint ) -> Option < TypeRef > {
135+ fn padding_ty ( align : uint , offset : uint ) -> Option < Type > {
137136 if ( ( align - 1 ) & offset) > 0 {
138- return Some ( T_i32 ( ) ) ;
137+ return Some ( Type :: i32 ( ) ) ;
139138 }
140139
141140 return None ;
142141}
143142
144- fn coerce_to_int ( size : uint ) -> ~[ TypeRef ] {
145- let int_ty = T_i32 ( ) ;
143+ fn coerce_to_int ( size : uint ) -> ~[ Type ] {
144+ let int_ty = Type :: i32 ( ) ;
146145 let mut args = ~[ ] ;
147146
148147 let mut n = size / 32 ;
@@ -154,16 +153,16 @@ fn coerce_to_int(size: uint) -> ~[TypeRef] {
154153 let r = size % 32 ;
155154 if r > 0 {
156155 unsafe {
157- args. push ( llvm:: LLVMIntTypeInContext ( task_llcx ( ) , r as c_uint ) )
156+ Type :: from_ref ( args. push ( llvm:: LLVMIntTypeInContext ( task_llcx ( ) , r as c_uint ) ) )
158157 }
159158 }
160159
161160 return args;
162161}
163162
164- fn struct_ty ( ty : TypeRef ,
165- padding : Option < TypeRef > ,
166- coerce : bool ) -> TypeRef {
163+ fn struct_ty ( ty : Type ,
164+ padding : Option < Type > ,
165+ coerce : bool ) -> Type {
167166 let size = ty_size ( ty) * 8 ;
168167 let mut fields = padding. map_default ( ~[ ] , |p| ~[ * p] ) ;
169168
@@ -173,20 +172,20 @@ fn struct_ty(ty: TypeRef,
173172 fields. push ( ty) ;
174173 }
175174
176- return T_struct ( fields, false ) ;
175+ return Type :: struct_ ( fields, false ) ;
177176}
178177
179178enum MIPS_ABIInfo { MIPS_ABIInfo }
180179
181180impl ABIInfo for MIPS_ABIInfo {
182181 fn compute_info ( & self ,
183- atys : & [ TypeRef ] ,
184- rty : TypeRef ,
182+ atys : & [ Type ] ,
183+ rty : Type ,
185184 ret_def : bool ) -> FnType {
186185 let mut ( ret_ty, ret_attr) = if ret_def {
187186 classify_ret_ty ( rty)
188187 } else {
189- ( LLVMType { cast : false , ty : T_void ( ) } , None )
188+ ( LLVMType { cast : false , ty : Type :: void ( ) } , None )
190189 } ;
191190
192191 let sret = ret_attr. is_some ( ) ;
@@ -203,7 +202,7 @@ impl ABIInfo for MIPS_ABIInfo {
203202 if sret {
204203 arg_tys = vec:: append ( ~[ ret_ty] , arg_tys) ;
205204 attrs = vec:: append ( ~[ ret_attr] , attrs) ;
206- ret_ty = LLVMType { cast : false , ty : T_void ( ) } ;
205+ ret_ty = LLVMType { cast : false , ty : Type :: void ( ) } ;
207206 }
208207
209208 return FnType {
0 commit comments