aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kvx/lib/PrepassSchedulingOracle.ml15
-rw-r--r--kvx/lib/RTLpathScheduleraux.ml19
-rw-r--r--test/monniaux/rules.mk2
3 files changed, 27 insertions, 9 deletions
diff --git a/kvx/lib/PrepassSchedulingOracle.ml b/kvx/lib/PrepassSchedulingOracle.ml
index eec2d9b5..5a48924e 100644
--- a/kvx/lib/PrepassSchedulingOracle.ml
+++ b/kvx/lib/PrepassSchedulingOracle.ml
@@ -19,7 +19,7 @@ let length_of_chunk = function
| Mfloat64
| Many64 -> 8;;
-let get_simple_dependencies (seqa : instruction array) =
+let get_simple_dependencies (seqa : (instruction*Regset.t) array) =
let last_reg_reads : int list PTree.t ref = ref PTree.empty
and last_reg_write : (int*int) PTree.t ref = ref PTree.empty
and last_mem_reads : int list ref = ref []
@@ -123,7 +123,12 @@ let get_simple_dependencies (seqa : instruction array) =
in
Array.iteri
begin
- fun i insn ->
+ fun i (insn, other_uses) ->
+ List.iter (fun use ->
+ print_endline "add other use";
+ add_input_reg i use)
+ (Regset.elements other_uses);
+
match insn with
| Inop _ -> ()
| Iop(op, inputs, output, _) ->
@@ -384,13 +389,13 @@ let define_problem seqa =
let simple_deps = get_simple_dependencies seqa in
{ max_latency = -1;
resource_bounds = OpWeights.resource_bounds;
- instruction_usages = Array.map resources_of_instruction seqa;
+ instruction_usages = Array.map resources_of_instruction (Array.map fst seqa);
latency_constraints =
(* if (use_alias_analysis ())
then (get_alias_dependencies seqa) @ simple_deps
else *) simple_deps };;
-let schedule_sequence (seqa : instruction array) =
+let schedule_sequence (seqa : (instruction*Regset.t) array) =
try
if (Array.length seqa) <= 1
then None
@@ -399,7 +404,7 @@ let schedule_sequence (seqa : instruction array) =
let nr_instructions = Array.length seqa in
Printf.printf "prepass scheduling length = %d\n" (Array.length seqa);
let problem = define_problem seqa in
- print_sequence stdout seqa;
+ print_sequence stdout (Array.map fst seqa);
print_problem stdout problem;
match reverse_list_scheduler problem
(* scheduler_by_name !Clflags.option_fprepass_sched problem *) with
diff --git a/kvx/lib/RTLpathScheduleraux.ml b/kvx/lib/RTLpathScheduleraux.ml
index 32fb2c2a..97de1a12 100644
--- a/kvx/lib/RTLpathScheduleraux.ml
+++ b/kvx/lib/RTLpathScheduleraux.ml
@@ -103,13 +103,26 @@ let schedule_superblock sb code =
print_endline "ORIGINAL SUPERBLOCK";
print_superblock sb code;
debug_flag := old_flag;
+ let nr_instr = Array.length sb.instructions in
+ let trailer_length =
+ match PTree.get (sb.instructions.(nr_instr-1)) code with
+ | Some (Ireturn _ | Itailcall _ | Ijumptable _) -> 1
+ | _ -> 0 in
match PrepassSchedulingOracle.schedule_sequence
(Array.map (fun i ->
- match PTree.get i code with Some ii -> ii | None -> failwith "RTLpathScheduleraux.schedule_superblock")
- sb.instructions) with
+ (match PTree.get i code with
+ | Some ii -> ii
+ | None -> failwith "RTLpathScheduleraux.schedule_superblock"),
+ (match PTree.get i sb.liveins with
+ | Some s -> s
+ | None -> Regset.empty))
+ (Array.sub sb.instructions 0 (nr_instr-trailer_length))) with
| None -> sb.instructions
| Some order ->
- let ins' = Array.map (fun i -> sb.instructions.(i)) order in
+ let ins' =
+ Array.append
+ (Array.map (fun i -> sb.instructions.(i)) order)
+ (Array.sub sb.instructions (nr_instr-trailer_length) trailer_length) in
Printf.printf "REORDERED SUPERBLOCK %d\n" (Array.length ins');
debug_flag := true;
print_instructions (Array.to_list ins') code;
diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk
index c0594ef9..95d57f80 100644
--- a/test/monniaux/rules.mk
+++ b/test/monniaux/rules.mk
@@ -21,7 +21,7 @@ MEASURES?=time
ALL_CFLAGS+=-Wall -D__KVX_COS__ -DMAX_MEASURES=$(MAX_MEASURES)
#ALL_CFLAGS+=-g
ALL_GCCFLAGS+=$(ALL_CFLAGS) -std=c99 -Wextra -Werror=implicit
-ALL_CCOMPFLAGS+=$(ALL_CFLAGS)
+ALL_CCOMPFLAGS+=$(ALL_CFLAGS) -fprepass
# The compilers
KVX_CC?=kvx-cos-gcc