Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/mid-to-low/mid-to-low.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/mid-to-low/mid-to-low.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 579, Sun Mar 6 22:26:51 2011 UTC revision 580, Sun Mar 6 22:27:25 2011 UTC
# Line 176  Line 176 
176     *     *
177     * the address is given by     * the address is given by
178     *     *
179     *    base + szb * (i_1 + N_2 * (i_2 + N_3 * (... + N_d * i_d) ...))     *    base + i_1 + N_2 * (i_2 + N_3 * (... + N_d * i_d) ...))
180     *     *
181     * where     * where
182     *    base    -- base address of the image data     *    base    -- base address of the image data
    *    szb     -- image-element size in bytes  
183     *    N_i     -- size of ith axis in elements     *    N_i     -- size of ith axis in elements
184       *
185       * Note that we are following the Nrrd convention that the axes are ordered
186       * in fastest to slowest order.  We are also assuming the C semantics of address
187       * arithmetic, where the offset will be automatically scaled by the size of the
188       * elements.
189     *)     *)
190      fun expandVoxelAddress (result, info, img::indices) = let      fun expandVoxelAddress (result, info, img::ix1::indices) = let
191            val ImageInfo.ImgInfo{dim, ty=(d, rTy), sizes=_::sizes, ...} = info            val ImageInfo.ImgInfo{dim, ty=(d, rTy), sizes=_::sizes, ...} = info
192          (* generate the address computation code in reverse order *)          (* generate the address computation code in reverse order *)
193            fun gen (d, [n], [ix]) = let            fun gen (d, [n], [ix]) = let
# Line 208  Line 212 
212                  in                  in
213                    (t2, code)                    (t2, code)
214                  end                  end
215    (* FIXME: what about non-scalar images?
216            val voxSzb = List.foldl Int.* (RawTypes.sizeb rTy) d            val voxSzb = List.foldl Int.* (RawTypes.sizeb rTy) d
217            val (offset, code) = gen (0, voxSzb :: sizes, indices)  *)
218              val (tmp, code) = gen (0, sizes, indices)
219              val offset = DstIL.Var.new ("offp", DstTy.intTy)
220            val addrTy = DstTy.AddrTy info            val addrTy = DstTy.AddrTy info
221            val base = DstIL.Var.new ("imgBaseAddr", addrTy)            val base = DstIL.Var.new ("imgBaseAddr", addrTy)
222            val code = (result, DstIL.OP(DstOp.Add addrTy, [base, offset])) ::            val code = (result, DstIL.OP(DstOp.Add addrTy, [base, offset])) ::
223                  (base, DstIL.OP(DstOp.ImageAddress info, [img])) ::                  (base, DstIL.OP(DstOp.ImageAddress info, [img])) ::
224                    iadd(offset, ix1, tmp) ::
225                  code                  code
226            in            in
227              List.rev code              List.rev code

Legend:
Removed from v.579  
changed lines
  Added in v.580

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0