| Version 22 (modified by , 10 years ago) ( diff ) |
|---|
The CIVL-IR language. A program in this language is also known as a "CIVL model".
Properties of the language:
- the language is not intended to be written by humans; it is an intermediate form constructed by CIVL. However it should be readable to help debug things
- the language (and grammar) are subsets of CIVL-C
- a CIVL-IR program represents a guarded-transition system explicitly
- as in CIVL-C, there are functions, scopes, and functions can be defined in any scope
- all blocks (including a function body) consist of the following elements:
- a sequence of type definitions
- a sequence of variable declarations with no initializers
- a sequence of function definitions
- a sequence of labeled
$choosestatements. Each clause in the choose statement is a$whenstatement with some guard and a primitive statement, followed by agotostatement
- an array is declared without any length expression. When it is initialized it can specify length.
Example:
$integer f() {
$real x;
$real y;
$float(16,23) z;
L1 :
$choose {
$when (g1) stmt1; goto L2;
$when (g2) stmt2; goto L3;
}
{ // begin new scope
$real x;
L2 :
$choose {
$when (g3) stmt3; goto L4;
...
}
} // end new scope
...
}
// etc.
Static Types
$bool: boolean type, values are$trueand$false$proc: process type$scope: scope type$char: character type. Alternatively, get rid of this and just use an integer type.$mem: type representing set of memory units$bundle: type representing some un-typed chunk of data$heap: heap type$range: ordered set of integers$domain: ordered set of tuples of integers$domain(n), n is an integer at least 1; subtype of above in which all tuples have arity n.
enumtypes.- different from integers or like C?
$integer: the mathematical integers$int(lo,hi,wrap)- lo, hi are integers, wrap is boolean
- finite interval of integers [lo,hi]. If
wrapis true then all operations "wrap", otherwise, any operation resulting in a value outside of the interval results in an exception being thrown. - Do we want to allow
loandhito be any values of type$integer, which means they are dynamic types, like complete array types?
$hint: Herbrand integers. Values are unsimplified symbolic expressions.$real: the mathematical real numbers$float(e,f), e, f are integers, each at least 1. Same question for e and f as for lo and hi.- IEEE754 floating point numbers
$hreal: Herbrand real numbers. Values are unsimplified symbolic expressions.struct(T1,...,Tn)- structure type with named fields. Names may not seem necessary but if you want a subset of CIVL-C...
- What about bit-widths?
union(T1,...,Tn): similar to structT[]: array-of-T- Function<S1,...,Sn;T>
- function consuming S1,...,Sn and returning T. T can be void. The actual notation is the horrible C notation.
void*: all pointersT*: pointer-to-T, subtype of above
When are two types equal?
What are two types compatible?
Type names
Do we need another syntactic category for code that specifies a dynamic type, for example
int[n*m+3].
This can be used in sizeof, ...
Do we need to clearly distinguish dynamic type names and static type names?
Declarations
Declarations follow the C notation. Function prototypes are considered to be declarations similar to variable declarations.
Example of declaration of a function:
$integer f($real x, $bool y);
Additional modifiers that may be placed on any of above:
$pure: the function has no side effects, but may be nondeterministic$abstract: function is a pure, mathematical function: deterministic function of inputs
System functions:
- A function declaration which is not abstract and for which no definition is provided is a system function.
- If the system function is called anywhere in the program, it must be defined by providing Java code in an Enabler and Executor. Failure to do so will result in an exception.
- A system function may modify any memory it can reach. This includes allocating new data on heaps it can reach.
- A system function may have an implicit guard. This is specified how?
- A system function may have an explicit guard. This is specified how?
Example of a declaration of a system function with guard. Fix me:
$bool g($real x, $bool y) { ... }
$integer f($real x, $bool y) $guard g;
Expressions
- literals
$true,$false: values of type$bool- 123, -123, 3.1415, etc. : values of type
$integer,$int,$real,$float- what particular notations for floating values?
- 'a', 'b', ... UNICODE?
(T[]){e0, e1, ...}: values of typeT[](S){e0, ...}: values of typeS(struct literal)e1..e2,e1..e2#e3: values of type$range($domain){r1,...,rn}: value of type$domain(n)"abc": string literals: value of type$char[]$root,$here: values of type$scope$self,$proc_null: values of type$procNULL: value of typevoid*
- variables
$defined(e1)e1+e2: additione1-e2: subtractione1*e2: multiplicatione1/e2: divisione1%e2: moduluse1[e2]: array index*e: pointer dereference&e: address-of!e: logical not-e: negative(T)e: cast expression- cast of integer to array-of-boolean, and vice-versa?
e1==e2,e1!=e2e1&&e2,e1||e2e1?e2:e3e1<e2,e1<=e2e0(e1,...,en): pure function call?$forall,$existse1.i, some natural number i (tuple read)$initial_value(T; e1,...,en)- e1,...,en are expressions of integer type
- the type of this expression is T[e1]...[en]
- array value with base type
Tand lengths e1,...,en - do we need this for more types? E.g., structs of arrays of structs of arrays of ...?
$typeof(...): what is this for?sizeof(T): T is a type name?e1&e2,e1|e2,e1^e2,~e1: bit-wise operations: arguments are arrays of booleans- MemoryUnitExpressions?: are these literal values of type
$mem?- could we use Frama-C notation
p+(e1..e2)for example? - are there conversions between pointers and mems?
- could we use Frama-C notation
The Primitive Statements
- Assign:
e1=e2; - Call:
e0(e1,...,en);ande=e0(e1,...,en);- regular function (one with flow graph)
- function can be system, pure, abstract?
- Spawn:
$spawn e0(e1,...,en);ande=$spawn e0(e1,...,en); - Wait:
$wait(e); - Wailtall?
- Malloc:
e=(T)$malloc(e1,e2);?? - Free:
free(e); - Noop:
;- Is there a need to add annotations for "true" or "false" branch, etc.?
- Return:
return;andreturn e; - Atomic_enter: what notation?
- Atomic_exit: what notation?
- Parfor_spawn. what notation? Is there exit?
- For_dom_enter (for domains). What notation? Is there exit?
Program Graph
Model
Semantics
Semantics issues
- define every possible cast
- define every possible +, etc.
- define every kind of pointer value and casts between pointer types
- casts between pointer and integer types?
