Skip to content

Commit 3e75698

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 5951 b: refs/heads/master c: 8f2d75d h: refs/heads/master i: 5949: 1300803 5947: cefbe2d 5943: c2290a5 5935: f37f3ec 5919: ee17e67 5887: ab4c4a5 v: v3
1 parent cb82adc commit 3e75698

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d69a83b0213952f2fdd48cddad493ad7a8dc0d6a
2+
refs/heads/master: 8f2d75d53c18c56e419a4e998699f2b525d68f07

trunk/src/comp/back/upcall.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import trans::decl_cdecl_fn;
55
import middle::trans_common::{T_f32, T_f64, T_fn, T_bool, T_i1, T_i8, T_i32,
66
T_int, T_vec, T_nil, T_opaque_chan_ptr,
77
T_opaque_vec, T_opaque_port_ptr, T_ptr,
8-
T_size_t, T_void};
8+
T_size_t, T_void, T_float};
99
import lib::llvm::type_names;
1010
import lib::llvm::llvm::ModuleRef;
1111
import lib::llvm::llvm::ValueRef;
@@ -28,6 +28,7 @@ type upcalls =
2828
dynastack_free: ValueRef,
2929
alloc_c_stack: ValueRef,
3030
call_c_stack: ValueRef,
31+
call_c_stack_float: ValueRef,
3132
rust_personality: ValueRef};
3233

3334
fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
@@ -77,6 +78,9 @@ fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
7778
call_c_stack: d("call_c_stack",
7879
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
7980
T_int()),
81+
call_c_stack_float: d("call_c_stack_float",
82+
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
83+
T_float()),
8084
rust_personality: d("rust_personality", [], T_i32())
8185
};
8286
}

trunk/src/comp/middle/trans.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,20 +3864,33 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38643864
i += 1u;
38653865
}
38663866

3867-
// Call.
3868-
// TODO: Invoke instead.
3869-
let llrawretval = Call(bcx, ccx.upcalls.call_c_stack,
3870-
[llfn, llrawargbundle]);
3871-
3872-
// Cast return type.
3867+
// Determine return type.
38733868
let ret_ty = ty::ty_fn_ret(bcx_tcx(bcx), fn_ty);
38743869
check type_has_static_size(ccx, ret_ty);
38753870
let llretty = type_of(ccx, f.span, ret_ty);
38763871

3872+
// Determine which upcall fn to use based on the return type.
3873+
let upcall_fn = alt lib::llvm::llvm::LLVMGetTypeKind(llretty) {
3874+
1 | 2 | 3 | 4 | 5 {
3875+
// LLVMFloatTypeKind, LLVMDoubleTypeKind,
3876+
// LLVMX86_FP80TypeKind, LLVMFP128TypeKind
3877+
// LLVMPPC_FP128TypeKind
3878+
ccx.upcalls.call_c_stack_float
3879+
}
3880+
3881+
_ { ccx.upcalls.call_c_stack }
3882+
};
3883+
3884+
// Call and cast the return type.
3885+
// TODO: Invoke instead.
3886+
let llrawretval = Call(bcx, upcall_fn,
3887+
[llfn, llrawargbundle]);
38773888
let llretval;
38783889
if lib::llvm::llvm::LLVMGetTypeKind(llretty) as int == 11 { // pointer
38793890
llretval = IntToPtr(bcx, llrawretval, llretty);
38803891
} else {
3892+
log_err("TruncOrBitCast(", val_str(ccx.tn, llrawretval), ", ",
3893+
ty_str(ccx.tn, llretty), ")");
38813894
llretval = TruncOrBitCast(bcx, llrawretval, llretty);
38823895
}
38833896

trunk/src/rt/arch/i386/ccall.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
// slower.
77
#if defined(__APPLE__) || defined(_WIN32)
88
.globl _upcall_call_c_stack
9+
.globl _upcall_call_c_stack_float
910
_upcall_call_c_stack:
11+
_upcall_call_c_stack_float:
1012
#else
1113
.globl upcall_call_c_stack
14+
.globl upcall_call_c_stack_float
1215
upcall_call_c_stack:
16+
upcall_call_c_stack_float:
1317
#endif
1418
pushl %ebp
1519
movl %esp,%ebp // save esp

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ task_join
6565
unsupervise
6666
upcall_alloc_c_stack
6767
upcall_call_c_stack
68+
upcall_call_c_stack_float
6869
upcall_cmp_type
6970
upcall_dynastack_alloc
7071
upcall_dynastack_alloc_2

trunk/src/test/bench/shootout-nbody.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// based on:
22
// http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java
33

4-
native "llvm" mod llvm {
5-
fn sqrt(n: float) -> float = "sqrt.f64";
4+
native "c-stack-cdecl" mod llvm = "" {
5+
fn sqrt(n: float) -> float;
66
}
77

88
fn main() {

0 commit comments

Comments
 (0)