2
* Copyright (c) 2000-2001 Stefan Kral
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
(* This module contains code for hashing vsimdinstrs. This feature is
21
* used extensively in the code optimizer (VK7Optimization) to speedup
22
* the code-optimization process.
27
(* for hashing purposes *)
28
type vsimdinstrcategory =
46
(* vsimdinstr category map *)
47
module VSICMap = Map.Make(struct
48
type t = vsimdinstrcategory
52
let vsicmap_findE k m = try VSICMap.find k m with Not_found -> []
53
let vsicmap_addE k v m = VSICMap.add k (v::(vsicmap_findE k m)) m
55
(****************************************************************************)
57
let vsimdunaryopcategories_chs =
64
let vsimdunaryopcategories_nocopy =
65
VSIC_UnarySwap::VSIC_UnaryMulConst::vsimdunaryopcategories_chs
67
let vsimdunaryopcategories_all =
68
VSIC_UnaryCopy::vsimdunaryopcategories_nocopy
70
let vsimdbinopcategories_par = [VSIC_BinAdd; VSIC_BinSub; VSIC_BinMul]
72
let vsimdbinopcategories_all =
73
vsimdbinopcategories_par @
82
let vsimdallcategories =
83
[VSIC_Load; VSIC_Store] @
84
vsimdunaryopcategories_all @
85
vsimdbinopcategories_all
87
(****************************************************************************)
89
let vsimdunaryopToCategory = function
90
| V_Id -> VSIC_UnaryCopy
91
| V_Swap -> VSIC_UnarySwap
92
| V_Chs V_Lo -> VSIC_UnaryChsLo
93
| V_Chs V_Hi -> VSIC_UnaryChsHi
94
| V_Chs V_LoHi -> VSIC_UnaryChsLoHi
95
| V_MulConst _ -> VSIC_UnaryMulConst
97
let vsimdbinopToCategory = function
98
| V_PPAcc -> VSIC_BinPPAcc
99
| V_NNAcc -> VSIC_BinNNAcc
100
| V_NPAcc -> VSIC_BinNPAcc
101
| V_UnpckLo -> VSIC_BinUnpckLo
102
| V_UnpckHi -> VSIC_BinUnpckHi
103
| V_Sub -> VSIC_BinSub
104
| V_SubR -> VSIC_BinSub
105
| V_Add -> VSIC_BinAdd
106
| V_Mul -> VSIC_BinMul
108
let vsimdinstrToCategory = function
109
| V_SimdLoadD _ -> VSIC_Load
110
| V_SimdLoadQ _ -> VSIC_Load
111
| V_SimdStoreD _ -> VSIC_Store
112
| V_SimdStoreQ _ -> VSIC_Store
113
| V_SimdUnaryOp(op,_,_) -> vsimdunaryopToCategory op
114
| V_SimdBinOp(op,_,_,_) -> vsimdbinopToCategory op
116
let vsimdinstrToCategories i = [vsimdinstrToCategory i]