diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-21 00:32:16 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-21 22:16:01 +0200 |
| commit | c05b1caa7c81b945526b77e84b888f48cfa91780 (patch) | |
| tree | 7dc09d5bff1977d757c920e033b08ba1d88be180 | |
| parent | 16b2b6eb6c83685afaa8d447d7837080b901b3d9 (diff) | |
| download | sparse-dev-c05b1caa7c81b945526b77e84b888f48cfa91780.tar.gz | |
doc: add doc for simplification notation
The documention of each simplications is quite dense and
use some implicit conventions for its notation.
Document this notation.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | Documentation/api.rst | 5 | ||||
| -rw-r--r-- | simplify.c | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Documentation/api.rst b/Documentation/api.rst index 1270551c..cb8a0982 100644 --- a/Documentation/api.rst +++ b/Documentation/api.rst @@ -20,3 +20,8 @@ Typing ~~~~~~ .. c:autodoc:: evaluate.h + +Optimization +~~~~~~~~~~~~ + +.. c:autodoc:: simplify.c @@ -7,6 +7,30 @@ /// // Instruction simplification // -------------------------- +// +// Notation +// ^^^^^^^^ +// The following conventions are used to describe the simplications: +// * Uppercase letters are reserved for constants: +// * `M` for a constant mask, +// * `S` for a constant shift, +// * `N` for a constant number of bits (usually other than a shift), +// * `C` or 'K' for others constants. +// * Lowercase letters `a`, `b`, `x`, `y`, ... are used for non-constants +// or when it doesn't matter if the pseudo is a constant or not. +// * Primes are used if needed to distinguish symbols (`M`, `M'`, ...). +// * Expressions or sub-expressions involving only constants are +// understood to be evaluated. +// * `$mask(N)` is used for `((1 << N) -1)` +// * `$trunc(x, N)` is used for `(x & $mask(N))` +// * Expressions like `(-1 << S)`, `(-1 >> S)` and others formulae are +// understood to be truncated to the size of the current instruction +// (needed, since in general this size is not the same as the one used +// by sparse for the evaluation of arithmetic operations). +// * `TRUNC(x, N)` is used for a truncation *to* a size of `N` bits +// * `ZEXT(x, N)` is used for a zero-extension *from* a size of `N` bits +// * `OP(x, C)` is used to represent some generic operation using a constant, +// including `TRUNC(x, N)` and `ZEXT(x, N)`. #include <assert.h> |
