~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/fftw/genfft-k7/vFpBasics.ml

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * Copyright (c) 2000-2001 Stefan Kral
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
17
 *
 
18
 *)
 
19
 
 
20
(* This module declares basic data types for virtual scalar floating-point
 
21
 * instructions and common operations on them.  *)
 
22
 
 
23
open List
 
24
open Util
 
25
open Number                             (* Arbitrary Precision Number Type  *)
 
26
open Variable                           (* Def.s of Variables and Arrays    *)
 
27
 
 
28
type vfpcomplexarrayformat = 
 
29
  | SplitFormat 
 
30
  | InterleavedFormat
 
31
 
 
32
type vfparraytype = 
 
33
  | RealArray 
 
34
  | ComplexArray of vfpcomplexarrayformat
 
35
 
 
36
let vfparraytypeIsReal = function
 
37
  | RealArray      -> true
 
38
  | ComplexArray _ -> false
 
39
 
 
40
let vfparraytypeIsComplex = function
 
41
  | RealArray      -> false
 
42
  | ComplexArray _ -> true
 
43
 
 
44
(****************************************************************************)
 
45
 
 
46
type vfpreg = V_FPReg of int            (* VIRTUAL SCALAR FP REGISTER *******)
 
47
 
 
48
type vfpsummand = V_FPPlus of vfpreg | V_FPMinus of vfpreg
 
49
 
 
50
(* makeNewVfpreg () creates a new vfpreg. It uses Variable.make_temporary   *
 
51
 * so that the indices of vfpregs and temporary variables (that have been   *
 
52
 * created in the generator) are ``compatible''.                            *)
 
53
let makeNewVfpreg () =
 
54
  match Variable.make_temporary () with
 
55
    | Temporary t -> V_FPReg t
 
56
    | _ -> failwith "VFPBasics.makeNewVfpreg: Unexpected failure!"
 
57
 
 
58
(* Sets and Maps with key type vfpreg *)
 
59
module VFPRegSet = Set.Make(struct type t = vfpreg let compare = compare end)
 
60
module VFPRegMap = Map.Make(struct type t = vfpreg let compare = compare end)
 
61
 
 
62
let vfpregmap_find k m = try Some(VFPRegMap.find k m) with Not_found -> None
 
63
 
 
64
(* The function vfpregmap_addE inserts a (key,value) pair into a multimap   *
 
65
 * m. All bindings bindings of key are stored in an unsorted list.          *)
 
66
let vfpregmap_findE k m = try VFPRegMap.find k m with Not_found -> []
 
67
let vfpregmap_addE k v m = VFPRegMap.add k (v::(vfpregmap_findE k m)) m
 
68
 
 
69
(****************************************************************************)
 
70
 
 
71
type vfpaccess =
 
72
  | V_FPRealOfComplex
 
73
  | V_FPImagOfComplex
 
74
  | V_FPReal
 
75
 
 
76
type vfpunaryop =
 
77
  | V_FPMulConst of number
 
78
  | V_FPId
 
79
  | V_FPNegate
 
80
 
 
81
type vfpbinop = 
 
82
  | V_FPAdd
 
83
  | V_FPSub
 
84
  | V_FPMul
 
85
 
 
86
type vfpinstr =                         (* VIRTUAL SCALAR FP INSTRUCTION ****)
 
87
  | V_FPLoad of 
 
88
        vfpaccess *
 
89
        array *
 
90
        int *
 
91
        vfpreg
 
92
  | V_FPStore of
 
93
        vfpreg *
 
94
        vfpaccess *
 
95
        array *
 
96
        int
 
97
  | V_FPUnaryOp of
 
98
        vfpunaryop *
 
99
        vfpreg *
 
100
        vfpreg
 
101
  | V_FPBinOp of
 
102
        vfpbinop *
 
103
        vfpreg *
 
104
        vfpreg *
 
105
        vfpreg
 
106
  | V_FPAddL of
 
107
        vfpsummand list *
 
108
        vfpreg
 
109
 
 
110
(****************************************************************************)
 
111
 
 
112
let vfpbinopIsAddorsub = function
 
113
  | V_FPAdd -> true
 
114
  | V_FPSub -> true
 
115
  | V_FPMul -> false
 
116
 
 
117
let vfpunaryopToNegated = function
 
118
  | V_FPId         -> V_FPNegate
 
119
  | V_FPNegate     -> V_FPId
 
120
  | V_FPMulConst n -> V_FPMulConst (Number.negate n)
 
