|
3 | 3 |
|
4 | 4 | import lib::llvm::True;
|
5 | 5 | import lib::llvm::llvm::{ModuleRef, TypeRef, ValueRef};
|
| 6 | +import driver::session; |
6 | 7 | import middle::{trans, trans_common};
|
7 | 8 | import middle::trans_common::{crate_ctxt, val_ty, C_bytes,
|
8 | 9 | C_named_struct, C_struct};
|
@@ -231,16 +232,32 @@ fn tag_kind(ccx: @crate_ctxt, did: ast::def_id) -> tag_kind {
|
231 | 232 |
|
232 | 233 |
|
233 | 234 | // Returns the code corresponding to the pointer size on this architecture.
|
234 |
| -fn s_int(_tcx: ty_ctxt) -> u8 { |
235 |
| - ret shape_i32; // TODO: x86-64 |
| 235 | +fn s_int(tcx: ty_ctxt) -> u8 { |
| 236 | + ret alt tcx.sess.get_targ_cfg().arch { |
| 237 | + session::arch_x86. { shape_i32 } |
| 238 | + session::arch_x86_64. { shape_i64 } |
| 239 | + session::arch_arm. { shape_i32 } |
| 240 | + }; |
236 | 241 | }
|
237 | 242 |
|
238 |
| -fn s_uint(_tcx: ty_ctxt) -> u8 { |
239 |
| - ret shape_u32; // TODO: x86-64 |
| 243 | +fn s_uint(tcx: ty_ctxt) -> u8 { |
| 244 | + ret alt tcx.sess.get_targ_cfg().arch { |
| 245 | + session::arch_x86. { shape_u32 } |
| 246 | + session::arch_x86_64. { shape_u64 } |
| 247 | + session::arch_arm. { shape_u32 } |
| 248 | + }; |
240 | 249 | }
|
241 | 250 |
|
242 |
| -fn s_float(_tcx: ty_ctxt) -> u8 { |
243 |
| - ret shape_f64; // TODO: x86-64 |
| 251 | +fn s_float(tcx: ty_ctxt) -> u8 { |
| 252 | + ret alt tcx.sess.get_targ_cfg().arch { |
| 253 | + session::arch_x86. { shape_f64 } |
| 254 | + session::arch_x86_64. { shape_f64 } |
| 255 | + session::arch_arm. { shape_f64 } |
| 256 | + }; |
| 257 | +} |
| 258 | + |
| 259 | +fn s_variant_tag_t(tcx: ty_ctxt) -> u8 { |
| 260 | + ret s_int(tcx); |
244 | 261 | }
|
245 | 262 |
|
246 | 263 | fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
@@ -329,9 +346,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
|
329 | 346 | alt tag_kind(ccx, did) {
|
330 | 347 | tk_unit. {
|
331 | 348 | // FIXME: For now we do this.
|
332 |
| - s += [shape_u32]; |
| 349 | + s += [s_variant_tag_t(ccx.tcx)]; |
333 | 350 | }
|
334 |
| - tk_enum. { s += [shape_u32]; } |
| 351 | + tk_enum. { s += [s_variant_tag_t(ccx.tcx)]; } |
335 | 352 | tk_complex. {
|
336 | 353 | s += [shape_tag];
|
337 | 354 |
|
|
0 commit comments