Home My Page Projects Code Snippets Project Openings SML/NJ
 Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

# SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/instructions/cells.sml
 [smlnj] / sml / trunk / src / MLRISC / instructions / cells.sml # View of /sml/trunk/src/MLRISC/instructions/cells.sml

Fri Jun 9 05:20:54 2000 UTC (19 years, 1 month ago) by leunga
File size: 3324 byte(s)
```
None of these changes should affect SML/NJ.  See HISTORY file for details.
CVS Tag=leunga-20000609-various
```
```(*
* Description of cell and other updatable cells.
*
* -- Allen.
*)
functor CellsBasis
(eqtype cellkind
exception Cells
val unknown     : cellkind
val cellkindToString : cellkind -> string
val INT         : cellkind
val FLOAT       : cellkind
val firstPseudo : int
val kinds       : cellkind list
val physical    : {kind:cellkind,from:int,to:int} list
) : CELLS_BASIS =
struct
type cellkind = cellkind
type cell = int
type ty   = int
type regmap = cell Intmap.intmap
exception Cells = Cells

val cellkinds = kinds
val cellkindToString = cellkindToString

val firstPseudo = firstPseudo

val name = ref firstPseudo
val counters = map (fn _ => ref 0) kinds

fun lookupCnt c =
let fun f(c'::cs,r::rs) = if c = c' then r else f(cs,rs)
| f _ = (print("lookupCnt "^cellkindToString c^"\n"); raise Cells)
in  f(kinds,counters) end

fun cellRange k =
let fun find({kind,from,to}::rest) =
if kind = k then {low=from,high=to}
else find rest
| find [] = raise Cells
in  find physical end

fun Reg k =
let val {high,low} = cellRange k
val count = high-low+1
in  fn nth => if 0 <= nth andalso nth < count then nth+low
else raise Cells
end

val GPReg = Reg INT
val FPReg = Reg FLOAT

fun newCell c =
let val cnt = lookupCnt c
in  fn _ =>
let val r = !name
in  name := r + 1;
cnt := !cnt + 1;
r
end
end

local val cnt = lookupCnt INT
in fun newReg _ =
let val r = !name
in  name := r + 1;
cnt := !cnt + 1;
r
end
end

local val cnt = lookupCnt FLOAT
in fun newFreg _ =
let val r = !name
in  name := r + 1;
cnt := !cnt + 1;
r
end
end

fun newVar r' =
let val r = !name
in  name := r + 1; r
end

fun numCell c = let val cnt = lookupCnt c in fn () => !cnt end

fun maxCell() = !name

fun regmap() = Intmap.new(32,Cells)
(*
let val map = Intmap.new(32,Cells)
(* initialize the regmap with physical register bindings *)
fun init [] = ()
| init({from,to,kind}::rest) = (ins(from,to); init rest)
and ins(r,limit) = if r > limit then () else (add(r,r); ins(r+1,limit))
in  init physical;
map
end
*)

val lookup = Intmap.mapInt

fun reset() = (app (fn r => r := 0) counters;
name := firstPseudo
)

fun printSet f set =
let fun g []     = ["}"]
| g [x]    = [f x,"}"]
| g (x::y) = f x::" "::g y
in  String.concat("{"::g set) end

fun printTuple(c::cs,s::sets) = c^"="^s^"  "^printTuple(cs,sets)
| printTuple _ = ""

(*
* These annotations specifies definitions and uses
* for a pseudo instruction.
*)
exception DEF_USE of {cellkind:cellkind, defs:cell list, uses:cell list}
val DEFUSE = Annotations.new'
{create=DEF_USE,
get=fn DEF_USE x => x | e => raise e,
toString=fn{cellkind,defs,uses} =>
"DEFUSE"^cellkindToString cellkind
}
end
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.50805193,"math_prob":0.98953676,"size":3055,"snap":"2019-26-2019-30","text_gpt3_token_len":949,"char_repetition_ratio":0.13274336,"word_repetition_ratio":0.19021739,"special_character_ratio":0.33649755,"punctuation_ratio":0.18096724,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9930307,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-07-15T22:21:06Z\",\"WARC-Record-ID\":\"<urn:uuid:63ce725e-575c-4980-a9cf-68b7d7fc5f7d>\",\"Content-Length\":\"18074\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:75fc5d19-113e-431f-89ae-3be755e20987>\",\"WARC-Concurrent-To\":\"<urn:uuid:aa201b84-b2af-49a9-bfb1-959353776388>\",\"WARC-IP-Address\":\"128.135.164.83\",\"WARC-Target-URI\":\"http://smlnj-gforge.cs.uchicago.edu/scm/viewvc.php/sml/trunk/src/MLRISC/instructions/cells.sml?view=markup&root=smlnj&sortby=rev&pathrev=657\",\"WARC-Payload-Digest\":\"sha1:F4HPYXV7TKDW5NYTDVEKA6H32ELG4RBM\",\"WARC-Block-Digest\":\"sha1:VZ65SGAAMELH5RN4W6LMYCHY4WM3JTTH\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-30/CC-MAIN-2019-30_segments_1563195524254.28_warc_CC-MAIN-20190715215144-20190716001144-00318.warc.gz\"}"}