Changes between Version 111 and Version 112 of IR


Ignore:
Timestamp:
12/02/15 09:33:37 (10 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v111 v112  
    3030block: '{' typedef* vardecl* fundef* statement* '}' ;
    3131statement: block | basicStmt ;
    32 basicStmt:  (ID ':')? (simpleStmt | chooseStmt) ;
    33 simpleStmt: (guardedStmt | primitiveStmt) ('goto' ID)? ;
     32basicStmt:  (ID ':')? (simpleStmt | chooseStmt | gotoStmt) ;
     33gotoStmt: 'goto' ID ;
     34simpleStmt: (guardedStmt | primitiveStmt) gotoStmt? ;
    3435guardedStmt: 'when' expr 'do' primitiveStmt ;
    3536chooseStmt: 'begin choose' simpleStmt+ 'end choose' ;
     
    143144A **type name** is a syntactic element that names a (static or value) type.  Examples of type names include `Array[Integer]` and `Array[Integer,24]`.
    144145
    145 The expression `new(t)` takes a Dytype and returns the initial value for an object of that type.   The initial value of `Integer` and other primitive (non-compound) types is "undefined".   The initial value of `Array[Integer]` is an array of length 0 of `Integer`.  The initial value of `Pointer[Real]` is the undefined pointer to `Real`.    The initial value of `Array[Real, 10]` is the array of length 10 in which each element is undefined.  In general, the initial value of an array of length n is the sequence of length n in which every element is the initial value of the element type of the array.   The initial value of a tuple type is the tuple in which each component is assigned the initial value for its type.
     146The expression `new(t)` takes a Dytype and returns an unconstrained value of that type.
    146147
    147148Example:  the C code
     
    226227 * If `e3` is positive, the integers `e1`, `e1`+`e3`, `e1`+2*`e3`, ... that are less than or equal to `e2`.  If `e3` is negative, the integers `e1`, `e1`+`e3`, `e1`+2*`e3`, ... that are greater than or equal to `e2`.  Exception if `e3` is 0.
    227228* `domain(<r1,...,rn>)` : value of type `Domain[n]`, the Cartesian product of the n ranges, with dictionary order
    228 * `hasnext(dom, <i,j,…>)`: an expression of type `Bool`, testing if the domain `dom` contains any element after `<i,j,...>`. If `i` or `j` or ... is undefined, then it evaluates to `false` if `dom` is empty, and `true` if `dom` is not empty.
    229229
    230230Arrays (which are also Sequences)
     
    280280
    281281Types
    282 * `new(t)` : new (default) value of `Dytype` t.  If `t` has type `Dytype[T]`, then this expression has static type `T`.
     282* `new(t)` : new unconstrained value of `Dytype` t.  If `t` has type `Dytype[T]`, then this expression has static type `T`.
    283283* `typeof(e)` : returns the value of type `Dytype` representing the value type of `e`.
    284284 * If `e` has static type `T` then this expression has static type `Dytype[T]`.
     
    297297* `"x"` : x is an identifier, naming either a type, variable, or function
    298298* `sizeof_expr(e)` : the size of the value of expression `e`; return an `Integer`
    299 * `defined(e)` : is `e` defined? `Bool` type
    300299* `ite(e1,e2,e3)`: if-then-else (conditional) expression, like `e1?e2:e3` in C.
    301300 * `e1` must have `Bool` type.  `e2` and `e3` must have the same static types, which is the static type of the result.
     
    333332* `PARSPAWN p, d, f;` : spawn a sequence of procs
    334333 * `p` has type `Pointer[Proc]`,  `d` has `Domain` type and `f` has `Function` type.
    335 * `NEXT dom, <i,j,…>;` : move to next element in domain
    336  * updates `i`,`j`,... to be the value of the next tuple in `dom` after `<i,j,...>`
    337  * if `i`, or `j`, ... is undefined, then `i`, `j`, ... are updated to be the value of the first tuple in `dom`
    338  * The CIVL-C code `$for(int i,j,...: dom) S;` is translated into the following:
    339 {{{
    340 var i: Integer;
    341 var j: Integer;
     334* `NEXT <i,j,...>, dom, flag;` : move to next element in domain
     335 * `i`,`j`,... have integral types
     336 * `dom` has type `Domain[n]`, where `n` is the number of variables in the sequence `i`,`j`,...
     337 * `flag` has type `Bool`
     338 * if `flag` is `false` in the pre-state, this indicates you want the first element of the domain
     339 * if `flag` is `true` in pre-state, this indicates you want the next element after current `<i,j,...>`
     340 * `flag`=`false` in post-state indicates there is no next element
     341 * `flag`=`true` in post-state indicates the next element is in `<i,j,...>`
     342
     343The CIVL-C code `$for(int i,j: dom) S;` is translated into the following:
     344{{{
     345{
     346  var i:Integer;
     347  var j:Integer;
     348  var flag:Bool;
     349
     350  flag=false;
    342351L0:
    343 begin choose
    344   when(hasnext(dom, <i,j,...>)) NEXT dom, <i,j,...>; goto L1;
    345   when(not(hasnext(dom, <i,j,...>))) NOOP; goto L2;
    346 end choose
     352  NEXT <i,j>, dom, flag;
     353  when not(flag) do NOOP; goto L1;
     354  S;
     355  goto L0;
     356}
    347357L1:
    348   S...
    349    ...goto L0;
    350 L2:
    351   ...
    352358}}}
    353359