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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/codegen/Ctypes.sml
ViewVC logotype

View of /branches/charisee/src/compiler/codegen/Ctypes.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3544 - (download) (annotate)
Tue Jan 5 00:01:44 2016 UTC (3 years, 6 months ago) by cchiw
File size: 1427 byte(s)
code cleanup
(* mid-il-types.sml
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 * Types for the MidIL.

structure CTypes =

 structure Ty = TreeILTypes
 structure CL = CLang

    fun q n =Int.toString n

    fun coords [i]=q i
    | coords (e1::es)= String.concat[q e1, "x", coords es]

    fun mkVec n =String.concat["Diderot_vec", q n , "_t"]
    fun mkMat e=String.concat["Diderot_Mat",coords e,"_t"]
    fun mkTen e=String.concat["Diderot_Tensor", coords e,"_t"]

    fun toCTyp (Ty.TensorTy[]) = NONE
      | toCTyp (Ty.TensorTy[n1])= SOME(mkVec n1)
      | toCTyp (Ty.TensorTy[n1,n2])=(*SOME(mkMat [n1,n2])*)SOME(mkVec n1) (*HERE*)
      | toCTyp (Ty.TensorTy dd) =SOME(mkTen dd)
      | toCTyp Ty.BoolTy = NONE
      | toCTyp Ty.StringTy =NONE
      | toCTyp Ty.IntTy = NONE
      | toCTyp (Ty.SeqTy _) = NONE
      | toCTyp (Ty.AddrTy _) =NONE
      | toCTyp (Ty.ImageTy _) =NONE
      | toCTyp Ty.KernelTy =NONE

    fun toString([],rest)=rest
      | toString(NONE::es,rest)=toString(es,rest)
      | toString(SOME e1::es,rest)= toString(es,rest@[e1])

    fun treeToCtypes e=let
        val a=List.map toCTyp e
        val str=toString(a,[])
        val _=print(String.concat["\n \t\t  CodeGen type names\n ",String.concatWith "," str])
        in str end


ViewVC Help
Powered by ViewVC 1.0.0