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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/c-target/opr-to-clang.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/c-target/opr-to-clang.sml

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

revision 2844, Tue Dec 9 18:05:29 2014 UTC revision 2845, Fri Dec 12 06:46:23 2014 UTC
# Line 1  Line 1 
1  (* WQE Tree-IL Opr expression to Clang *)  (*Tree-IL Opr expression to CLang Declarations *)
2    
3  structure OprToClang= struct  structure OprToClang= struct
4    
# Line 22  Line 22 
22      fun mkInt i =CL.mkInt(IntInf.fromInt i)      fun mkInt i =CL.mkInt(IntInf.fromInt i)
23    
24      (*-------------- var:strings ---------------*)      (*-------------- var:strings ---------------*)
   
25      val varR="r"   (*reals*)      val varR="r"   (*reals*)
26      val varV="v"  (*vector*)      val varV="v"  (*vector*)
27      val varI="i"  (*int*)      val varI="i"  (*int*)
# Line 55  Line 54 
54      val ParamI=mkParam([],intTy, varI)   (*Int i*)      val ParamI=mkParam([],intTy, varI)   (*Int i*)
55      val ParamA=mkParam([], star,varA) (*float ptr * a *)      val ParamA=mkParam([], star,varA) (*float ptr * a *)
56      val ParamA2=mkParam([], star,varA2) (*float ptr * b*)      val ParamA2=mkParam([], star,varA2) (*float ptr * b*)
   
57      fun mkParamsSameType(ty,args)=List.map (fn e=>mkParam([],ty,e)) args      fun mkParamsSameType(ty,args)=List.map (fn e=>mkParam([],ty,e)) args
58    
59      (*mkVarParams: int*int-> CL.Exp * CL.PARAM list      (*mkVarParams: int*int-> CL.Exp * CL.PARAM list
# Line 79  Line 77 
77   fun mkAddM [a]=a   fun mkAddM [a]=a
78   | mkAddM (a::b::es)= mkAddM (CL.mkBinOp(a, CL.#+, b)::es)   | mkAddM (a::b::es)= mkAddM (CL.mkBinOp(a, CL.#+, b)::es)
79    
   
80   fun mkRtn e=CL.S_Return(SOME e)   fun mkRtn e=CL.S_Return(SOME e)
81   val voidRtn =CL.S_Return NONE   val voidRtn =CL.S_Return NONE
82    
# Line 93  Line 90 
90   fun mkCast(ty,body)=CL.E_Cast(ty, body)   fun mkCast(ty,body)=CL.E_Cast(ty, body)
91   fun mkCastStruct(ty,body)= mkCast(ty, (CL.E_Struct body))   fun mkCastStruct(ty,body)= mkCast(ty, (CL.E_Struct body))
92    
   
93   (*mkExtVar:int*var *Var ->CL.S* CL.E   (*mkExtVar:int*var *Var ->CL.S* CL.E
94   *ty:vectTy n  u = (ty) a   *ty:vectTy n  u = (ty) a
95   *)   *)
# Line 115  Line 111 
111  fun indexDiderotTypeWithOffset(U,0,I)= []  fun indexDiderotTypeWithOffset(U,0,I)= []
112   | indexDiderotTypeWithOffset(U,1,I)=[CL.E_Subscript(U,I)]   | indexDiderotTypeWithOffset(U,1,I)=[CL.E_Subscript(U,I)]
113  | indexDiderotTypeWithOffset(U,n,I)=  | indexDiderotTypeWithOffset(U,n,I)=
114      indexDiderotTypeWithOffset(U,n-1,I)@          indexDiderotTypeWithOffset(U,n-1,I)@[CL.E_Subscript(U,mkAdd(mkInt(n-1),I))]
   [CL.E_Subscript(U,mkAdd(mkInt(n-1),I))]  
115    
116  (*mkZero:int -> exp  (*mkZero:int -> exp
117  *mk List of 0 expressions  *mk List of 0 expressions
# Line 128  Line 123 
123  end  end
124    
125  (*createDec:Ty,string, exp list, exp list ->CL.D_Func  (*createDec:Ty,string, exp list, exp list ->CL.D_Func
126   *create a CLang Decl       *create a CLang Declaration
127  *)  *)
128  fun createDec(rtnType, fnName, params,blk)=   CL.D_Func([],rtnType,fnName,params,CL.S_Block blk)  fun createDec(rtnType, fnName, params,blk)=   CL.D_Func([],rtnType,fnName,params,CL.S_Block blk)
129    
# Line 179  Line 174 
174          val f=List.map (fn e=> CL.mkApply(N.NameFloor, [e])) indexedVec          val f=List.map (fn e=> CL.mkApply(N.NameFloor, [e])) indexedVec
175          val body'= mkCastStruct(rtnType,f)          val body'= mkCastStruct(rtnType,f)
176          val rtn= mkRtn(CL.E_Ext(body'))          val rtn= mkRtn(CL.E_Ext(body'))
   
177          in          in
178              createDec(rtnType, fnName, params,[e,rtn])              createDec(rtnType, fnName, params,[e,rtn])
179          end          end

Legend:
Removed from v.2844  
changed lines
  Added in v.2845

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