Skip to content

Commit 4467d76

Browse files
committed
Merge branch 'master' of git://github.com/graydon/rust
Conflicts: src/boot/fe/ast.ml
2 parents b1c86be + bd7835e commit 4467d76

21 files changed

+410
-147
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Jeff Mulzelaar <[email protected]>
1515
Jeffrey Yasskin <[email protected]>
1616
Matt Brubeck <[email protected]>
1717
Michael Bebenita <[email protected]>
18+
Or Brostovski <[email protected]>
1819
Patrick Walton <[email protected]>
1920
Ralph Giles <[email protected]>
2021
Roy Frostig <[email protected]>

src/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,13 @@ TEST_XFAILS_X86 := $(TASK_XFAILS) \
389389
test/run-pass/child-outlives-parent.rs \
390390
test/run-pass/clone-with-exterior.rs \
391391
test/run-pass/constrained-type.rs \
392+
test/run-pass/destructor-ordering.rs \
392393
test/run-pass/obj-as.rs \
393394
test/run-pass/vec-slice.rs \
394395
test/run-pass/fn-lval.rs \
395396
test/run-pass/generic-fn-infer.rs \
396397
test/run-pass/generic-recursive-tag.rs \
398+
test/run-pass/int-lib.rs \
397399
test/run-pass/iter-ret.rs \
398400
test/run-pass/lib-deque.rs \
399401
test/run-pass/lib-map.rs \
@@ -418,7 +420,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
418420
alt-tag.rs \
419421
arithmetic-interference.rs \
420422
argv.rs \
421-
auto-deref.rs \
422423
autoderef-full-lval.rs \
423424
autoderef-objfn.rs \
424425
basic.rs \
@@ -452,7 +453,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
452453
generic-drop-glue.rs \
453454
generic-exterior-box.rs \
454455
generic-fn-infer.rs \
455-
generic-fn-twice.rs \
456456
generic-fn.rs \
457457
generic-obj-with-derived-type.rs \
458458
generic-obj.rs \
@@ -464,6 +464,8 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
464464
i8-incr.rs \
465465
import.rs \
466466
inner-module.rs \
467+
integral-indexing.rs \
468+
int-lib.rs \
467469
iter-range.rs \
468470
iter-ret.rs \
469471
large-records.rs \
@@ -481,8 +483,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
481483
mutable-alias-vec.rs \
482484
mutable-vec-drop.rs \
483485
mutual-recursion-group.rs \
484-
native-mod.rc \
485-
native.rc \
486486
obj-as.rs \
487487
obj-drop.rs \
488488
obj-dtor.rs \
@@ -506,6 +506,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
506506
str-append.rs \
507507
str-concat.rs \
508508
str-idx.rs \
509+
str-lib.rs \
509510
tag.rs \
510511
tail-cps.rs \
511512
tail-direct.rs \

src/boot/be/il.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ type emitter = { mutable emit_pc: int;
695695
emit_target_specific: (emitter -> quad -> unit);
696696
mutable emit_quads: quads;
697697
emit_annotations: (int,string) Hashtbl.t;
698-
emit_size_cache: ((size,operand) Hashtbl.t) Stack.t;
698+
emit_size_cache: (size,operand) Hashtbl.t;
699699
emit_node: node_id option;
700700
}
701701

@@ -722,7 +722,7 @@ let new_emitter
722722
emit_target_specific = emit_target_specific;
723723
emit_quads = Array.create 4 badq;
724724
emit_annotations = Hashtbl.create 0;
725-
emit_size_cache = Stack.create ();
725+
emit_size_cache = Hashtbl.create 0;
726726
emit_node = node;
727727
}
728728
;;

