Convert a couple hundred ~""s to ""s, in trans functions.

This commit is contained in:
Graydon Hoare
2012-08-14 16:45:43 -07:00
parent c1fad07758
commit 4c16ff516d
9 changed files with 280 additions and 280 deletions

View File

@@ -41,7 +41,7 @@ enum opt_result {
range_result(result, result), range_result(result, result),
} }
fn trans_opt(bcx: block, o: opt) -> opt_result { fn trans_opt(bcx: block, o: opt) -> opt_result {
let _icx = bcx.insn_ctxt(~"alt::trans_opt"); let _icx = bcx.insn_ctxt("alt::trans_opt");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let mut bcx = bcx; let mut bcx = bcx;
match o { match o {
@@ -303,7 +303,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
fn extract_variant_args(bcx: block, pat_id: ast::node_id, fn extract_variant_args(bcx: block, pat_id: ast::node_id,
vdefs: {enm: def_id, var: def_id}, val: ValueRef) -> vdefs: {enm: def_id, var: def_id}, val: ValueRef) ->
{vals: ~[ValueRef], bcx: block} { {vals: ~[ValueRef], bcx: block} {
let _icx = bcx.insn_ctxt(~"alt::extract_variant_args"); let _icx = bcx.insn_ctxt("alt::extract_variant_args");
let ccx = bcx.fcx.ccx; let ccx = bcx.fcx.ccx;
let enum_ty_substs = match check ty::get(node_id_type(bcx, pat_id)) let enum_ty_substs = match check ty::get(node_id_type(bcx, pat_id))
.struct { .struct {
@@ -449,7 +449,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
For an empty match, a fall-through case must exist For an empty match, a fall-through case must exist
*/ */
assert(m.len() > 0u || is_some(chk)); assert(m.len() > 0u || is_some(chk));
let _icx = bcx.insn_ctxt(~"alt::compile_submatch"); let _icx = bcx.insn_ctxt("alt::compile_submatch");
let mut bcx = bcx; let mut bcx = bcx;
let tcx = bcx.tcx(), dm = tcx.def_map; let tcx = bcx.tcx(), dm = tcx.def_map;
if m.len() == 0u { Br(bcx, option::get(chk)()); return; } if m.len() == 0u { Br(bcx, option::get(chk)()); return; }
@@ -735,7 +735,7 @@ fn make_phi_bindings(bcx: block,
map: ~[exit_node], map: ~[exit_node],
ids: pat_util::pat_id_map) ids: pat_util::pat_id_map)
-> option<phi_bindings_list> { -> option<phi_bindings_list> {
let _icx = bcx.insn_ctxt(~"alt::make_phi_bindings"); let _icx = bcx.insn_ctxt("alt::make_phi_bindings");
let our_block = bcx.llbb as uint; let our_block = bcx.llbb as uint;
let mut phi_bindings = ~[]; let mut phi_bindings = ~[];
for ids.each |name, node_id| { for ids.each |name, node_id| {
@@ -815,7 +815,7 @@ fn trans_alt(bcx: block,
arms: ~[ast::arm], arms: ~[ast::arm],
mode: ast::alt_mode, mode: ast::alt_mode,
dest: dest) -> block { dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"alt::trans_alt"); let _icx = bcx.insn_ctxt("alt::trans_alt");
do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| { do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| {
trans_alt_inner(bcx, expr, arms, mode, dest) trans_alt_inner(bcx, expr, arms, mode, dest)
} }
@@ -823,7 +823,7 @@ fn trans_alt(bcx: block,
fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
mode: ast::alt_mode, dest: dest) -> block { mode: ast::alt_mode, dest: dest) -> block {
let _icx = scope_cx.insn_ctxt(~"alt::trans_alt_inner"); let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner");
let bcx = scope_cx, tcx = bcx.tcx(); let bcx = scope_cx, tcx = bcx.tcx();
let mut bodies = ~[], matches = ~[]; let mut bodies = ~[], matches = ~[];
@@ -897,7 +897,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
// Not alt-related, but similar to the pattern-munging code above // Not alt-related, but similar to the pattern-munging code above
fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
make_copy: bool) -> block { make_copy: bool) -> block {
let _icx = bcx.insn_ctxt(~"alt::bind_irrefutable_pat"); let _icx = bcx.insn_ctxt("alt::bind_irrefutable_pat");
let ccx = bcx.fcx.ccx; let ccx = bcx.fcx.ccx;
let mut bcx = bcx; let mut bcx = bcx;

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@ fn B(cx: block) -> BuilderRef {
return b; return b;
} }
fn count_insn(cx: block, category: ~str) { fn count_insn(cx: block, category: &str) {
if cx.ccx().sess.count_llvm_insns() { if cx.ccx().sess.count_llvm_insns() {
let h = cx.ccx().stats.llvm_insns; let h = cx.ccx().stats.llvm_insns;
@@ -70,7 +70,7 @@ fn RetVoid(cx: block) {
if cx.unreachable { return; } if cx.unreachable { return; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"retvoid"); count_insn(cx, "retvoid");
llvm::LLVMBuildRetVoid(B(cx)); llvm::LLVMBuildRetVoid(B(cx));
} }
@@ -78,7 +78,7 @@ fn Ret(cx: block, V: ValueRef) {
if cx.unreachable { return; } if cx.unreachable { return; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"ret"); count_insn(cx, "ret");
llvm::LLVMBuildRet(B(cx), V); llvm::LLVMBuildRet(B(cx), V);
} }
@@ -96,7 +96,7 @@ fn Br(cx: block, Dest: BasicBlockRef) {
if cx.unreachable { return; } if cx.unreachable { return; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"br"); count_insn(cx, "br");
llvm::LLVMBuildBr(B(cx), Dest); llvm::LLVMBuildBr(B(cx), Dest);
} }
@@ -105,7 +105,7 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
if cx.unreachable { return; } if cx.unreachable { return; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"condbr"); count_insn(cx, "condbr");
llvm::LLVMBuildCondBr(B(cx), If, Then, Else); llvm::LLVMBuildCondBr(B(cx), If, Then, Else);
} }
@@ -126,7 +126,7 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
if cx.unreachable { return; } if cx.unreachable { return; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"indirectbr"); count_insn(cx, "indirectbr");
llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests as c_uint); llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests as c_uint);
} }
@@ -147,7 +147,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)), str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)),
~", ")}; ~", ")};
unsafe { unsafe {
count_insn(cx, ~"invoke"); count_insn(cx, "invoke");
llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, Then, Catch, Args.len() as c_uint, Then, Catch,
noname()); noname());
@@ -160,7 +160,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
unsafe { unsafe {
count_insn(cx, ~"fastinvoke"); count_insn(cx, "fastinvoke");
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, Args.len() as c_uint,
Then, Catch, noname()); Then, Catch, noname());
@@ -172,7 +172,7 @@ fn Unreachable(cx: block) {
if cx.unreachable { return; } if cx.unreachable { return; }
cx.unreachable = true; cx.unreachable = true;
if !cx.terminated { if !cx.terminated {
count_insn(cx, ~"unreachable"); count_insn(cx, "unreachable");
llvm::LLVMBuildUnreachable(B(cx)); llvm::LLVMBuildUnreachable(B(cx));
} }
} }
@@ -184,218 +184,218 @@ fn _Undef(val: ValueRef) -> ValueRef {
/* Arithmetic */ /* Arithmetic */
fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"add"); count_insn(cx, "add");
return llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname());
} }
fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nswadd"); count_insn(cx, "nswadd");
return llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname());
} }
fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwadd"); count_insn(cx, "nuwadd");
return llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname());
} }
fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fadd"); count_insn(cx, "fadd");
return llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname());
} }
fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sub"); count_insn(cx, "sub");
return llvm::LLVMBuildSub(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildSub(B(cx), LHS, RHS, noname());
} }
fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nwsub"); count_insn(cx, "nwsub");
return llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname());
} }
fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwsub"); count_insn(cx, "nuwsub");
return llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname());
} }
fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sub"); count_insn(cx, "sub");
return llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname());
} }
fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"mul"); count_insn(cx, "mul");
return llvm::LLVMBuildMul(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildMul(B(cx), LHS, RHS, noname());
} }
fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nswmul"); count_insn(cx, "nswmul");
return llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname());
} }
fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwmul"); count_insn(cx, "nuwmul");
return llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname());
} }
fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fmul"); count_insn(cx, "fmul");
return llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname());
} }
fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"udiv"); count_insn(cx, "udiv");
return llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname());
} }
fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sdiv"); count_insn(cx, "sdiv");
return llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname());
} }
fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"extractsdiv"); count_insn(cx, "extractsdiv");
return llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname());
} }
fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fdiv"); count_insn(cx, "fdiv");
return llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname());
} }
fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"urem"); count_insn(cx, "urem");
return llvm::LLVMBuildURem(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildURem(B(cx), LHS, RHS, noname());
} }
fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"srem"); count_insn(cx, "srem");
return llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname());
} }
fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"frem"); count_insn(cx, "frem");
return llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname());
} }
fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"shl"); count_insn(cx, "shl");
return llvm::LLVMBuildShl(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildShl(B(cx), LHS, RHS, noname());
} }
fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"lshr"); count_insn(cx, "lshr");
return llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname());
} }
fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"ashr"); count_insn(cx, "ashr");
return llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname());
} }
fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"and"); count_insn(cx, "and");
return llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname());
} }
fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"or"); count_insn(cx, "or");
return llvm::LLVMBuildOr(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildOr(B(cx), LHS, RHS, noname());
} }
fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"xor"); count_insn(cx, "xor");
return llvm::LLVMBuildXor(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildXor(B(cx), LHS, RHS, noname());
} }
fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) ->
ValueRef { ValueRef {
if cx.unreachable { return _Undef(LHS); } if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"binop"); count_insn(cx, "binop");
return llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname()); return llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname());
} }
fn Neg(cx: block, V: ValueRef) -> ValueRef { fn Neg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); } if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"neg"); count_insn(cx, "neg");
return llvm::LLVMBuildNeg(B(cx), V, noname()); return llvm::LLVMBuildNeg(B(cx), V, noname());
} }
fn NSWNeg(cx: block, V: ValueRef) -> ValueRef { fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); } if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"nswneg"); count_insn(cx, "nswneg");
return llvm::LLVMBuildNSWNeg(B(cx), V, noname()); return llvm::LLVMBuildNSWNeg(B(cx), V, noname());
} }
fn NUWNeg(cx: block, V: ValueRef) -> ValueRef { fn NUWNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); } if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"nuwneg"); count_insn(cx, "nuwneg");
return llvm::LLVMBuildNUWNeg(B(cx), V, noname()); return llvm::LLVMBuildNUWNeg(B(cx), V, noname());
} }
fn FNeg(cx: block, V: ValueRef) -> ValueRef { fn FNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); } if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"fneg"); count_insn(cx, "fneg");
return llvm::LLVMBuildFNeg(B(cx), V, noname()); return llvm::LLVMBuildFNeg(B(cx), V, noname());
} }
fn Not(cx: block, V: ValueRef) -> ValueRef { fn Not(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); } if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"not"); count_insn(cx, "not");
return llvm::LLVMBuildNot(B(cx), V, noname()); return llvm::LLVMBuildNot(B(cx), V, noname());
} }
/* Memory */ /* Memory */
fn Malloc(cx: block, Ty: TypeRef) -> ValueRef { fn Malloc(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"malloc"); count_insn(cx, "malloc");
return llvm::LLVMBuildMalloc(B(cx), Ty, noname()); return llvm::LLVMBuildMalloc(B(cx), Ty, noname());
} }
fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"arraymalloc"); count_insn(cx, "arraymalloc");
return llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname()); return llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname());
} }
fn Alloca(cx: block, Ty: TypeRef) -> ValueRef { fn Alloca(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, ~"alloca"); count_insn(cx, "alloca");
return llvm::LLVMBuildAlloca(B(cx), Ty, noname()); return llvm::LLVMBuildAlloca(B(cx), Ty, noname());
} }
fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, ~"arrayalloca"); count_insn(cx, "arrayalloca");
return llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname()); return llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname());
} }
fn Free(cx: block, PointerVal: ValueRef) { fn Free(cx: block, PointerVal: ValueRef) {
if cx.unreachable { return; } if cx.unreachable { return; }
count_insn(cx, ~"free"); count_insn(cx, "free");
llvm::LLVMBuildFree(B(cx), PointerVal); llvm::LLVMBuildFree(B(cx), PointerVal);
} }
@@ -407,7 +407,7 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
llvm::LLVMGetElementType(ty) } else { ccx.int_type }; llvm::LLVMGetElementType(ty) } else { ccx.int_type };
return llvm::LLVMGetUndef(eltty); return llvm::LLVMGetUndef(eltty);
} }
count_insn(cx, ~"load"); count_insn(cx, "load");
return llvm::LLVMBuildLoad(B(cx), PointerVal, noname()); return llvm::LLVMBuildLoad(B(cx), PointerVal, noname());
} }
@@ -416,14 +416,14 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
debug!{"Store %s -> %s", debug!{"Store %s -> %s",
val_str(cx.ccx().tn, Val), val_str(cx.ccx().tn, Val),
val_str(cx.ccx().tn, Ptr)}; val_str(cx.ccx().tn, Ptr)};
count_insn(cx, ~"store"); count_insn(cx, "store");
llvm::LLVMBuildStore(B(cx), Val, Ptr); llvm::LLVMBuildStore(B(cx), Val, Ptr);
} }
fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
unsafe { unsafe {
count_insn(cx, ~"gep"); count_insn(cx, "gep");
return llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), return llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices),
Indices.len() as c_uint, noname()); Indices.len() as c_uint, noname());
} }
@@ -434,7 +434,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef { fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef {
let mut v: ~[ValueRef] = ~[]; let mut v: ~[ValueRef] = ~[];
for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); } for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); }
count_insn(cx, ~"gepi"); count_insn(cx, "gepi");
return InBoundsGEP(cx, base, v); return InBoundsGEP(cx, base, v);
} }
@@ -442,7 +442,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) ->
ValueRef { ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
unsafe { unsafe {
count_insn(cx, ~"inboundsgep"); count_insn(cx, "inboundsgep");
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
vec::unsafe::to_ptr(Indices), vec::unsafe::to_ptr(Indices),
Indices.len() as c_uint, Indices.len() as c_uint,
@@ -452,138 +452,138 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) ->
fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef { fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
count_insn(cx, ~"structgep"); count_insn(cx, "structgep");
return llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); return llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname());
} }
fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef { fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"globalstring"); count_insn(cx, "globalstring");
return llvm::LLVMBuildGlobalString(B(cx), _Str, noname()); return llvm::LLVMBuildGlobalString(B(cx), _Str, noname());
} }
fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef { fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"globalstringptr"); count_insn(cx, "globalstringptr");
return llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname()); return llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname());
} }
/* Casts */ /* Casts */
fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"trunc"); count_insn(cx, "trunc");
return llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname());
} }
fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"zext"); count_insn(cx, "zext");
return llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname());
} }
fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sext"); count_insn(cx, "sext");
return llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname());
} }
fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptoui"); count_insn(cx, "fptoui");
return llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname());
} }
fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptosi"); count_insn(cx, "fptosi");
return llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname());
} }
fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"uitofp"); count_insn(cx, "uitofp");
return llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname());
} }
fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sitofp"); count_insn(cx, "sitofp");
return llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname());
} }
fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptrunc"); count_insn(cx, "fptrunc");
return llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname());
} }
fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fpext"); count_insn(cx, "fpext");
return llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname());
} }
fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"ptrtoint"); count_insn(cx, "ptrtoint");
return llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname());
} }
fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"inttoptr"); count_insn(cx, "inttoptr");
return llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname());
} }
fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"bitcast"); count_insn(cx, "bitcast");
return llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname());
} }
fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef { ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"zextorbitcast"); count_insn(cx, "zextorbitcast");
return llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname());
} }
fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef { ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sextorbitcast"); count_insn(cx, "sextorbitcast");
return llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname());
} }
fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef { ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"truncorbitcast"); count_insn(cx, "truncorbitcast");
return llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname());
} }
fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef,
_Name: *u8) -> ValueRef { _Name: *u8) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"cast"); count_insn(cx, "cast");
return llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname()); return llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname());
} }
fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"pointercast"); count_insn(cx, "pointercast");
return llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname());
} }
fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"intcast"); count_insn(cx, "intcast");
return llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname());
} }
fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fpcast"); count_insn(cx, "fpcast");
return llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname()); return llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname());
} }
@@ -592,21 +592,21 @@ fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef) fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef { -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"icmp"); count_insn(cx, "icmp");
return llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); return llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname());
} }
fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef) fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef { -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"fcmp"); count_insn(cx, "fcmp");
return llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); return llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname());
} }
/* Miscellaneous instructions */ /* Miscellaneous instructions */
fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef { fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); } if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, ~"emptyphi"); count_insn(cx, "emptyphi");
return llvm::LLVMBuildPhi(B(cx), Ty, noname()); return llvm::LLVMBuildPhi(B(cx), Ty, noname());
} }
@@ -616,7 +616,7 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
assert vals.len() == bbs.len(); assert vals.len() == bbs.len();
let phi = EmptyPhi(cx, Ty); let phi = EmptyPhi(cx, Ty);
unsafe { unsafe {
count_insn(cx, ~"addincoming"); count_insn(cx, "addincoming");
llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals), llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals),
vec::unsafe::to_ptr(bbs), vec::unsafe::to_ptr(bbs),
vals.len() as c_uint); vals.len() as c_uint);
@@ -671,7 +671,7 @@ fn add_comment(bcx: block, text: ~str) {
fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); } if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe { unsafe {
count_insn(cx, ~"call"); count_insn(cx, "call");
debug!{"Call(Fn=%s, Args=%?)", debug!{"Call(Fn=%s, Args=%?)",
val_str(cx.ccx().tn, Fn), val_str(cx.ccx().tn, Fn),
@@ -685,7 +685,7 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); } if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe { unsafe {
count_insn(cx, ~"fastcall"); count_insn(cx, "fastcall");
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname()); Args.len() as c_uint, noname());
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv); lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
@@ -697,7 +697,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Conv: CallConv) -> ValueRef { Conv: CallConv) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); } if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe { unsafe {
count_insn(cx, ~"callwithconv"); count_insn(cx, "callwithconv");
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname()); Args.len() as c_uint, noname());
lib::llvm::SetInstructionCallConv(v, Conv); lib::llvm::SetInstructionCallConv(v, Conv);
@@ -708,40 +708,40 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) ->
ValueRef { ValueRef {
if cx.unreachable { return _Undef(Then); } if cx.unreachable { return _Undef(Then); }
count_insn(cx, ~"select"); count_insn(cx, "select");
return llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname()); return llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname());
} }
fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef { fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); } if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, ~"vaarg"); count_insn(cx, "vaarg");
return llvm::LLVMBuildVAArg(B(cx), list, Ty, noname()); return llvm::LLVMBuildVAArg(B(cx), list, Ty, noname());
} }
fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) -> fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) ->
ValueRef { ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); } if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
count_insn(cx, ~"extractelement"); count_insn(cx, "extractelement");
return llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname()); return llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname());
} }
fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef, fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
Index: ValueRef) { Index: ValueRef) {
if cx.unreachable { return; } if cx.unreachable { return; }
count_insn(cx, ~"insertelement"); count_insn(cx, "insertelement");
llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname()); llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname());
} }
fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef, fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
Mask: ValueRef) { Mask: ValueRef) {
if cx.unreachable { return; } if cx.unreachable { return; }
count_insn(cx, ~"shufflevector"); count_insn(cx, "shufflevector");
llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname()); llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname());
} }
fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef { fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); } if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
count_insn(cx, ~"extractvalue"); count_insn(cx, "extractvalue");
return llvm::LLVMBuildExtractValue( return llvm::LLVMBuildExtractValue(
B(cx), AggVal, Index as c_uint, noname()); B(cx), AggVal, Index as c_uint, noname());
} }
@@ -749,27 +749,27 @@ fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef, fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef,
Index: uint) { Index: uint) {
if cx.unreachable { return; } if cx.unreachable { return; }
count_insn(cx, ~"insertvalue"); count_insn(cx, "insertvalue");
llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint, llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint,
noname()); noname());
} }
fn IsNull(cx: block, Val: ValueRef) -> ValueRef { fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"isnull"); count_insn(cx, "isnull");
return llvm::LLVMBuildIsNull(B(cx), Val, noname()); return llvm::LLVMBuildIsNull(B(cx), Val, noname());
} }
fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef { fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"isnotnull"); count_insn(cx, "isnotnull");
return llvm::LLVMBuildIsNotNull(B(cx), Val, noname()); return llvm::LLVMBuildIsNotNull(B(cx), Val, noname());
} }
fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
let ccx = cx.fcx.ccx; let ccx = cx.fcx.ccx;
if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type); } if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type); }
count_insn(cx, ~"ptrdiff"); count_insn(cx, "ptrdiff");
return llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname()); return llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname());
} }
@@ -785,7 +785,7 @@ fn Trap(cx: block) {
assert (T as int != 0); assert (T as int != 0);
let Args: ~[ValueRef] = ~[]; let Args: ~[ValueRef] = ~[];
unsafe { unsafe {
count_insn(cx, ~"trap"); count_insn(cx, "trap");
llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args), llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname()); Args.len() as c_uint, noname());
} }
@@ -794,20 +794,20 @@ fn Trap(cx: block) {
fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef, fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef,
NumClauses: uint) -> ValueRef { NumClauses: uint) -> ValueRef {
assert !cx.terminated && !cx.unreachable; assert !cx.terminated && !cx.unreachable;
count_insn(cx, ~"landingpad"); count_insn(cx, "landingpad");
return llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, return llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn,
NumClauses as c_uint, noname()); NumClauses as c_uint, noname());
} }
fn SetCleanup(cx: block, LandingPad: ValueRef) { fn SetCleanup(cx: block, LandingPad: ValueRef) {
count_insn(cx, ~"setcleanup"); count_insn(cx, "setcleanup");
llvm::LLVMSetCleanup(LandingPad, lib::llvm::True); llvm::LLVMSetCleanup(LandingPad, lib::llvm::True);
} }
fn Resume(cx: block, Exn: ValueRef) -> ValueRef { fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
count_insn(cx, ~"resume"); count_insn(cx, "resume");
return llvm::LLVMBuildResume(B(cx), Exn); return llvm::LLVMBuildResume(B(cx), Exn);
} }

