Changes between Version 60 and Version 61 of IR


Ignore:
Timestamp:
11/25/15 18:02:53 (10 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v60 v61  
    5656  when (\true) assign x, \mul(3,y); goto L2;
    5757L2:
    58   when(\true) assign a_t, \dytype(Array[Integer, \add(x,1)]); goto L3; // Array[Integer] is refined here using x+1
     58  when(\true) assign a_t, \dytype(Array[Integer, \add(x,1)]); goto L3;
    5959L3:
    6060  when (\true) assign a, \new(a_t); goto L4;
     
    8989 * IEEE754 floating point numbers
    9090* `HerbrandReal` : Herbrand real numbers.  Values are unsimplified symbolic expressions.
    91 * `Tuple[T0, T1, ...]`: a tuple type, the Cartesian product of T0, T1, ...
     91* `Tuple[<T0, T1, ...>]`: a tuple type, the Cartesian product of T0, T1, ...
    9292 * **What about bit-widths?**
    93 * `Union[T0, T1, ...]`: union type, the disjoint union of T0, T1, ...
     93* `Union[<T0, T1, ...>]`: union type, the disjoint union of T0, T1, ...
    9494* `Array[T]` : arrays of any length whose elements belong to T
    95 * `Function[(T0,T1,...),T]` : functions consuming T0,T1,... and returning T.  T can be `void` to indicate nothing is returned.
     95* `Function[<T0,T1,...>,T]` : functions consuming T0,T1,... and returning T.  T can be `void` to indicate nothing is returned.
    9696* `Mem` : type representing a memory set.  May be thought of as a set of pointers.
    9797* `Pointer` : all pointers, a subtype of `Mem`
     
    122122
    123123{{{
    124 typedef S=Tuple[Array[Integer]];
     124typedef S=Tuple[<Array[Integer]>];
    125125
    126126n: Integer;
     
    132132  when (\true) assign n, 10; goto L1;
    133133L1:
    134   when (\true) assign S_d, \dytype(Tuple[Array[Integer, n]]); goto L2;
     134  when (\true) assign S_d, \dytype(Tuple[<Array[Integer, n]]>); goto L2;
    135135L2:
    136136  when (\true) assign x1, \new(S_d); goto L3;
     
    147147In the following list of expressions, `e`, `e0`, `e1`, etc., are expressions.  `T` is a type name. `t` is an expression of type `Dytype`.
    148148
    149 * literals
    150  * `\true`, `\false` : values of type `Bool`
     149* Logical
     150 * `\true`, `\false` : literal values of type `Bool`
     151 * `\not(e)` : logical not
     152 * `\and(e1, e2)`, `\or(e1, e2)`: logical and/or operation
     153 * `\eq(e1, e2)`, `\neq(e1, e2)`: equality/inequality test
     154 * `\forall`, `\exists` :  `\forall {Integer i | e0} e1`. `\exists` is similar.  ** Is this the best notation? **
     155* Numeric
    151156 * 123, -123, 3.1415, etc. : values of type `Integer`, `Int`, `Real`, `Float`.   **NEED TO BE MORE SPECIFIC**
     157 * `\add(e1, e2)` : numeric addition. 
     158  * `e1` and `e2` have the same numeric type.  Note that there are no "automatic conversions" as there are in C.  If the original expressions have different types, explicit casts must be inserted. 
     159 * `\sub(e1, e2)` : subtraction
     160 * `\mul(e1, e2)` : multiplication
     161 * `\div(e1, e2)` : division
     162  * If both are integer types, the result is integer division.  Otherwise it is real division.  Need to define what happens for negative integers.
     163 * `\mod(e1, e2)` : integer modulus
     164 * `\neg(e)` : negative
     165 * `\lt(e1, e2)`, `\lte(e1, e2)`: less than/less than or equal to
     166* Characters and Strings
    152167 * 'a', 'b', ... : Char values.  **UNICODE?**
     168 * `"abc"` : string literals: value of type `Array[Char, n+1]`, where n is the length of the string (the last element is the character `\0`)
     169* Ranges and Domains
     170 * `\range(e1,e2,e3)` : value of type `Range` consisting of the integers e1, e1+e3, e1+2*e3, ... that are less than or equal to e2.
     171 * `\domain(<r1,...,rn>)` : value of type `Domain[n]`, the ordered Cartesian product of the n ranges (dictionary order)
     172 * `\hasnext(dom, <i, j, …>)`: an expression of boolean type, testing if the domain `dom` contains any element after `<i, j, ...>`
     173* Arrays
    153174 * `\array(T, <e0, ..., en-1>)`: value of type `Array[T, n]`, a literal array
    154175 * `\array(T, n, e)`: value of type `Array[T,n]` in which each of the n elements is `e`
     176 * `\asub(e1, e2)` : array subscript expression.  Note that `e1` must have array type, not pointer type. (This is different from C.)   If `e1` has pointer type, use `\deref(\padd(e1, e2))` instead. 
     177 * `\aslice(a, dom)`, where `a` is an expression of array type and `dom` is an expression of `Domain` type.   The dimension of the array must match the dimension of the domain.   This represents all memory units which are the cells in the array indexed by a tuple in `dom`.
     178 * `\bit_and(e1, e2)`, `\bit_or(e1, e2)`, `\bit_xor(e1, e2)`, `\bit_comp(e1)` : bit-wise operations: arguments are arrays of booleans
     179* Tuples
    155180 * `\tuple(S, <e0, e1, ...>)` : value of tuple type `S` (tuple literal)
    156  * `\range(e1,e2,e3)` : value of type `Range` consisting of the integers e1, e1+e3, e1+2*e3, ... that are less than or equal to e2.
    157  * `\domain(<r1,...,rn>)` : value of type `Domain[n]`, the ordered Cartesian product of the n ranges (dictionary order)
    158  * `"abc"` : string literals: value of type `Array[Char, n+1]`, where n is the length of the string (the last element is the character `\0`)
     181 * `\tsel(e1, i)` : tuple selection of component i of e1.  i must be a literal natural number.
     182* Pointers and Memory
     183 * `NULL` : value of type `void*`
     184 * `\deref(e)` : pointer dereference
     185 * `\addr(e)` : address-of operator
     186 * `\padd(e1, e2)`: pointer addition. `e1` has pointer type and `e2` has an integer type or range type.  If `e2` has integer type the result has pointer type.   Otherwise, the result has `Mem` type.
     187 * `\psub(e1,e2)`: pointer subtraction
     188 * `\region(ptr)`, where `ptr` is an expression with a pointer type.  This represents the set of all memory units reachable from `ptr`, including the memory unit pointed to by `ptr` itself.
     189 * `\mem_union(mem1, mem2)`, where `mem1` and `mem2` are expressions of type `Memory`.  This is the union of the two memory sets.
     190 * `\mem_intersect(mem1, mem1)` : set intersection
     191 * `\mem_comp(mem1)` : set complement (everything not in `mem1`)
     192* Scopes and Processes
    159193 * `\root`, `\here` : values of type `Scope`
    160194 * `\self`, `\proc_null` : values of type `Proc`
    161  * `NULL` : value of type `void*`
    162 * variables
    163 * `\sizeof_type(t)` : the size of the dynamic type t
    164 * `\sizeof_expr(e)` : the size of the value of expression `e`
    165 * `\new(t)` : new (default) value of dynamic type t
    166 * `\defined(e)` : is `e` defined? Type is `Bool`
    167 * `\has_next(dom, <i, j, …>)`: an expression of boolean type, testing if the domain `dom` contains any element after `<i, j, ...>`
    168 * `\add(e1, e2)` : numeric addition. 
    169  * `e1` and `e2` have the same numeric type.  Note that there are no "automatic conversions" as there are in C.  If the original expressions have different types, explicit casts must be inserted. 
    170 * `\padd(e1, e2)`: pointer addition. `e1` has pointer type and `e2` has an integer type or range type.  If `e2` has integer type the result has pointer type.   Otherwise, the result has `Mem` type.
    171 * `\sub(e1, e2)` : subtraction
    172 * `\psub(e1,e2)`: pointer subtraction
    173 * `\mul(e1, e2)` : multiplication
    174 * `\div(e1, e2)` : division
    175  * If both are integer types, the result is integer division.  Otherwise it is real division.  Need to define what happens for negative integers.
    176 * `\mod(e1, e2)` : modulus
    177 * `\asub(e1, e2)` : array subscript expression.  Note that `e1` must have array type, not pointer type. (This is different from C.)   If `e1` has pointer type, use `\deref(\padd(e1, e2))` instead. 
    178 * `\deref(e)` : pointer dereference
    179 * `\addr(e)` : address-of operator
    180 * `\not(e)` : logical not
    181 * `\neg(e)` : negative
    182 * `\cast(T, e)` : casts `e` to a value of the named type
    183  * need to list all of the legal casts and what they mean exactly
    184  * cast of integer to array-of-boolean, and vice-versa?
    185  * **Instead of casts would it be better to have explicit functions for each legal kind of cast?**
    186 * `\eq(e1, e2)`, `\neq(e1, e2)`: equality/inequality test
    187 * `\and(e1, e2)`, `\or(e1, e2)`: logical and/or operation
    188 * `\cond(e1, e2, e3)`: conditional expression, equivalent to `e1?e2:e3` in C.
    189 * `\lt(e1, e2)`, `\lte(e1, e2)`: less than/less than or equal to
    190 * `e0(e1,...,en)` : a function invocation where `e` must evaluate to an abstract or pure system function
    191 * `\forall`, `\exists` :  `\forall {Integer i | e0} e1`. `\exists` is similar.  ** Is this the best notation? **
    192 * `\tuple_read(e1, i)`, some natural number i (tuple read)
    193 * `\bit_and(e1, e2)`, `\bit_or(e1, e2)`, `\bit_xor(e1, e2)`, `\bit_comp(e1)` : bit-wise operations: arguments are arrays of booleans
    194 * a left-hand-side expression, when used in certain contexts, is automatically converted to `Mem`.  The contexts are: arguments to the built-in functions `\access`, `\read`, and `\write` described below, or occurrence in the list of an `\assigns` clause
    195 * `\array_slice(a, dom)`, where `a` is an expression of array type and `dom` is an expression of `Domain` type.   The dimension of the array must match the dimension of the domain.   This represents all memory units which are the cells in the array indexed by a tuple in `dom`.
    196 * `\region(ptr)`, where `ptr` is an expression with a pointer type.  This represents the set of all memory units reachable from `ptr`, including the memory unit pointed to by `ptr` itself.
    197  * **\mem_reach ?**
    198 * `\mem_union(mem1, mem2)`, where `mem1` and `mem2` are expressions of type `Memory`.  This is the union of the two sets.
    199  * **could we use Frama-C notation `p+(e1..e2)` for example?**
    200 
    201 Pointers: unlike C, there is no "array-pointer pun".   If an array `a` needs to be converted to a pointer, you must use `\address_of(\address_of(\array_subscript(a, 0)))`.
     195* Other
     196 * variables
     197 * `\sizeof_type(t)` : the size of the dynamic type t; `Integer` type
     198 * `\sizeof_expr(e)` : the size of the value of expression `e`; `Integer` type
     199 * `\new(t)` : new (default) value of `Dytype` t
     200 * `\defined(e)` : is `e` defined? `Bool` type
     201 * `\cast(e, T)` : casts `e` to a value of the named type
     202  * need to list all of the legal casts and what they mean exactly
     203  * cast of integer to array-of-boolean, and vice-versa?
     204  * **Instead of casts would it be better to have explicit functions for each legal kind of cast?**
     205 * `\ite(e1, e2, e3)`: if-then-else (conditional) expression, equivalent to `e1?e2:e3` in C.
     206 * `e0(e1,...,en)` : a function invocation where `e` must evaluate to either an abstract or pure system function
     207
     208Notes
     209* unlike C, there is no "array-pointer pun".   If an array `a` needs to be converted to a pointer, you must use \addr(\asub(a, 0))`.
    202210
    203211== The Primitive Statements ==