src/boot/be/x86.ml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,49 @@ let emit_target_specific
302302
| Il.IMOD | Il.UMOD ->
303303
let dst_eax = hr_like_cell eax dst in
304304
let lhs_eax = hr_like_op eax lhs in
305-
let rhs_ecx = hr_like_op ecx lhs in
306-
if lhs <> (Il.Cell lhs_eax)
307-
then mov lhs_eax lhs;
308-
if rhs <> (Il.Cell rhs_ecx)
309-
then mov rhs_ecx rhs;
305+
let rhs_ecx = hr_like_op ecx rhs in
306+
(* Horrible: we bounce complex mul inputs off spill slots
307+
* to ensure non-interference between the temporaries used
308+
* during mem-base-reg reloads and the registers we're
309+
* preparing. *)
310+
let next_spill_like op =
311+
Il.Mem (Il.next_spill_slot e
312+
(Il.ScalarTy (Il.operand_scalar_ty op)))
313+
in
314+
let is_mem op =
315+
match op with
316+
Il.Cell (Il.Mem _) -> true
317+
| _ -> false
318+
in
319+
let bounce_lhs = is_mem lhs in
320+
let bounce_rhs = is_mem rhs in
321+
let lhs_spill = next_spill_like lhs in
322+
let rhs_spill = next_spill_like rhs in
323+
324+
if bounce_lhs
325+
then mov lhs_spill lhs;
326+
327+
if bounce_rhs
328+
then mov rhs_spill rhs;
329+
330+
mov lhs_eax
331+
(if bounce_lhs
332+
then (Il.Cell lhs_spill)
333+
else lhs);
334+
335+
mov rhs_ecx
336+
(if bounce_rhs
337+
then (Il.Cell rhs_spill)
338+
else rhs);
339+
310340
put (Il.Binary
311341
{ b with
312342
Il.binary_lhs = (Il.Cell lhs_eax);
313343
Il.binary_rhs = (Il.Cell rhs_ecx);
314344
Il.binary_dst = dst_eax; });
315345
if dst <> dst_eax
316346
then mov dst (Il.Cell dst_eax);
317-
347+
318348
| _ when (Il.Cell dst) <> lhs ->
319349
mov dst lhs;
320350
put (Il.Binary
@@ -1936,15 +1966,20 @@ let zero (dst:Il.cell) (count:Il.operand) : Asm.frag =
19361966
;;
19371967

19381968
let mov (signed:bool) (dst:Il.cell) (src:Il.operand) : Asm.frag =
1939-
if is_ty8 (Il.cell_scalar_ty dst) || is_ty8 (Il.operand_scalar_ty src)
1969+
if is_ty8 (Il.cell_scalar_ty dst)
19401970
then
19411971
begin
1942-
(match dst with
1943-
Il.Reg (Il.Hreg r, _)
1944-
-> assert (is_ok_r8 r) | _ -> ());
1945-
(match src with
1946-
Il.Cell (Il.Reg (Il.Hreg r, _))
1947-
-> assert (is_ok_r8 r) | _ -> ());
1972+
match dst with
1973+
Il.Reg (Il.Hreg r, _) -> assert (is_ok_r8 r)
1974+
| _ -> ()
1975+
end;
1976+
1977+
if is_ty8 (Il.operand_scalar_ty src)
1978+
then
1979+
begin
1980+
match src with
1981+
Il.Cell (Il.Reg (Il.Hreg r, _)) -> assert (is_ok_r8 r)
1982+
| _ -> ()
19481983
end;
19491984

19501985
match (signed, dst, src) with

src/boot/fe/item.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ and parse_stmts (ps:pstate) : Ast.stmt array =
253253
let lv = name_to_lval apos bpos name in
254254
Ast.PAT_tag (lv, paren_comma_list parse_pat ps)
255255

256-
| LIT_INT _ | LIT_CHAR _ | LIT_BOOL _ ->
256+
| LIT_INT _
257+
| LIT_UINT _
258+
| LIT_CHAR _
259+
| LIT_BOOL _ ->
257260
Ast.PAT_lit (Pexp.parse_lit ps)
258261

259262
| UNDERSCORE -> bump ps; Ast.PAT_wild

src/boot/fe/pexp.ml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,33 @@ and parse_or_pexp (ps:pstate) : pexp =
817817
step lhs
818818

819819

820+
and parse_as_pexp (ps:pstate) : pexp =
821+
let apos = lexpos ps in
822+
let pexp = ctxt "as pexp" parse_or_pexp ps in
823+
let rec step accum =
824+
match peek ps with
825+
AS ->
826+
bump ps;
827+
let tapos = lexpos ps in
828+
let t = parse_ty ps in
829+
let bpos = lexpos ps in
830+
let t = span ps tapos bpos t in
831+
let node =
832+
span ps apos bpos
833+
(PEXP_unop ((Ast.UNOP_cast t), accum))
834+
in
835+
step node
836+
837+
| _ -> accum
838+
in
839+
step pexp
840+
841+
820842
and parse_relational_pexp (ps:pstate) : pexp =
821843
let name = "relational pexp" in
822844
let apos = lexpos ps in
823-
let lhs = ctxt (name ^ " lhs") parse_or_pexp ps in
824-
let build = binop_build ps name apos parse_or_pexp in
845+
let lhs = ctxt (name ^ " lhs") parse_as_pexp ps in
846+
let build = binop_build ps name apos parse_as_pexp in
825847
let rec step accum =
826848
match peek ps with
827849
LT -> build accum step Ast.BINOP_lt
@@ -883,30 +905,8 @@ and parse_oror_pexp (ps:pstate) : pexp =
883905
step lhs
884906

885907

886-
and parse_as_pexp (ps:pstate) : pexp =
887-
let apos = lexpos ps in
888-
let pexp = ctxt "as pexp" parse_oror_pexp ps in
889-
let rec step accum =
890-
match peek ps with
891-
AS ->
892-
bump ps;
893-
let tapos = lexpos ps in
894-
let t = parse_ty ps in
895-
let bpos = lexpos ps in
896-
let t = span ps tapos bpos t in
897-
let node =
898-
span ps apos bpos
899-
(PEXP_unop ((Ast.UNOP_cast t), accum))
900-
in
901-
step node
902-
903-
| _ -> accum
904-
in
905-
step pexp
906-
907-
908908
and parse_pexp (ps:pstate) : pexp =
909-
parse_as_pexp ps
909+
parse_oror_pexp ps
910910

911911
and parse_mutable_and_pexp (ps:pstate) : (Ast.mutability * pexp) =
912912
let mutability = parse_mutability ps in

src/boot/llvm/lltrans.ml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ let trans_crate
588588
(* Maps a fn's or block's id to an LLVM metadata node (subprogram or
589589
lexical block) representing it. *)
590590
let (dbg_llscopes:(node_id, Llvm.llvalue) Hashtbl.t) = Hashtbl.create 0 in
591-
let declare_mod_item
591+
let rec declare_mod_item
592592
(name:Ast.ident)
593593
mod_item
594594
: unit =
@@ -616,9 +616,8 @@ let trans_crate
616616
| Ast.MOD_ITEM_type _ ->
617617
() (* Types get translated with their terms. *)
618618

619-
| Ast.MOD_ITEM_mod _ ->
620-
() (* Modules simply contain other items that are translated
621-
on their own. *)
619+
| Ast.MOD_ITEM_mod (_, items) ->
620+
Hashtbl.iter declare_mod_item items
622621

623622
| _ ->
624623
Common.unimpl (Some id)
@@ -807,6 +806,17 @@ let trans_crate
807806
Ast.sprintf_lval lval)
808807
in
809808

