llvm.org GIT mirror llvm / 1d21395
Tests for the instruction iterator bindings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48775 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 12 years ago
1 changed file(s) with 35 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
704704 end
705705
706706
707 (*===-- Instructions ------------------------------------------------------===*)
708
709 let test_instructions () =
710 begin group "iteration";
711 let m = create_module "temp" in
712 let fty = function_type void_type [| i32_type; i32_type |] in
713 let f = define_function "f" fty m in
714 let bb = entry_block f in
715 let b = builder_at (At_end bb) in
716
717 insist (At_end bb = instr_begin bb);
718 insist (At_start bb = instr_end bb);
719
720 let i1 = build_add (param f 0) (param f 1) "One" b in
721 let i2 = build_sub (param f 0) (param f 1) "Two" b in
722
723 insist (Before i1 = instr_begin bb);
724 insist (Before i2 = instr_succ i1);
725 insist (At_end bb = instr_succ i2);
726
727 insist (After i2 = instr_end bb);
728 insist (After i1 = instr_pred i2);
729 insist (At_start bb = instr_pred i1);
730
731 let lf s x = s ^ "->" ^ value_name x in
732 insist ("->One->Two" = fold_left_instrs lf "" bb);
733
734 let rf x s = value_name x ^ "<-" ^ s in
735 insist ("One<-Two<-" = fold_right_instrs rf bb "");
736
737 dispose_module m
738 end
739
740
707741 (*===-- Builder -----------------------------------------------------------===*)
708742
709743 let test_builder () =
10231057 suite "functions" test_functions;
10241058 suite "params" test_params;
10251059 suite "basic blocks" test_basic_blocks;
1060 suite "instructions" test_instructions;
10261061 suite "builder" test_builder;
10271062 suite "module provider" test_module_provider;
10281063 suite "pass manager" test_pass_manager;