exception IllegalState fun tnodeBase tgPairList temp = let val igNodeOpt = List.find (fn (pTemp,_) => pTemp = temp) tgPairList in case igNodeOpt of SOME (_,igNode) => igNode | _ => raise IllegalState end fun gtempBase tgPairList igNode = let val tempOpt = List.find (fn (_,pIgNode) => Graph.eq(pIgNode,igNode)) tgPairList in case tempOpt of SOME (temp,_) => temp | _ => raise IllegalState end fun makeIGraph numOfIgNodes = let val iGraph = Graph.newGraph() val _ = Temp.reset() val tgPairList = List.tabulate (numOfIgNodes, fn n => (Temp.newtemp(), Graph.newNode(iGraph))) in (iGraph,tgPairList) end fun addInterferences igNodeList nPairList = let fun addInterferenceBase (n1,n2) = Graph.mk_edge {from=List.nth(igNodeList,n1), to= List.nth(igNodeList,n2)} in app addInterferenceBase nPairList end fun makeFGraphWithMoves igNodeList gtemp nPairList = let val fGraphInitial = Flow.FGRAPH{control=Graph.newGraph(), def=Graph.Table.empty, use=Graph.Table.empty, ismove=Graph.Table.empty} fun addMove ((n1,n2),Flow.FGRAPH{control,ismove,def,use}) = let val enter = Graph.Table.enter val fgNode = Graph.newNode control val (temp1,temp2) = (gtemp(List.nth(igNodeList,n1)), gtemp(List.nth(igNodeList,n2))) in Flow.FGRAPH{control=control, def=enter(def,fgNode,[temp1]), use=enter(use,fgNode,[temp2]), ismove=enter(ismove,fgNode,true)} end in foldl addMove fGraphInitial nPairList end fun genDummyGraph numOfNodes interferencePairList movesPairList = let val (iGraph,tgPairList) = makeIGraph numOfNodes val (_,igNodeList) = ListPair.unzip tgPairList val _ = addInterferences igNodeList interferencePairList val tnode = tnodeBase tgPairList val gtemp = gtempBase tgPairList val fGraph as Flow.FGRAPH{control,def,use,...} = makeFGraphWithMoves igNodeList gtemp movesPairList val fgNodes = Graph.nodes(control) fun getMoves fgNode = let val defINode = tnode(hd(valOf(Graph.Table.look(def,fgNode)))) val useINode = tnode(hd(valOf(Graph.Table.look(use,fgNode)))) in {fgNode=fgNode,duPair=(defINode,useINode)} end val moves = List.map getMoves fgNodes val interference = Liveness.IGRAPH{graph=iGraph, tnode=tnode, gtemp=gtemp, moves=moves} in {fGraph=fGraph, fgNodes=fgNodes, interference=interference} end fun genGraph1() = genDummyGraph 4 [(0,1),(0,2)] [(0,3)]