@@ -31,7 +31,7 @@ fn align(off: uint, ty: Type) -> uint {
31
31
return align_up_to ( off, a) ;
32
32
}
33
33
34
- fn ty_align ( ty : TypeRef ) -> uint {
34
+ fn ty_align ( ty : Type ) -> uint {
35
35
unsafe {
36
36
return match llvm:: LLVMGetTypeKind ( ty) {
37
37
Integer => {
@@ -41,7 +41,7 @@ fn ty_align(ty: TypeRef) -> uint {
41
41
Float => 4 ,
42
42
Double => 8 ,
43
43
Struct => {
44
- if llvm :: LLVMIsPackedStruct ( ty ) == True {
44
+ if ty . is_packed ( ) {
45
45
1
46
46
} else {
47
47
let str_tys = struct_tys ( ty) ;
@@ -71,32 +71,31 @@ fn ty_size(ty: TypeRef) -> uint {
71
71
let str_tys = struct_tys ( ty) ;
72
72
str_tys. iter ( ) . fold ( 0 , |s, t| s + ty_size ( * t) )
73
73
} else {
74
- let str_tys = struct_tys ( ty ) ;
74
+ let str_tys = ty . field_types ( ) ;
75
75
let size = str_tys. iter ( ) . fold ( 0 , |s, t| align ( s, * t) + ty_size ( * t) ) ;
76
76
align ( size, ty)
77
77
}
78
78
}
79
79
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
84
84
}
85
85
_ => fail ! ( "ty_size: unhandled type" )
86
86
} ;
87
87
}
88
88
}
89
89
90
- fn classify_ret_ty ( ty : TypeRef ) -> ( LLVMType , Option < Attribute > ) {
90
+ fn classify_ret_ty ( ty : Type ) -> ( LLVMType , Option < Attribute > ) {
91
91
return if is_reg_ty ( ty) {
92
92
( LLVMType { cast : false , ty : ty } , None )
93
93
} else {
94
- ( LLVMType { cast : false , ty : T_ptr ( ty ) } , Some ( StructRetAttribute ) )
94
+ ( LLVMType { cast : false , ty : ty . ptr_to ( ) } , Some ( StructRetAttribute ) )
95
95
} ;
96
96
}
97
97
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 > ) {
100
99
let orig_offset = * offset;
101
100
let size = ty_size ( ty) * 8 ;
102
101
let mut align = ty_align ( ty) ;
@@ -123,7 +122,7 @@ fn classify_arg_ty(ty: TypeRef,
123
122
124
123
fn is_reg_ty ( ty : TypeRef ) -> bool {
125
124
unsafe {
126
- return match llvm :: LLVMGetTypeKind ( ty ) {
125
+ return match ty . kind ( ) {
127
126
Integer
128
127
| Pointer
129
128
| Float
@@ -133,16 +132,16 @@ fn is_reg_ty(ty: TypeRef) -> bool {
133
132
}
134
133
}
135
134
136
- fn padding_ty ( align : uint , offset : uint ) -> Option < TypeRef > {
135
+ fn padding_ty ( align : uint , offset : uint ) -> Option < Type > {
137
136
if ( ( align - 1 ) & offset) > 0 {
138
- return Some ( T_i32 ( ) ) ;
137
+ return Some ( Type :: i32 ( ) ) ;
139
138
}
140
139
141
140
return None ;
142
141
}
143
142
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 ( ) ;
146
145
let mut args = ~[ ] ;
147
146
148
147
let mut n = size / 32 ;
@@ -154,16 +153,16 @@ fn coerce_to_int(size: uint) -> ~[TypeRef] {
154
153
let r = size % 32 ;
155
154
if r > 0 {
156
155
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 ) ) )
158
157
}
159
158
}
160
159
161
160
return args;
162
161
}
163
162
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 {
167
166
let size = ty_size ( ty) * 8 ;
168
167
let mut fields = padding. map_default ( ~[ ] , |p| ~[ * p] ) ;
169
168
@@ -173,20 +172,20 @@ fn struct_ty(ty: TypeRef,
173
172
fields. push ( ty) ;
174
173
}
175
174
176
- return T_struct ( fields, false ) ;
175
+ return Type :: struct_ ( fields, false ) ;
177
176
}
178
177
179
178
enum MIPS_ABIInfo { MIPS_ABIInfo }
180
179
181
180
impl ABIInfo for MIPS_ABIInfo {
182
181
fn compute_info ( & self ,
183
- atys : & [ TypeRef ] ,
184
- rty : TypeRef ,
182
+ atys : & [ Type ] ,
183
+ rty : Type ,
185
184
ret_def : bool ) -> FnType {
186
185
let mut ( ret_ty, ret_attr) = if ret_def {
187
186
classify_ret_ty ( rty)
188
187
} else {
189
- ( LLVMType { cast : false , ty : T_void ( ) } , None )
188
+ ( LLVMType { cast : false , ty : Type :: void ( ) } , None )
190
189
} ;
191
190
192
191
let sret = ret_attr. is_some ( ) ;
@@ -203,7 +202,7 @@ impl ABIInfo for MIPS_ABIInfo {
203
202
if sret {
204
203
arg_tys = vec:: append ( ~[ ret_ty] , arg_tys) ;
205
204
attrs = vec:: append ( ~[ ret_attr] , attrs) ;
206
- ret_ty = LLVMType { cast : false , ty : T_void ( ) } ;
205
+ ret_ty = LLVMType { cast : false , ty : Type :: void ( ) } ;
207
206
}
208
207
209
208
return FnType {
0 commit comments