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

« back to all changes in this revision

Viewing changes to extern/fftw/genfft-k7/k7RegisterAllocatorInit.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) 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
 
 
21
open List
 
22
open Util
 
23
open VSimdBasics
 
24
open K7Basics
 
25
open K7RegisterAllocationBasics
 
26
 
 
27
module HandleOnDemandInstructions : sig
 
28
  val addOndemandInstructions : 
 
29
        viregfileentry VIntRegMap.t -> k7vinstr list -> 
 
30
                viregfileentry VIntRegMap.t * K7Basics.k7vinstr list
 
31
end = struct
 
32
  open Util
 
33
  open StateMonad
 
34
 
 
35
  let fetchInstrsM    = fetchStateM >>= fun x -> unitM (fst x)
 
36
  let fetchVIRegFileM = fetchStateM >>= fun x -> unitM (snd x)
 
37
 
 
38
  let storeInstrsM x    = fetchStateM >>= fun s -> storeStateM (repl1of2 x s)
 
39
  let storeVIRegFileM x = fetchStateM >>= fun s -> storeStateM (repl2of2 x s)
 
40
 
 
41
  let addInstrM x = fetchInstrsM >>= consM x >>= storeInstrsM
 
42
 
 
43
  let rec addOndemandInstrs1M instr =
 
44
    iterM addOndemandInstrs2M (snd (k7vinstrToSrcvregs instr)) >>
 
45
      addInstrM instr
 
46
 
 
47
  and addOndemandInstrs2M vireg =
 
48
    fetchVIRegFileM >>= fun viregfile ->
 
49
      match vintregmap_find vireg viregfile with
 
50
        | Some (IOnDemand zs) -> 
 
51
            storeVIRegFileM (VIntRegMap.add vireg IFresh viregfile) >>
 
52
              iterM addOndemandInstrs1M zs
 
53
        | _ -> 
 
54
            unitM ()
 
55
 
 
56
  let rec addOndemandInstrsM instrs =
 
57
    iterM addOndemandInstrs1M instrs >>
 
58
      fetchVIRegFileM >>= fun viregfile' ->
 
59
      fetchInstrsM >>= fun instrs' ->
 
60
        unitM (viregfile',List.rev instrs')
 
61
 
 
62
  let addOndemandInstructions viregfile instrs = 
 
63
    StateMonad.runM addOndemandInstrsM instrs ([],viregfile)
 
64
end
 
65
 
 
66
open HandleOnDemandInstructions
 
67
 
 
68
(****************************************************************************)
 
69
 
 
70
let processInitcode viregfile = function
 
71
  | AddIntOnDemandCode(reg,xs) -> VIntRegMap.add reg (IOnDemand xs) viregfile
 
72
  | _ -> viregfile
 
73
 
 
74
let makeInitialMap rregfile = function
 
75
  | FixRegister(vreg, rreg) -> (rreg, IFixed vreg)::(remove_assoc rreg rregfile)
 
76
  | _ -> rregfile
 
77
 
 
78
let addRegRefForInstr (n0,vsrefs0,virefs0) instr =
 
79
  let (_,_,(vsregs,viregs)) = k7vinstrToVregs instr in
 
80
  let vsrefs = fold_right (fun reg -> vsimdregmap_addE reg n0) vsregs vsrefs0
 
81
  and virefs = fold_right (fun reg -> vintregmap_addE reg n0) viregs virefs0 in
 
82
    (succ n0,vsrefs,virefs)
 
83
 
 
84
let getRegRefsForInstrs instrs =
 
85
  let s0 = (0,VSimdRegMap.empty,VIntRegMap.empty) in
 
86
  let (_,vsrefs0,virefs0) = fold_left addRegRefForInstr s0 instrs in
 
87
    (VSimdRegMap.map rev vsrefs0, VIntRegMap.map rev virefs0)
 
88
 
 
89
let addRegsForInstr i = (@.)(k7vinstrToDstvregs i @. k7vinstrToSrcvregs i) 
 
90
 
 
91
let prepareRegAlloc initcode instrs0 =
 
92
  let viregfile0 = fold_left processInitcode VIntRegMap.empty initcode
 
93
  and vsregfile0 = VSimdRegMap.empty in
 
94
  let (viregfile1, instrs) = addOndemandInstructions viregfile0 instrs0 in
 
95
  let (vsregs,viregs) = fold_right addRegsForInstr instrs ([],[]) in
 
96
  let rimap0 = map (fun reg -> (reg,IFree)) k7rintregs in
 
97
  let rimap1 = fold_left makeInitialMap rimap0 initcode in
 
98
  (((map (fun reg -> (reg,SFree)) k7rmmxregs), rimap1),
 
99
   (fold_right (fun reg -> VSimdRegMap.add reg SFresh) vsregs vsregfile0,
 
100
    fold_right (fun reg -> VIntRegMap.add reg IFresh) viregs viregfile1),
 
101
   getRegRefsForInstrs instrs,
 
102
   instrs)
 
103