121
 
 
122
let vfpsummandToVfpreg = function
 
123
  | V_FPPlus  x -> x
 
124
  | V_FPMinus x -> x
 
125
 
 
126
let vfpsummandIsPositive = function
 
127
  | V_FPPlus _  -> true
 
128
  | V_FPMinus _ -> false
 
129
 
 
130
let vfpsummandIsNegative = function
 
131
  | V_FPPlus _  -> false
 
132
  | V_FPMinus _ -> true
 
133
 
 
134
let vfpsummandToNegated = function
 
135
  | V_FPPlus x  -> V_FPMinus x
 
136
  | V_FPMinus x -> V_FPPlus x
 
137
 
 
138
(****************************************************************************)
 
139
 
 
140
(* vfpinstrToSrcregs maps a vfpinstruction to its source register operands. *
 
141
 * The output list may contain duplicates.                                  *)
 
142
let vfpinstrToSrcregs = function
 
143
  | V_FPLoad _           -> []
 
144
  | V_FPStore(s,_,_,_)   -> [s]
 
145
  | V_FPUnaryOp(_,s,_)   -> [s]
 
146
  | V_FPBinOp(_,s1,s2,_) -> [s1;s2]
 
147
  | V_FPAddL(srcs,_)     -> map vfpsummandToVfpreg srcs
 
148
  
 
149
(* vfpinstrToDstreg maps a vfpinstr to its destination register operand. If *
 
150
 * an instruction does not have a dest register-operand, None is returned.  *)
 
151
let vfpinstrToDstreg = function
 
152
  | V_FPStore _        -> None
 
153
  | V_FPLoad(_,_,_,d)  -> Some d
 
154
  | V_FPUnaryOp(_,_,d) -> Some d
 
155
  | V_FPBinOp(_,_,_,d) -> Some d
 
156
  | V_FPAddL(_,d)      -> Some d
 
157
 
 
158
let vfpinstrToVfpregs instr = 
 
159
  optionToListAndConcat (vfpinstrToSrcregs instr) (vfpinstrToDstreg instr)
 
160
 
 
161
let vfpinstrIsLoad = function
 
162
  | V_FPLoad _ -> true
 
163
  | _ -> false
 
164
 
 
165
let vfpinstrIsStore = function
 
166
  | V_FPStore _ -> true
 
167
  | _ -> false
 
168
 
 
169
let vfpinstrIsLoadOrStore i = vfpinstrIsLoad i || vfpinstrIsStore i
 
170
 
 
171
let vfpinstrToAddsubcount = function
 
172
  | V_FPLoad _          -> 0
 
173
  | V_FPStore _         -> 0
 
174
  | V_FPUnaryOp _       -> 0
 
175
  | V_FPBinOp(op,_,_,_) -> if vfpbinopIsAddorsub op then 1 else 0
 
176
  | V_FPAddL(xs,_)      -> length xs
 
177
 
 
178
let vfpinstrIsBinMul = function
 
179
  | V_FPBinOp(V_FPMul,_,_,_) -> true
 
180
  | _ -> false
 
181
 
 
182
let vfpinstrIsUnaryOp = function
 
183
  | V_FPUnaryOp _ -> true
 
184
  | _ -> false
 
185
 
 
186
 
 
187
(****************************************************************************)
 
188
 
 
189
let addlistHelper2 dst = function
 
190
  | (V_FPPlus  x, V_FPPlus y)  -> (V_FPBinOp(V_FPAdd,x,y,dst), V_FPPlus dst)
 
191
  | (V_FPPlus  x, V_FPMinus y) -> (V_FPBinOp(V_FPSub,x,y,dst), V_FPPlus dst)
 
192
  | (V_FPMinus x, V_FPPlus y)  -> (V_FPBinOp(V_FPSub,y,x,dst), V_FPPlus dst)
 
193
  | (V_FPMinus x, V_FPMinus y) -> (V_FPBinOp(V_FPAdd,x,y,dst), V_FPMinus dst)
 
194
 
 
195
let addlistHelper3' dst tmp (x',y',z') =
 
196
  let (i1, tmp') = addlistHelper2 tmp (x',y') in
 
197
  let (i2, dst') = addlistHelper2 dst (tmp',z') in
 
198
    (i1,i2,dst')
 
199
 
 
200
let addlistHelper3 dst triple =
 
201
  addlistHelper3' dst (makeNewVfpreg ()) triple
 
202
 
 
203