809+
let trans_callee (fn:Ast.lval) : (Llvm.llvalue * Ast.ty) =
810+
let fty = Hashtbl.find sem_cx.ctxt_all_lval_types (lval_base_id fn) in
811+
if lval_base_is_item sem_cx fn then
812+
let fn_item = lval_item sem_cx fn in
813+
let llfn = Hashtbl.find llitems (fn_item.id) in
814+
(llfn, fty)
815+
else
816+
(* indirect call to computed slot *)
817+
trans_lval fn
818+
in
819+
810820
let trans_atom (atom:Ast.atom) : Llvm.llvalue =
811821
iflog (fun _ -> log sem_cx "trans_atom: %a" Ast.sprintf_atom atom);
812822
match atom with
@@ -959,7 +969,7 @@ let trans_crate
959969
| Ast.STMT_call (dest, fn, args) ->
960970
let llargs = Array.map trans_atom args in
961971
let (lldest, _) = trans_lval dest in
962-
let (llfn, _) = trans_lval fn in
972+
let (llfn, _) = trans_callee fn in
963973
let llallargs = Array.append [| lldest; lltask |] llargs in
964974
let llrv = build_call llfn llallargs "" llbuilder in
965975
Llvm.set_instruction_call_conv Llvm.CallConv.c llrv;
@@ -1072,13 +1082,22 @@ let trans_crate
10721082
ignore (Llvm.build_br llbodyblock llinitbuilder)
10731083
in
10741084

1075-
let trans_mod_item
1076-
(_:Ast.ident)
1077-
{ node = { Ast.decl_item = (item:Ast.mod_item') }; id = id }
1085+
let rec trans_mod_item
1086+
(name:Ast.ident)
1087+
mod_item
10781088
: unit =
1089+
let { node = { Ast.decl_item = (item:Ast.mod_item') }; id = id } =
1090+
mod_item in
10791091
match item with
1080-
Ast.MOD_ITEM_fn fn -> trans_fn fn id
1081-
| _ -> ()
1092+
Ast.MOD_ITEM_type _ ->
1093+
() (* Types get translated with their terms. *)
1094+
| Ast.MOD_ITEM_mod (_, items) ->
1095+
Hashtbl.iter trans_mod_item items
1096+
| Ast.MOD_ITEM_fn fn -> trans_fn fn id
1097+
| _ -> Common.unimpl (Some id)
1098+
"LLVM module declaration for: %a"
1099+
Ast.sprintf_mod_item (name, mod_item)
1100+
10821101
in
10831102

10841103
let exit_task_glue =

0 commit comments

Comments
 (0)