aboutsummaryrefslogtreecommitdiffstats
path: root/aarch64/OpWeightsAsm.ml
blob: 17869a99220783d6a1db855ecf513c3431bbcfba (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
open Asmblock;;
(* TODO remove? open PrepassSchedulingOracleDeps;;*)

module Cortex_A53=
  struct
    let resource_bounds = [| 2; 2; 1; 1 |];; (* instr ; ALU ; MAC; LSU *)
    let nr_non_pipelined_units = 1;;

    let latency_of_op (i : basic) (nargs : int) =
      match i with
      | PArith _
        | PArithP _ _ -> 1 (* XXX *)
        | PArithPP
    
    let resources_of_op (op : operation) (nargs : int) =
      match op with
      | Omove 
        | Ointconst _
        | Olongconst _
        | Ofloatconst _
        | Osingleconst _
        | Oaddrsymbol _
        | Oaddrstack _
        (* 32-bit integer arithmetic *)
        | Oshift _
        | Oadd 
        | Oaddshift _
        | Oaddimm _
        | Oneg         
        | Onegshift _
        | Osub
        | Osubshift _ -> [| 1 ; 1; 0; 0 |]
      | Omul 
        | Omuladd
        | Omulsub -> [| 1; 1; 1; 0 |]
      | Odiv 
        | Odivu -> [| 1; 0; 0; 0 |]
      | Oand 
        | Oandshift _
        | Oandimm _
        | Oor
        | Oorshift _
        | Oorimm _
        | Oxor
        | Oxorshift _
        | Oxorimm _
        | Onot
        | Onotshift _
        | Obic
        | Obicshift _
        | Oorn
        | Oornshift _
        | Oeqv
        | Oeqvshift _
        | Oshl
        | Oshr
        | Oshru
        | Oshrximm _
        | Ozext _
        | Osext  _
        | Oshlzext _
        | Oshlsext _
        | Ozextshr _
        | Osextshr _
  
(* 64-bit integer arithmetic *)
        | Oshiftl _
        | Oextend _
        | Omakelong
        | Olowlong 
        | Ohighlong
        | Oaddl 
        | Oaddlshift _
        | Oaddlext _
        | Oaddlimm _
        | Onegl        
        | Oneglshift _
        | Osubl
        | Osublshift _
        | Osublext _ -> [| 1 ; 1 ; 0; 0 |]
      | Omull 
        | Omulladd 
        | Omullsub
        | Omullhs 
        | Omullhu -> [| 1 ; 1 ; 1; 0 |]
      | Odivl 
        | Odivlu -> [| 1; 0; 0; 0 |]
      | Oandl 
        | Oandlshift _
        | Oandlimm _
        | Oorl
        | Oorlshift _
        | Oorlimm _
        | Oxorl
        | Oxorlshift _
        | Oxorlimm _
        | Onotl
        | Onotlshift _
        | Obicl
        | Obiclshift _
        | Oornl
        | Oornlshift _
        | Oeqvl
        | Oeqvlshift _
        | Oshll
        | Oshrl
        | Oshrlu 
        | Oshrlximm _
        | Ozextl _
        | Osextl _
        | Oshllzext _
        | Oshllsext _
        | Ozextshrl _
        | Osextshrl _ -> [| 1; 1; 0; 0 |]
      (* 64-bit floating-point arithmetic *)
      | Onegf                                               (* r [rd = - r1] *)
        | Oabsf                                               (* r [rd = abs(r1)] *)
        | Oaddf                                               (* r [rd = r1 + r2] *)
        | Osubf                                               (* r [rd = r1 - r2] *)
        | Omulf                                               (* r [rd = r1 * r2] *)
        | Odivf
        (* 32-bit floating-point arithmetic *)
        | Onegfs                                              (* r [rd = - r1] *)
        | Oabsfs                                              (* r [rd = abs(r1)] *)
        | Oaddfs                                              (* r [rd = r1 + r2] *)
        | Osubfs                                              (* r [rd = r1 - r2] *)
        | Omulfs                                              (* r [rd = r1 * r2] *)
        | Odivfs                                              (* r [rd = r1 / r2] *)
        | Osingleoffloat                                      (* r [rd] is [r1] truncated to single-precision float *)
        | Ofloatofsingle                                      (* r [rd] is [r1] extended to double-precision float *)
(*  Conversions between int and float *)
        | Ointoffloat                                         (* r [rd = signed_int_of_float64(r1)] *)
        | Ointuoffloat                                        (* r [rd = unsigned_int_of_float64(r1)] *)
        | Ofloatofint                                         (* r [rd = float64_of_signed_int(r1)] *)
        | Ofloatofintu                                        (* r [rd = float64_of_unsigned_int(r1)] *)
        | Ointofsingle                                        (* r [rd = signed_int_of_float32(r1)] *)
        | Ointuofsingle                                       (* r [rd = unsigned_int_of_float32(r1)] *)
        | Osingleofint                                        (* r [rd = float32_of_signed_int(r1)] *)
        | Osingleofintu                                       (* r [rd = float32_of_unsigned_int(r1)] *)
        | Olongoffloat                                        (* r [rd = signed_long_of_float64(r1)] *)
        | Olonguoffloat                                       (* r [rd = unsigned_long_of_float64(r1)] *)
        | Ofloatoflong                                        (* r [rd = float64_of_signed_long(r1)] *)
        | Ofloatoflongu                                       (* r [rd = float64_of_unsigned_long(r1)] *)
        | Olongofsingle                                       (* r [rd = signed_long_of_float32(r1)] *)
        | Olonguofsingle                                      (* r [rd = unsigned_long_of_float32(r1)] *)
        | Osingleoflong                                       (* r [rd = float32_of_signed_long(r1)] *)
        | Osingleoflongu                                      (* r [rd = float32_of_unsigned_int(r1)] *)
        -> [| 1 ; 1; 1; 0 |]
         
(* Boolean tests *)
      | Ocmp cmp | Osel (cmp, _) ->
         (match cmp with
          | Ccompf _                              (* r FP comparison *)
            | Cnotcompf _                           (* r negation of an FP comparison *)
            | Ccompfzero _                          (* r comparison with 0.0 *)
            | Cnotcompfzero _                       (* r negation of comparison with 0.0 *)
            | Ccompfs _                             (* r FP comparison *)
            | Cnotcompfs _                          (* r negation of an FP comparison *)
            | Ccompfszero _                         (* r equal to 0.0 *)
            | Cnotcompfszero _                     (* r not equal to 0.0 *) ->
             [| 1; 1; 1; 0 |]
          | _ -> [| 1; 1; 0; 0 |] );;
    
    let non_pipelined_resources_of_op (op : operation) (nargs : int) =
      match op with
      | Odiv | Odivu -> [| 29 |]
      | Odivfs -> [| 20 |]
      | Odivl | Odivlu | Odivf -> [| 50 |]
      | _ -> [| -1 |];;
    
    let resources_of_cond (cmp : condition) (nargs : int) =
      (match cmp with
       | Ccompf _                              (* r FP comparison *)
         | Cnotcompf _                           (* r negation of an FP comparison *)
         | Ccompfzero _                          (* r comparison with 0.0 *)
         | Cnotcompfzero _                       (* r negation of comparison with 0.0 *)
         | Ccompfs _                             (* r FP comparison *)
         | Cnotcompfs _                          (* r negation of an FP comparison *)
         | Ccompfszero _                         (* r equal to 0.0 *)
         | Cnotcompfszero _                     (* r not equal to 0.0 *) ->
          [| 1; 1; 1; 0 |]
       | _ -> [| 1; 1; 0; 0 |] );;
    
    let latency_of_load trap chunk (addr : addressing) (nargs : int) = 3;;
    let latency_of_call _ _ = 6;;
    
    let resources_of_load trap chunk addressing nargs = [| 1; 0; 0; 1 |];;
    
    let resources_of_store chunk addressing nargs = [| 1; 0; 0; 1 |];;
    
    let resources_of_call _ _ = resource_bounds;;
    let resources_of_builtin _ = resource_bounds;;
  end;;

let get_opweights () : opweights =
  match !Clflags.option_mtune with
  | "cortex-a53" | "cortex-a35" | "" ->
     {
       pipelined_resource_bounds = Cortex_A53.resource_bounds;
       nr_non_pipelined_units = Cortex_A53.nr_non_pipelined_units;
       latency_of_op = Cortex_A53.latency_of_op;
       resources_of_op = Cortex_A53.resources_of_op;
       non_pipelined_resources_of_op = Cortex_A53.non_pipelined_resources_of_op;
       latency_of_load = Cortex_A53.latency_of_load;
       resources_of_load = Cortex_A53.resources_of_load;
       resources_of_store = Cortex_A53.resources_of_store;
       resources_of_cond = Cortex_A53.resources_of_cond;
       latency_of_call = Cortex_A53.latency_of_call;
       resources_of_call = Cortex_A53.resources_of_call;
       resources_of_builtin = Cortex_A53.resources_of_builtin
     }
  | xxx -> failwith (Printf.sprintf "unknown -mtune: %s" xxx);;