Module Operator.Sig
This defines the syntax for the operators usable in the internal languages of Codex, expressed as signatures as in the Tagless final approach.
The signatures are grouped by type of values manipulated (boolean, integer, bitvector, binary, memory, enum). We define two set of functions: the forward are the normal operations, and the backward exclude the functions of arity 0 (for which a backward operation is meaningless).
module type ARITY = sig ... endArity of function symbols. 'r represents the result type and 'a, 'b, 'c the arguments.
module Forward_Arity : sig ... endStandard arities for forward transfer functions: given the arguments, return the results. These match the arities of the concrete functions they represent (but with concrete types substituted for their abstract counterparts).
module Backward_Arity : sig ... endStandard arities for backward transfer functions (used to refined the arguments from information on the result values). These take the result value 'r as argument and return a new-improved value for each argument. They return None when no improvement is possible for that argument.
Note: in the following, we distinguish between backward and forward because there is no need to implement backward transfer functions for symbols with arity 0.
Boolean transfer functions
Transfer functions for boolean values: not, and (&&), or (||), as well as contants true_ and false_.
module type BOOLEAN_BACKWARD = sig ... endmodule type BOOLEAN_FORWARD = sig ... endInteger transfer functions
Transfer functions for unbounded integers:
- addition (
iadd); subtraction (isub); - multiplication (
imul, in general,itimeswhen multiplying by a constant); - division (
idiv), remainder (imod); - comparisons (
ieqfor==,ilefor<=); - shifts (left
ishland rightishr) - bitwise operations (
ior,iand,ixor).
For the bitwise operation, we assume an infinite two-complement representation: i.e. -1 is represented by an infinite sequence of 1, and 0 by an infinite sequence of 0.
module type INTEGER_BACKWARD = sig ... endmodule type INTEGER_FORWARD_MIN = sig ... endmodule type INTEGER_FORWARD = sig ... endBitvector transfer functions
Purely numerical operations on fixed-size bitvectors. Includes bitwise operations and arithmetic, but not pointer arithmetic.
Note: the size argument is generally the size of both arguments and the result.
module type BITVECTOR_BACKWARD = sig ... endmodule type BITVECTOR_FORWARD = sig ... endmodule type BITVECTOR_FORWARD_WITH_BIMUL_ADD = sig ... endBinary transfer functions
Binary is the name of values handled by C or machine-level programs, i.e. either numeric bitvectors or pointers.
module type BINARY_BACKWARD = sig ... endmodule type BINARY_FORWARD = sig ... endmodule type OFFSET_BACKWARD = sig ... endmodule type OFFSET_FORWARD = sig ... endmodule type BLOCK_BACKWARD = sig ... endmodule type BLOCK_FORWARD = sig ... endEnum transfer functions
Transfer function for enum values. Enums are types with a fixed (small) number of possible cases.
module type ENUM_BACKWARD = sig ... endmodule type ENUM_FORWARD = sig ... endMemory transfer functions
module type MEMORY_BACKWARD = sig ... endmodule type MEMORY_FORWARD = sig ... end