From b4a145e60f4bbc90dc780239cc49c024b9f52ca8 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 28 Jun 2011 17:58:44 -0700 Subject: Added a nanosecond timer to time.rs, support for some floating point casts, and a commandline-driven mode for pfib.rs --- src/comp/middle/trans.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/comp') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index c14938a5b61..01ae30bf4e1 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5113,7 +5113,22 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, ast::node_id id) -> result { int_cast(e_res.bcx, lldsttype, llsrctype, e_res.val, ty::type_is_signed(cx.fcx.lcx.ccx.tcx, t))); } - } else { cx.fcx.lcx.ccx.sess.unimpl("fp cast"); } + } + else { + if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, + ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) { + if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx, + ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) { + e_res = rslt(e_res.bcx, + e_res.bcx.build.SIToFP(e_res.val, lldsttype)); + } + else { + e_res = rslt(e_res.bcx, + e_res.bcx.build.UIToFP(e_res.val, lldsttype)); + } + } + else { cx.fcx.lcx.ccx.sess.unimpl("fp cast"); } + } ret e_res; } -- cgit 1.4.1-3-g733a5