View File

@@ -137,11 +137,11 @@ fn allocate_cbox(bcx: block,
ck: ty::closure_kind, ck: ty::closure_kind,
cdata_ty: ty::t) cdata_ty: ty::t)
-> result { -> result {
let _icx = bcx.insn_ctxt(~"closure::allocate_cbox"); let _icx = bcx.insn_ctxt("closure::allocate_cbox");
let ccx = bcx.ccx(), tcx = ccx.tcx; let ccx = bcx.ccx(), tcx = ccx.tcx;
fn nuke_ref_count(bcx: block, llbox: ValueRef) { fn nuke_ref_count(bcx: block, llbox: ValueRef) {
let _icx = bcx.insn_ctxt(~"closure::nuke_ref_count"); let _icx = bcx.insn_ctxt("closure::nuke_ref_count");
// Initialize ref count to arbitrary value for debugging: // Initialize ref count to arbitrary value for debugging:
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let llbox = PointerCast(bcx, llbox, T_opaque_box_ptr(ccx)); let llbox = PointerCast(bcx, llbox, T_opaque_box_ptr(ccx));
@@ -178,7 +178,7 @@ type closure_result = {
fn store_environment(bcx: block, fn store_environment(bcx: block,
bound_values: ~[environment_value], bound_values: ~[environment_value],
ck: ty::closure_kind) -> closure_result { ck: ty::closure_kind) -> closure_result {
let _icx = bcx.insn_ctxt(~"closure::store_environment"); let _icx = bcx.insn_ctxt("closure::store_environment");
let ccx = bcx.ccx(), tcx = ccx.tcx; let ccx = bcx.ccx(), tcx = ccx.tcx;
// compute the shape of the closure // compute the shape of the closure
@@ -251,7 +251,7 @@ fn build_closure(bcx0: block,
ck: ty::closure_kind, ck: ty::closure_kind,
id: ast::node_id, id: ast::node_id,
include_ret_handle: option<ValueRef>) -> closure_result { include_ret_handle: option<ValueRef>) -> closure_result {
let _icx = bcx0.insn_ctxt(~"closure::build_closure"); let _icx = bcx0.insn_ctxt("closure::build_closure");
// If we need to, package up the iterator body to call // If we need to, package up the iterator body to call
let mut env_vals = ~[]; let mut env_vals = ~[];
let mut bcx = bcx0; let mut bcx = bcx0;
@@ -312,7 +312,7 @@ fn load_environment(fcx: fn_ctxt,
cap_vars: ~[capture::capture_var], cap_vars: ~[capture::capture_var],
load_ret_handle: bool, load_ret_handle: bool,
ck: ty::closure_kind) { ck: ty::closure_kind) {
let _icx = fcx.insn_ctxt(~"closure::load_environment"); let _icx = fcx.insn_ctxt("closure::load_environment");
let bcx = raw_block(fcx, false, fcx.llloadenv); let bcx = raw_block(fcx, false, fcx.llloadenv);
// Load a pointer to the closure data, skipping over the box header: // Load a pointer to the closure data, skipping over the box header:
@@ -354,7 +354,7 @@ fn trans_expr_fn(bcx: block,
cap_clause: ast::capture_clause, cap_clause: ast::capture_clause,
is_loop_body: option<option<ValueRef>>, is_loop_body: option<option<ValueRef>>,
dest: dest) -> block { dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn"); let _icx = bcx.insn_ctxt("closure::trans_expr_fn");
if dest == ignore { return bcx; } if dest == ignore { return bcx; }
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let fty = node_id_type(bcx, id); let fty = node_id_type(bcx, id);
@@ -407,7 +407,7 @@ fn make_fn_glue(
t: ty::t, t: ty::t,
glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block)
-> block { -> block {
let _icx = cx.insn_ctxt(~"closure::make_fn_glue"); let _icx = cx.insn_ctxt("closure::make_fn_glue");
let bcx = cx; let bcx = cx;
let tcx = cx.tcx(); let tcx = cx.tcx();
@@ -439,7 +439,7 @@ fn make_opaque_cbox_take_glue(
cboxptr: ValueRef) // ptr to ptr to the opaque closure cboxptr: ValueRef) // ptr to ptr to the opaque closure
-> block { -> block {
// Easy cases: // Easy cases:
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_take_glue");
match ck { match ck {
ty::ck_block => return bcx, ty::ck_block => return bcx,
ty::ck_box => { ty::ck_box => {
@@ -491,7 +491,7 @@ fn make_opaque_cbox_drop_glue(
ck: ty::closure_kind, ck: ty::closure_kind,
cboxptr: ValueRef) // ptr to the opaque closure cboxptr: ValueRef) // ptr to the opaque closure
-> block { -> block {
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue"); let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_drop_glue");
match ck { match ck {
ty::ck_block => bcx, ty::ck_block => bcx,
ty::ck_box => { ty::ck_box => {
@@ -510,7 +510,7 @@ fn make_opaque_cbox_free_glue(
ck: ty::closure_kind, ck: ty::closure_kind,
cbox: ValueRef) // ptr to ptr to the opaque closure cbox: ValueRef) // ptr to ptr to the opaque closure
-> block { -> block {
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_free_glue");
match ck { match ck {
ty::ck_block => return bcx, ty::ck_block => return bcx,
ty::ck_box | ty::ck_uniq => { /* hard cases: */ } ty::ck_box | ty::ck_uniq => { /* hard cases: */ }

View File

@@ -4,7 +4,7 @@ import base::get_insn_ctxt;
fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
-> ValueRef { -> ValueRef {
let _icx = cx.insn_ctxt(~"trans_lit"); let _icx = cx.insn_ctxt("trans_lit");
match lit.node { match lit.node {
ast::lit_int(i, t) => C_integral(T_int_ty(cx, t), i as u64, True), ast::lit_int(i, t) => C_integral(T_int_ty(cx, t), i as u64, True),
ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False), ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False),
@@ -82,7 +82,7 @@ fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
let _icx = cx.insn_ctxt(~"const_expr"); let _icx = cx.insn_ctxt("const_expr");
match e.node { match e.node {
ast::expr_lit(lit) => consts::const_lit(cx, e, *lit), ast::expr_lit(lit) => consts::const_lit(cx, e, *lit),
ast::expr_binary(b, e1, e2) => { ast::expr_binary(b, e1, e2) => {
@@ -366,7 +366,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
} }
fn trans_const(ccx: @crate_ctxt, e: @ast::expr, id: ast::node_id) { fn trans_const(ccx: @crate_ctxt, e: @ast::expr, id: ast::node_id) {
let _icx = ccx.insn_ctxt(~"trans_const"); let _icx = ccx.insn_ctxt("trans_const");
let v = const_expr(ccx, e); let v = const_expr(ccx, e);
// The scalars come back as 1st class LLVM vals // The scalars come back as 1st class LLVM vals

View File

@@ -511,7 +511,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
arg_builder: wrap_arg_builder, arg_builder: wrap_arg_builder,
ret_builder: wrap_ret_builder) { ret_builder: wrap_ret_builder) {
let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn_"); let _icx = ccx.insn_ctxt("foreign::build_wrap_fn_");
let fcx = new_fn_ctxt(ccx, ~[], llwrapfn, none); let fcx = new_fn_ctxt(ccx, ~[], llwrapfn, none);
let bcx = top_scope_block(fcx, none); let bcx = top_scope_block(fcx, none);
let lltop = bcx.llbb; let lltop = bcx.llbb;
@@ -571,18 +571,18 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
fn trans_foreign_mod(ccx: @crate_ctxt, fn trans_foreign_mod(ccx: @crate_ctxt,
foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) { foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) {
let _icx = ccx.insn_ctxt(~"foreign::trans_foreign_mod"); let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod");
fn build_shim_fn(ccx: @crate_ctxt, fn build_shim_fn(ccx: @crate_ctxt,
foreign_item: @ast::foreign_item, foreign_item: @ast::foreign_item,
tys: @c_stack_tys, tys: @c_stack_tys,
cc: lib::llvm::CallConv) -> ValueRef { cc: lib::llvm::CallConv) -> ValueRef {
let _icx = ccx.insn_ctxt(~"foreign::build_shim_fn"); let _icx = ccx.insn_ctxt("foreign::build_shim_fn");
fn build_args(bcx: block, tys: @c_stack_tys, fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> ~[ValueRef] { llargbundle: ValueRef) -> ~[ValueRef] {
let _icx = bcx.insn_ctxt(~"foreign::shim::build_args"); let _icx = bcx.insn_ctxt("foreign::shim::build_args");
let mut llargvals = ~[]; let mut llargvals = ~[];
let mut i = 0u; let mut i = 0u;
let n = vec::len(tys.arg_tys); let n = vec::len(tys.arg_tys);
@@ -628,7 +628,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
fn build_ret(bcx: block, tys: @c_stack_tys, fn build_ret(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef, llretval: ValueRef) { llargbundle: ValueRef, llretval: ValueRef) {
let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret"); let _icx = bcx.insn_ctxt("foreign::shim::build_ret");
match tys.x86_64_tys { match tys.x86_64_tys {
some(x86_64) => { some(x86_64) => {
do vec::iteri(x86_64.attrs) |i, a| { do vec::iteri(x86_64.attrs) |i, a| {
@@ -719,11 +719,11 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
llshimfn: ValueRef, llshimfn: ValueRef,
llwrapfn: ValueRef) { llwrapfn: ValueRef) {
let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn"); let _icx = ccx.insn_ctxt("foreign::build_wrap_fn");
fn build_args(bcx: block, tys: @c_stack_tys, fn build_args(bcx: block, tys: @c_stack_tys,
llwrapfn: ValueRef, llargbundle: ValueRef) { llwrapfn: ValueRef, llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt(~"foreign::wrap::build_args"); let _icx = bcx.insn_ctxt("foreign::wrap::build_args");
let mut i = 0u; let mut i = 0u;
let n = vec::len(tys.arg_tys); let n = vec::len(tys.arg_tys);
let implicit_args = first_real_arg; // return + env let implicit_args = first_real_arg; // return + env
@@ -738,7 +738,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
fn build_ret(bcx: block, _tys: @c_stack_tys, fn build_ret(bcx: block, _tys: @c_stack_tys,
_llargbundle: ValueRef) { _llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt(~"foreign::wrap::build_ret"); let _icx = bcx.insn_ctxt("foreign::wrap::build_ret");
RetVoid(bcx); RetVoid(bcx);
} }
@@ -987,12 +987,12 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) { body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) {
let _icx = ccx.insn_ctxt(~"foreign::build_foreign_fn"); let _icx = ccx.insn_ctxt("foreign::build_foreign_fn");
fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path, fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path,
decl: ast::fn_decl, body: ast::blk, decl: ast::fn_decl, body: ast::blk,
id: ast::node_id) -> ValueRef { id: ast::node_id) -> ValueRef {
let _icx = ccx.insn_ctxt(~"foreign::foreign::build_rust_fn"); let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id); let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path( let ps = link::mangle_internal_name_by_path(
ccx, vec::append_one(path, ast_map::path_name(@~"__rust_abi"))); ccx, vec::append_one(path, ast_map::path_name(@~"__rust_abi")));
@@ -1005,11 +1005,11 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path, fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef { llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef {
let _icx = ccx.insn_ctxt(~"foreign::foreign::build_shim_fn"); let _icx = ccx.insn_ctxt("foreign::foreign::build_shim_fn");
fn build_args(bcx: block, tys: @c_stack_tys, fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> ~[ValueRef] { llargbundle: ValueRef) -> ~[ValueRef] {
let _icx = bcx.insn_ctxt(~"foreign::extern::shim::build_args"); let _icx = bcx.insn_ctxt("foreign::extern::shim::build_args");
let mut llargvals = ~[]; let mut llargvals = ~[];
let mut i = 0u; let mut i = 0u;
let n = vec::len(tys.arg_tys); let n = vec::len(tys.arg_tys);
@@ -1042,11 +1042,11 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef, fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef,
llwrapfn: ValueRef, tys: @c_stack_tys) { llwrapfn: ValueRef, tys: @c_stack_tys) {
let _icx = ccx.insn_ctxt(~"foreign::foreign::build_wrap_fn"); let _icx = ccx.insn_ctxt("foreign::foreign::build_wrap_fn");
fn build_args(bcx: block, tys: @c_stack_tys, fn build_args(bcx: block, tys: @c_stack_tys,
llwrapfn: ValueRef, llargbundle: ValueRef) { llwrapfn: ValueRef, llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args"); let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_args");
match tys.x86_64_tys { match tys.x86_64_tys {
option::some(x86_64) => { option::some(x86_64) => {
let mut atys = x86_64.arg_tys; let mut atys = x86_64.arg_tys;
@@ -1100,7 +1100,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_ret(bcx: block, tys: @c_stack_tys, fn build_ret(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) { llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret"); let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_ret");
match tys.x86_64_tys { match tys.x86_64_tys {
option::some(x86_64) => { option::some(x86_64) => {
if x86_64.sret || !tys.ret_def { if x86_64.sret || !tys.ret_def {
@@ -1144,7 +1144,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn register_foreign_fn(ccx: @crate_ctxt, sp: span, fn register_foreign_fn(ccx: @crate_ctxt, sp: span,
path: ast_map::path, node_id: ast::node_id) path: ast_map::path, node_id: ast::node_id)
-> ValueRef { -> ValueRef {
let _icx = ccx.insn_ctxt(~"foreign::register_foreign_fn"); let _icx = ccx.insn_ctxt("foreign::register_foreign_fn");
let t = ty::node_id_to_type(ccx.tcx, node_id); let t = ty::node_id_to_type(ccx.tcx, node_id);
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id); let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id);
return if ccx.sess.targ_cfg.arch == arch_x86_64 { return if ccx.sess.targ_cfg.arch == arch_x86_64 {

View File

@@ -20,7 +20,7 @@ import syntax::print::pprust::expr_to_str;
fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
methods: ~[@ast::method], tps: ~[ast::ty_param]) { methods: ~[@ast::method], tps: ~[ast::ty_param]) {
let _icx = ccx.insn_ctxt(~"impl::trans_impl"); let _icx = ccx.insn_ctxt("impl::trans_impl");
if tps.len() > 0u { return; } if tps.len() > 0u { return; }
let sub_path = vec::append_one(path, path_name(name)); let sub_path = vec::append_one(path, path_name(name));
for vec::each(methods) |m| { for vec::each(methods) |m| {
@@ -41,7 +41,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
} }
fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result {
let _icx = bcx.insn_ctxt(~"impl::trans_self_arg"); let _icx = bcx.insn_ctxt("impl::trans_self_arg");
let basety = expr_ty(bcx, base); let basety = expr_ty(bcx, base);
let m_by_ref = ast::expl(ast::by_ref); let m_by_ref = ast::expl(ast::by_ref);
let mut temp_cleanups = ~[]; let mut temp_cleanups = ~[];
@@ -59,7 +59,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result {
fn trans_method_callee(bcx: block, callee_id: ast::node_id, fn trans_method_callee(bcx: block, callee_id: ast::node_id,
self: @ast::expr, mentry: typeck::method_map_entry) self: @ast::expr, mentry: typeck::method_map_entry)
-> lval_maybe_callee { -> lval_maybe_callee {
let _icx = bcx.insn_ctxt(~"impl::trans_method_callee"); let _icx = bcx.insn_ctxt("impl::trans_method_callee");
match mentry.origin { match mentry.origin {
typeck::method_static(did) => { typeck::method_static(did) => {
let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs); let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs);
@@ -89,7 +89,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
fn trans_static_method_callee(bcx: block, method_id: ast::def_id, fn trans_static_method_callee(bcx: block, method_id: ast::def_id,
callee_id: ast::node_id) -> lval_maybe_callee { callee_id: ast::node_id) -> lval_maybe_callee {
let _icx = bcx.insn_ctxt(~"impl::trans_static_method_callee"); let _icx = bcx.insn_ctxt("impl::trans_static_method_callee");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let mname = if method_id.crate == ast::local_crate { let mname = if method_id.crate == ast::local_crate {
@@ -175,7 +175,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
trait_id: ast::def_id, n_method: uint, trait_id: ast::def_id, n_method: uint,
vtbl: typeck::vtable_origin) vtbl: typeck::vtable_origin)
-> lval_maybe_callee { -> lval_maybe_callee {
let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee"); let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee");
match vtbl { match vtbl {
typeck::vtable_static(impl_did, impl_substs, sub_origins) => { typeck::vtable_static(impl_did, impl_substs, sub_origins) => {
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@@ -210,7 +210,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
fn trans_trait_callee(bcx: block, val: ValueRef, fn trans_trait_callee(bcx: block, val: ValueRef,
callee_ty: ty::t, n_method: uint) callee_ty: ty::t, n_method: uint)
-> lval_maybe_callee { -> lval_maybe_callee {
let _icx = bcx.insn_ctxt(~"impl::trans_trait_callee"); let _icx = bcx.insn_ctxt("impl::trans_trait_callee");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, ~[0u, 0u]), let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, ~[0u, 0u]),
T_ptr(T_ptr(T_vtable())))); T_ptr(T_ptr(T_vtable()))));
@@ -299,7 +299,7 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin)
} }
fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
let _icx = ccx.insn_ctxt(~"impl::make_vtable"); let _icx = ccx.insn_ctxt("impl::make_vtable");
let tbl = C_struct(ptrs); let tbl = C_struct(ptrs);
let vt_gvar = str::as_c_str(ccx.names(~"vtable"), |buf| { let vt_gvar = str::as_c_str(ccx.names(~"vtable"), |buf| {
llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf) llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf)
@@ -312,7 +312,7 @@ fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
vtables: typeck::vtable_res) -> ValueRef { vtables: typeck::vtable_res) -> ValueRef {
let _icx = ccx.insn_ctxt(~"impl::make_impl_vtable"); let _icx = ccx.insn_ctxt("impl::make_impl_vtable");
let tcx = ccx.tcx; let tcx = ccx.tcx;
// XXX: This should support multiple traits. // XXX: This should support multiple traits.
@@ -345,7 +345,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest)
-> block { -> block {
let _icx = bcx.insn_ctxt(~"impl::trans_cast"); let _icx = bcx.insn_ctxt("impl::trans_cast");
if dest == ignore { return trans_expr(bcx, val, ignore); } if dest == ignore { return trans_expr(bcx, val, ignore); }
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let v_ty = expr_ty(bcx, val); let v_ty = expr_ty(bcx, val);

View File

@@ -32,7 +32,7 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
} }
fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef { fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt(~"tvec::get_fill"); let _icx = bcx.insn_ctxt("tvec::get_fill");
Load(bcx, GEPi(bcx, vptr, ~[0u, abi::vec_elt_fill])) Load(bcx, GEPi(bcx, vptr, ~[0u, abi::vec_elt_fill]))
} }
fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) { fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) {
@@ -48,12 +48,12 @@ fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef {
fn get_dataptr(bcx: block, vptr: ValueRef) fn get_dataptr(bcx: block, vptr: ValueRef)
-> ValueRef { -> ValueRef {
let _icx = bcx.insn_ctxt(~"tvec::get_dataptr"); let _icx = bcx.insn_ctxt("tvec::get_dataptr");
GEPi(bcx, vptr, ~[0u, abi::vec_elt_elems, 0u]) GEPi(bcx, vptr, ~[0u, abi::vec_elt_elems, 0u])
} }
fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt(~"tvec::pointer_add"); let _icx = bcx.insn_ctxt("tvec::pointer_add");
let old_ty = val_ty(ptr); let old_ty = val_ty(ptr);
let bptr = PointerCast(bcx, ptr, T_ptr(T_i8())); let bptr = PointerCast(bcx, ptr, T_ptr(T_i8()));
return PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty); return PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty);
@@ -61,7 +61,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
fn alloc_raw(bcx: block, unit_ty: ty::t, fn alloc_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef, heap: heap) -> result { fill: ValueRef, alloc: ValueRef, heap: heap) -> result {
let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let _icx = bcx.insn_ctxt("tvec::alloc_uniq");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty);
@@ -79,7 +79,7 @@ fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
} }
fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result {
let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let _icx = bcx.insn_ctxt("tvec::alloc_uniq");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let llunitty = type_of::type_of(ccx, unit_ty); let llunitty = type_of::type_of(ccx, unit_ty);
let unit_sz = llsize_of(ccx, llunitty); let unit_sz = llsize_of(ccx, llunitty);
@@ -92,7 +92,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result {
} }
fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
let _icx = bcx.insn_ctxt(~"tvec::duplicate_uniq"); let _icx = bcx.insn_ctxt("tvec::duplicate_uniq");
let fill = get_fill(bcx, get_bodyptr(bcx, vptr)); let fill = get_fill(bcx, get_bodyptr(bcx, vptr));
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
@@ -110,7 +110,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
block { block {
let _icx = bcx.insn_ctxt(~"tvec::make_drop_glue_unboxed"); let _icx = bcx.insn_ctxt("tvec::make_drop_glue_unboxed");
let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty); let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty);
if ty::type_needs_drop(tcx, unit_ty) { if ty::type_needs_drop(tcx, unit_ty) {
iter_vec_unboxed(bcx, vptr, vec_ty, base::drop_ty) iter_vec_unboxed(bcx, vptr, vec_ty, base::drop_ty)
@@ -124,7 +124,7 @@ enum evec_elements {
fn trans_evec(bcx: block, elements: evec_elements, fn trans_evec(bcx: block, elements: evec_elements,
vst: ast::vstore, id: ast::node_id, dest: dest) -> block { vst: ast::vstore, id: ast::node_id, dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"tvec::trans_evec"); let _icx = bcx.insn_ctxt("tvec::trans_evec");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let mut bcx = bcx; let mut bcx = bcx;
@@ -318,7 +318,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t)
fn trans_estr(bcx: block, s: @~str, vstore: option<ast::vstore>, fn trans_estr(bcx: block, s: @~str, vstore: option<ast::vstore>,
dest: dest) -> block { dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"tvec::trans_estr"); let _icx = bcx.insn_ctxt("tvec::trans_estr");
if dest == base::ignore { return bcx; } if dest == base::ignore { return bcx; }
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@@ -362,7 +362,7 @@ type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block { fill: ValueRef, f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt(~"tvec::iter_vec_raw"); let _icx = bcx.insn_ctxt("tvec::iter_vec_raw");
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
@@ -393,14 +393,14 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t, fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block { fill: ValueRef, f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt(~"tvec::iter_vec_uniq"); let _icx = bcx.insn_ctxt("tvec::iter_vec_uniq");
let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr)); let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr));
iter_vec_raw(bcx, data_ptr, vec_ty, fill, f) iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
} }
fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
f: iter_vec_block) -> block { f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt(~"tvec::iter_vec_unboxed"); let _icx = bcx.insn_ctxt("tvec::iter_vec_unboxed");
let fill = get_fill(bcx, body_ptr); let fill = get_fill(bcx, body_ptr);
let dataptr = get_dataptr(bcx, body_ptr); let dataptr = get_dataptr(bcx, body_ptr);
return iter_vec_raw(bcx, dataptr, vec_ty, fill, f); return iter_vec_raw(bcx, dataptr, vec_ty, fill, f);

View File

@@ -9,7 +9,7 @@ export make_free_glue, autoderef, duplicate;
fn make_free_glue(bcx: block, vptrptr: ValueRef, t: ty::t) fn make_free_glue(bcx: block, vptrptr: ValueRef, t: ty::t)
-> block { -> block {
let _icx = bcx.insn_ctxt(~"uniq::make_free_glue"); let _icx = bcx.insn_ctxt("uniq::make_free_glue");
let vptr = Load(bcx, vptrptr); let vptr = Load(bcx, vptrptr);
do with_cond(bcx, IsNotNull(bcx, vptr)) |bcx| { do with_cond(bcx, IsNotNull(bcx, vptr)) |bcx| {
let content_ty = content_ty(t); let content_ty = content_ty(t);
@@ -33,7 +33,7 @@ fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} {
} }
fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result {
let _icx = bcx.insn_ctxt(~"uniq::duplicate"); let _icx = bcx.insn_ctxt("uniq::duplicate");
let content_ty = content_ty(t); let content_ty = content_ty(t);
let {bcx: bcx, box: dst_box, body: dst_body} = let {bcx: bcx, box: dst_box, body: dst_body} =
malloc_unique(bcx, content_ty); malloc_unique(bcx, content_ty);