Skip to content

Commit 602ae91

Browse files
nikomatsakisbrson
authored andcommitted
convert various ints to i32 and vice versa
1 parent 4bd05e5 commit 602ae91

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/comp/middle/trans.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -935,20 +935,15 @@ fn trans_stack_local_derived_tydesc(cx: @block_ctxt, llsz: ValueRef,
935935
// Store a pointer to the rest of the descriptors.
936936
let ccx = bcx_ccx(cx);
937937
store_inbounds(cx, llfirstparam, llmyroottydesc,
938-
[C_int(ccx, 0),
939-
C_int(ccx, abi::tydesc_field_first_param)]);
938+
[0, abi::tydesc_field_first_param]);
940939
store_inbounds(cx, C_uint(ccx, n_params), llmyroottydesc,
941-
[C_int(ccx, 0),
942-
C_int(ccx, abi::tydesc_field_n_params)]);
940+
[0, abi::tydesc_field_n_params]);
943941
store_inbounds(cx, llsz, llmyroottydesc,
944-
[C_int(ccx, 0),
945-
C_int(ccx, abi::tydesc_field_size)]);
942+
[0, abi::tydesc_field_size]);
946943
store_inbounds(cx, llalign, llmyroottydesc,
947-
[C_int(ccx, 0),
948-
C_int(ccx, abi::tydesc_field_align)]);
944+
[0, abi::tydesc_field_align]);
949945
store_inbounds(cx, C_uint(ccx, obj_params), llmyroottydesc,
950-
[C_int(ccx, 0),
951-
C_int(ccx, abi::tydesc_field_obj_params)]);
946+
[0, abi::tydesc_field_obj_params]);
952947
ret llmyroottydesc;
953948
}
954949

@@ -1618,8 +1613,8 @@ fn load_inbounds(cx: @block_ctxt, p: ValueRef, idxs: [ValueRef]) -> ValueRef {
16181613
}
16191614

16201615
fn store_inbounds(cx: @block_ctxt, v: ValueRef, p: ValueRef,
1621-
idxs: [ValueRef]) {
1622-
Store(cx, v, InBoundsGEP(cx, p, idxs));
1616+
idxs: [int]) {
1617+
Store(cx, v, GEPi(cx, p, idxs));
16231618
}
16241619

16251620
// Iterates through the elements of a structural type.
@@ -1975,16 +1970,20 @@ fn call_memmove(cx: @block_ctxt, dst: ValueRef, src: ValueRef,
19751970
// LLVM complains -- not even a constant element of a tydesc works).
19761971

19771972
let ccx = bcx_ccx(cx);
1973+
let key = alt ccx.sess.get_targ_cfg().arch {
1974+
session::arch_x86. | session::arch_arm. { "llvm.memmove.p0i8.p0i8.i32" }
1975+
session::arch_x86_64. { "llvm.memmove.p0i8.p0i8.i64" }
1976+
};
19781977
let i = ccx.intrinsics;
1979-
assert (i.contains_key("llvm.memmove.p0i8.p0i8.i32"));
1980-
let memmove = i.get("llvm.memmove.p0i8.p0i8.i32");
1978+
assert (i.contains_key(key));
1979+
let memmove = i.get(key);
19811980
let src_ptr = PointerCast(cx, src, T_ptr(T_i8()));
19821981
let dst_ptr = PointerCast(cx, dst, T_ptr(T_i8()));
1983-
let size = IntCast(cx, n_bytes, T_i32());
1984-
let align = C_int(ccx, 1);
1982+
let size = IntCast(cx, n_bytes, ccx.int_type);
1983+
let align = C_i32(1i32);
19851984
let volatile = C_bool(false);
1986-
ret rslt(cx,
1987-
Call(cx, memmove, [dst_ptr, src_ptr, size, align, volatile]));
1985+
let ret_val = Call(cx, memmove, [dst_ptr, src_ptr, size, align, volatile]);
1986+
ret rslt(cx, ret_val);
19881987
}
19891988

19901989
fn call_bzero(cx: @block_ctxt, dst: ValueRef, n_bytes: ValueRef,
@@ -3872,8 +3871,7 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38723871
let i = 0u, n = vec::len(llargs);
38733872
while i < n {
38743873
let llarg = llargs[i].llval;
3875-
store_inbounds(bcx, llarg, llargbundle, [C_int(ccx, 0),
3876-
C_uint(ccx, i)]);
3874+
store_inbounds(bcx, llarg, llargbundle, [0, i as int]);
38773875
i += 1u;
38783876
}
38793877

@@ -4408,8 +4406,10 @@ fn trans_log(lvl: int, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
44084406
let llvalptr = r.val;
44094407
let llval_i8 = PointerCast(log_bcx, llvalptr, T_ptr(T_i8()));
44104408

4409+
// FIXME lvl should not be int, but actually u32,
4410+
// and the upcall should take a u32, not an i32
44114411
Call(log_bcx, ccx.upcalls.log_type,
4412-
[lltydesc, llval_i8, C_int(ccx, lvl)]);
4412+
[lltydesc, llval_i8, C_i32(lvl as i32)]);
44134413

44144414
log_bcx = trans_block_cleanups(log_bcx, log_cx);
44154415
Br(log_bcx, after_cx.llbb);
@@ -5206,7 +5206,7 @@ fn trans_res_ctor(cx: @local_ctxt, sp: span, dtor: ast::_fn,
52065206
check type_is_tup_like(bcx, tup_t);
52075207
let flag = GEP_tup_like(bcx, tup_t, llretptr, [0, 0]);
52085208
bcx = flag.bcx;
5209-
Store(bcx, C_int(ccx, 1), flag.val);
5209+
Store(bcx, C_i32(1), flag.val);
52105210
build_return(bcx);
52115211
finish_fn(fcx, lltop);
52125212
}

0 commit comments

Comments
 (0)