aboutsummaryrefslogtreecommitdiffstats
path: root/kvx/OpWeights.ml
blob: 4c3c40d07bf61ebfc8b73cdcf12d3f21e47fd19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
open Op;;
open PostpassSchedulingOracle;;
let resource_bounds = PostpassSchedulingOracle.resource_bounds;;


let rec nlist_rec x l = function
  | 0 -> l
  | n when n > 0 -> nlist_rec x (x :: l) (n-1)
  | _ -> failwith "nlist_rec";;
let nlist x n = nlist_rec x [] n;;

let bogus_register = Machregs.R0;;
let bogus_inputs n = nlist bogus_register n;;

let insns_of_op (op : operation) (nargs : int) =
  match Asmblockgen.transl_op op
          (bogus_inputs nargs) bogus_register [] with
  | Errors.Error msg -> failwith "OpWeights.insns_of_op"
  | Errors.OK insns -> insns;;

let insn_of_op op nargs =
  match insns_of_op op nargs with
  | [] -> failwith "OpWeights.insn_of_op"
  | h::_ -> h;;

let insns_of_cond (cond : condition) (nargs : int) =
  match Asmblockgen.transl_cond_op cond
           Asmvliw.GPR0 (bogus_inputs nargs) [] with
  | Errors.Error msg -> failwith "OpWeights.insns_of_cond"
  | Errors.OK insns -> insns;;

let insn_of_cond cond nargs =
  match insns_of_cond cond nargs with
  | [] -> failwith "OpWeights.insn_of_cond"
  | h::_ -> h;;

let insns_of_load trap chunk addressing (nargs : int) =
  match Asmblockgen.transl_load trap chunk addressing
          (bogus_inputs nargs) bogus_register [] with
  | Errors.Error msg -> failwith "OpWeights.insns_of_load"
  | Errors.OK insns -> insns;;

let insn_of_load trap chunk addressing nargs =
  match insns_of_load trap chunk addressing nargs with
  | [] -> failwith "OpWeights.insn_of_load"
  | h::_ -> h;;

let insns_of_store chunk addressing (nargs : int) =
  match Asmblockgen.transl_store chunk addressing
          (bogus_inputs nargs) bogus_register [] with
  | Errors.Error msg -> failwith "OpWeights.insns_of_store"
  | Errors.OK insns -> insns;;

let insn_of_store chunk addressing nargs =
  match insns_of_store chunk addressing nargs with
  | [] -> failwith "OpWeights.insn_of_store"
  | h::_ -> h;;

let latency_of_op (op : operation) (nargs : int) =
  let insn = insn_of_op op nargs in
  let record = basic_rec insn in
  let latency = real_inst_to_latency record.inst in
  latency;;

let resources_of_op (op : operation) (nargs : int) =
  let insn = insn_of_op op nargs in
  let record = basic_rec insn in
  rec_to_usage record;;

let resources_of_cond (cond : condition) (nargs : int) =
  let insn = insn_of_cond cond nargs in
  let record = basic_rec insn in
  rec_to_usage record;;

let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
let latency_of_call _ _ = 6;;

let resources_of_load trap chunk addressing nargs =
  let insn = insn_of_load trap chunk addressing nargs in
  let record = basic_rec insn in
  rec_to_usage record;;

let resources_of_store chunk addressing nargs =
  let insn = insn_of_store chunk addressing nargs in
  let record = basic_rec insn in
  rec_to_usage record;;

let resources_of_call _ _ = resource_bounds;;
let resources_of_builtin _ = resource_bounds;;