Changes between Version 139 and Version 140 of IR


Ignore:
Timestamp:
01/11/16 17:33:34 (10 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v139 v140  
    394394fun[options] foo(x:Integer, ...) : Real
    395395  // contract clauses (optional):
    396   requires expr;
    397   ensures expr ;
    398   mpi_requires expr ;
    399   mpi_ensures expr ;
    400   behavior name:
    401     assigns expr ;
    402     reads expr ;
    403     depends actions ;
     396  Requires expr;
     397  Ensures expr ;
     398  MPI_requires expr ;
     399  MPI_ensures expr ;
     400  Behavior name:
     401    Assigns expr ;
     402    Reads expr ;
     403    Depends actions ;
    404404{
    405405  // all of the following are missing for a system function...
     
    451451
    452452
    453 === Function Contracts ===
    454 
    455 [wiki:Function_Contracts]
    456 
    457 * action expressions:
    458  * `read(e)`: `e` has type `Mem`. The function reads the memory units specified by `e`.
    459  * `write(e)`: `e` has type `Mem`. The function writes the memory units specified by `e`.
    460  * `call(f, <e1, ...>)`: `f` has type `Function`. The function calls `f` with parameters `e1, ...`.
    461  * `noaction`: no action
    462  * `anyaction`: all actions
    463  * `act_union(ma0, ma1)`: the union of the two memory set actions `ma0` and `ma1`.
    464  * `act_comp(ma0, ma1)`: action complement (everything not in `ma1`)
    465  * `act_isect(ma0, ma1)`: action intersection
    466 
    467 * depends clause: `depends action0, action1, action2, ... `
    468  * Example: `depends act_union(act_comp(read(n), call(inc, <x>))), call(dec, <y>))`
    469  * absence of depends clause: there is no information about the dependency of the function, which means that the analysis needs to figure it out by itself.
    470 * some facts about assigns-or-reads clause
    471  * absence of `reads`/`assigns` clause: there is no assumption about the read/assign access of the function, i.e., the function could read/assign anything
    472   * absence of `assigns` clause: similar to the absence of `reads` clause
    473  * `reads/assigns nothing` doesn’t necessarily means that the function never reads or assigns any variable. The function could still reads/assigns its “local” variables, including function parameters and any variable declared inside the function body. **check it**
    474 
    475 * For an independent function which has `depends coaction`, usually we also need to specify `reads nothing`, for the purpose of reachability analysis.
    476 e.g.,
    477 {{{
    478 /* Returns the size of the given bundle b. */
    479 bundle_size(Bundle b): Integer
    480   depends nothing
    481   reads b
    482   ;
    483 }}}
    484 
    485 * Example of a function declaration with contracts:
    486 {{{
    487 fun[atomic] sendRecv(Int cmd, Pointer buf): Integer
    488   reads deref(buf);
    489   behavior send:
    490     depends writes(buf);
    491     assigns nothing;
    492   behavior receive:
    493     depends access(deref(buf));
    494     assigns deref(buf);
    495 {
    496   begin choose
    497   when eq(cmd, 0)
    498      do CALL send, <buf, ...>; goto L1;
    499   when eq(cmd, 1)
    500     do CALL recv, <buf, ...>; goto L1;
    501   when and(neq(cmd, 0), neq(cmd, 1))
    502     do NOOP; goto L1;
    503   end choose
    504 L1:
    505 }
    506 }}}
     453Function Contracts:
     454 * [wiki:Function_Contracts]
    507455
    508456== Program ==