Use c_ulonglong now that it works in FFI, etc...

Annotate FIXMEs; remove obsolete FIXMEs; remove an unnecessary
PointerCast.
This commit is contained in:
Tim Chevalier 2012-06-07 14:37:36 -07:00
parent dc77386494
commit d68c5cc399
2 changed files with 27 additions and 31 deletions

View File

@ -491,9 +491,11 @@ fn LLVMGetOrInsertFunction(M: ModuleRef, Name: *c_char,
fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint); fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
fn LLVMGetGC(Fn: ValueRef) -> *c_char; fn LLVMGetGC(Fn: ValueRef) -> *c_char;
fn LLVMSetGC(Fn: ValueRef, Name: *c_char); fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint); fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_ulonglong, HighPA:
fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint; c_ulonglong);
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint); fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: c_ulonglong, HighPA:
c_ulonglong);
/* Operations on parameters */ /* Operations on parameters */
fn LLVMCountParams(Fn: ValueRef) -> c_uint; fn LLVMCountParams(Fn: ValueRef) -> c_uint;

View File

@ -13,7 +13,7 @@
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int, // but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
// int) and rec(x=int, y=int, z=int) will have the same TypeRef. // int) and rec(x=int, y=int, z=int) will have the same TypeRef.
import libc::c_uint; import libc::{c_uint, c_ulonglong};
import std::{map, time, list}; import std::{map, time, list};
import std::map::hashmap; import std::map::hashmap;
import std::map::{int_hash, str_hash}; import std::map::{int_hash, str_hash};
@ -450,25 +450,25 @@ fn get_static_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
} }
fn set_no_inline(f: ValueRef) { fn set_no_inline(f: ValueRef) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoInlineAttribute as c_uint, llvm::LLVMAddFunctionAttr(f, lib::llvm::NoInlineAttribute as c_ulonglong,
0u as c_uint); 0u as c_ulonglong);
} }
fn set_no_unwind(f: ValueRef) { fn set_no_unwind(f: ValueRef) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoUnwindAttribute as c_uint, llvm::LLVMAddFunctionAttr(f, lib::llvm::NoUnwindAttribute as c_ulonglong,
0u as c_uint); 0u as c_ulonglong);
} }
// Tell LLVM to emit the information necessary to unwind the stack for the // Tell LLVM to emit the information necessary to unwind the stack for the
// function f. // function f.
fn set_uwtable(f: ValueRef) { fn set_uwtable(f: ValueRef) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::UWTableAttribute as c_uint, llvm::LLVMAddFunctionAttr(f, lib::llvm::UWTableAttribute as c_ulonglong,
0u as c_uint); 0u as c_ulonglong);
} }
fn set_inline_hint(f: ValueRef) { fn set_inline_hint(f: ValueRef) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::InlineHintAttribute as c_uint, llvm::LLVMAddFunctionAttr(f, lib::llvm::InlineHintAttribute
0u as c_uint); as c_ulonglong, 0u as c_ulonglong);
} }
fn set_inline_hint_if_appr(attrs: [ast::attribute], fn set_inline_hint_if_appr(attrs: [ast::attribute],
@ -481,13 +481,12 @@ fn set_inline_hint_if_appr(attrs: [ast::attribute],
} }
fn set_always_inline(f: ValueRef) { fn set_always_inline(f: ValueRef) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::AlwaysInlineAttribute as c_uint, llvm::LLVMAddFunctionAttr(f, lib::llvm::AlwaysInlineAttribute
0u as c_uint); as c_ulonglong, 0u as c_ulonglong);
} }
fn set_custom_stack_growth_fn(f: ValueRef) { fn set_custom_stack_growth_fn(f: ValueRef) {
// FIXME: Remove this hack to work around the lack of u64 in the FFI. llvm::LLVMAddFunctionAttr(f, 0u as c_ulonglong, 1u as c_ulonglong);
llvm::LLVMAddFunctionAttr(f, 0u as c_uint, 1u as c_uint);
} }
fn set_glue_inlining(f: ValueRef, t: ty::t) { fn set_glue_inlining(f: ValueRef, t: ty::t) {
@ -1343,7 +1342,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
// FIXME: Provide LLVM with better alignment information when the // FIXME: Provide LLVM with better alignment information when the
// alignment is statically known (it must be nothing more than a constant // alignment is statically known (it must be nothing more than a constant
// int, or LLVM complains -- not even a constant element of a tydesc // int, or LLVM complains -- not even a constant element of a tydesc
// works). // works). (Related to #1645, I think?)
let _icx = cx.insn_ctxt("call_memmove"); let _icx = cx.insn_ctxt("call_memmove");
let ccx = cx.ccx(); let ccx = cx.ccx();
let key = alt ccx.sess.targ_cfg.arch { let key = alt ccx.sess.targ_cfg.arch {
@ -1428,7 +1427,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef,
// Since it needs to zero out the source, src also needs to be an lval. // Since it needs to zero out the source, src also needs to be an lval.
// FIXME: We always zero out the source. Ideally we would detect the // FIXME: We always zero out the source. Ideally we would detect the
// case where a variable is always deinitialized by block exit and thus // case where a variable is always deinitialized by block exit and thus
// doesn't need to be dropped. // doesn't need to be dropped. (Issue #839)
fn move_val(cx: block, action: copy_action, dst: ValueRef, fn move_val(cx: block, action: copy_action, dst: ValueRef,
src: lval_result, t: ty::t) -> block { src: lval_result, t: ty::t) -> block {
let _icx = cx.insn_ctxt("move_val"); let _icx = cx.insn_ctxt("move_val");
@ -1623,7 +1622,7 @@ fn cast_shift_rhs(op: ast::binop,
trunc(rhs, lhs_llty) trunc(rhs, lhs_llty)
} else if lhs_sz > rhs_sz { } else if lhs_sz > rhs_sz {
// FIXME: If shifting by negative values becomes not undefined // FIXME: If shifting by negative values becomes not undefined
// then this is wrong. // then this is wrong. (See discussion at #1570)
zext(rhs, lhs_llty) zext(rhs, lhs_llty)
} else { } else {
rhs rhs
@ -1713,6 +1712,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
expr_ty(bcx, ex), expr_ty(bcx, ex),
{|bcx| {|bcx|
// FIXME provide the already-computed address, not the expr // FIXME provide the already-computed address, not the expr
// #2528
impl::trans_method_callee(bcx, callee_id, dst, origin) impl::trans_method_callee(bcx, callee_id, dst, origin)
}, },
arg_exprs([src]), save_in(lhs_res.val)); arg_exprs([src]), save_in(lhs_res.val));
@ -2006,7 +2006,7 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t)
} }
fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> {
// FIXME[mono] could do this recursively. is that worthwhile? // FIXME[mono] could do this recursively. is that worthwhile? (#2529)
alt ty::get(ty).struct { alt ty::get(ty).struct {
ty::ty_box(mt) { some(ty::mk_opaque_box(tcx)) } ty::ty_box(mt) { some(ty::mk_opaque_box(tcx)) }
ty::ty_fn(fty) { some(ty::mk_fn(tcx, {purity: ast::impure_fn, ty::ty_fn(fty) { some(ty::mk_fn(tcx, {purity: ast::impure_fn,
@ -2379,7 +2379,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
ccx, node_id_type(bcx, id)))); ccx, node_id_type(bcx, id))));
} }
// FIXME: Need to support external crust functions // FIXME: Need to support external crust functions (#1840)
if fn_id.crate == ast::local_crate { if fn_id.crate == ast::local_crate {
alt bcx.tcx().def_map.find(id) { alt bcx.tcx().def_map.find(id) {
some(ast::def_fn(_, ast::crust_fn)) { some(ast::def_fn(_, ast::crust_fn)) {
@ -2480,10 +2480,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee {
} else { } else {
// Nullary variant. // Nullary variant.
let enum_ty = node_id_type(cx, id); let enum_ty = node_id_type(cx, id);
let llenumblob = alloc_ty(cx, enum_ty); let llenumptr = alloc_ty(cx, enum_ty);
// FIXME: This pointer cast probably isn't necessary
let llenumty = type_of(ccx, enum_ty);
let llenumptr = PointerCast(cx, llenumblob, T_ptr(llenumty));
let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]); let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]);
let lldiscrim_gv = lookup_discriminant(ccx, vid); let lldiscrim_gv = lookup_discriminant(ccx, vid);
let lldiscrim = Load(cx, lldiscrim_gv); let lldiscrim = Load(cx, lldiscrim_gv);
@ -3666,7 +3663,7 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block {
expr_ty(bcx, src), is_last_use); expr_ty(bcx, src), is_last_use);
} }
ast::expr_move(dst, src) { ast::expr_move(dst, src) {
// FIXME: calculate copy init-ness in typestate. // FIXME: calculate copy init-ness in typestate. (#839)
assert dest == ignore; assert dest == ignore;
let src_r = trans_temp_lval(bcx, src); let src_r = trans_temp_lval(bcx, src);
let {bcx, val: addr, kind} = trans_lval(src_r.bcx, dst); let {bcx, val: addr, kind} = trans_lval(src_r.bcx, dst);
@ -4650,7 +4647,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
// FIXME: this should do some structural hash-consing to avoid // FIXME: this should do some structural hash-consing to avoid
// duplicate constants. I think. Maybe LLVM has a magical mode // duplicate constants. I think. Maybe LLVM has a magical mode
// that does so later on? // that does so later on? (#2530)
fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
let _icx = cx.insn_ctxt("trans_const_expr"); let _icx = cx.insn_ctxt("trans_const_expr");
alt e.node { alt e.node {
@ -4754,7 +4751,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
}, _) { }, _) {
// FIXME: Instead of recursing here to regenerate the values // FIXME: Instead of recursing here to regenerate the values
// for other constants, we should just look up the // for other constants, we should just look up the
// already-defined value // already-defined value (#2530)
trans_const_expr(cx, subexpr) trans_const_expr(cx, subexpr)
} }
_ { _ {
@ -4800,7 +4797,6 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
// Make the fn context // Make the fn context
let fcx = new_fn_ctxt_w_id(ccx, path, llctor_decl, ctor_id, let fcx = new_fn_ctxt_w_id(ccx, path, llctor_decl, ctor_id,
some(psubsts), some(sp)); some(psubsts), some(sp));
// FIXME: need to substitute into the fn arg types too?
create_llargs_for_fn_args(fcx, no_self, decl.inputs); create_llargs_for_fn_args(fcx, no_self, decl.inputs);
let mut bcx_top = top_scope_block(fcx, body.info()); let mut bcx_top = top_scope_block(fcx, body.info());
let lltop = bcx_top.llbb; let lltop = bcx_top.llbb;
@ -4953,8 +4949,6 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
ast::item_class(tps, _ifaces, items, ctor, m_dtor, _) { ast::item_class(tps, _ifaces, items, ctor, m_dtor, _) {
if tps.len() == 0u { if tps.len() == 0u {
let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps), let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps),
// FIXME: vtables have to get filled in depending
// on ifaces
vtables: none, vtables: none,
bounds: @[]}; bounds: @[]};
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body, trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,