Commit Graph

20 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
34146435e5 Legalize unsigned-to-float conversions for Intel 64.
Also make sure we generate type checks for the controlling type variable
in legalization patterns. This is not needed for encodings since the
encoding tables are already keyed on the controlling type variable.
2017-09-28 11:39:19 -07:00
Jakob Stoklund Olesen
8deca67968 Add legalization patterns for fabs and fneg.
These sign bit manipulations need to use a -0.0 floating point constant
which we didn't have a way of materializing previously.

Add a ieee32.bits(0x...) syntax to the Python AST nodes that creates am
f32 immediate value with the exact requested bitwise representation.
2017-09-25 12:15:33 -07:00
d1m0
66da171050 Fix for #141 (#142)
* Add Atom and Literal base classes to CDSL Ast. Change substitution() and copy() on Def/Apply/Rtl to support substituting Var->Union[Var, Literal]. Check in Apply() constructor kinds of passed in Literals respect instruction signature

* Change verify_semantics to check all possible instantiations of enumerated immediates (needed to descrive icmp). Add all bitvector comparison primitives and bvite; Change set_semantics to optionally accept XForms; Add semantics for icmp; Fix typing errors in semantics/{smtlib, elaborate, __init__}.py after the change of VarMap->VarAtomMap

* Forgot macros.py

* Nit obscured by testing with mypy enabled present.

* Typo
2017-08-14 20:19:47 -07:00
Jakob Stoklund Olesen
b1508d8588 Include bound typevars in the instruction predicate.
We already do this for the encoding tables, but the instruction
predicates computed by Apply.inst_predicate() did not include them.

Make sure we don't duplicate the type check in the Encoding constructor
when passed an Apply AST node.
2017-07-28 14:56:45 -07:00
Jakob Stoklund Olesen
b5076108c1 Support constant integers in AST expressions.
Make it possible to write AST nodes: iconst.i32(imm64(0)).
2017-07-28 13:54:25 -07:00
Dimo
b5e1e4d454 Add smtlib.py 2017-07-28 10:47:08 -07:00
Dimo
20d96a1ac4 Handle non-ssa Vars and Enumerator constants in Rtl substitutions 2017-07-24 15:49:34 -07:00
Dimo
74f72a3b43 Documentation nits; Sematnics syntax cleanup 2017-07-24 14:08:44 -07:00
Dimo
a12fa86e60 Add the BVType; Add suport for bitvectors in TypeVar and TypeSet. 2017-07-24 14:08:44 -07:00
Dimo
605886a277 Rename Dict[Var, TypeVar] to VarTyping; Add VarMap (Dict[Var,Var]). Add {Ast, Def, Rtl}.{vars(), substitution()} and Def.uses(), Def.definitions() - these enable checking structural equivalence between Rtls and doing variable substitutions between compatible Rtls; Add TypeEnv.permits() routine - allows checking if a given TypeEnv allows a given concrete typing without enumerating all typings (will be useful for determing which semantic transform applies to a given concrete typing). 2017-07-24 14:08:44 -07:00
d1m0
fc11ae7b72 Emit runtime type checks in legalizer.rs (#112)
* Emit runtime type checks in legalizer.rs
2017-07-10 15:28:32 -07:00
d1m0
e35398842d Add better type inference and encapsulate it in its own file (#110)
* Add more rigorous type inference and encapsulate the type inferece code in its own file (ti.py).

Add constraints accumulation during type inference, to represent constraints that cannot be expressed
using bijective derivation functions between typevars.

Add testing for new type inference code.

* Additional annotations to appease mypy
2017-07-05 09:16:44 -07:00
Jakob Stoklund Olesen
0403845c40 Add Apply.inst_predicate().
Compute an instruction predicate from any constant values given as
arguments for the immediate operands in an instruction pattern.

Allows for patterns like icmp.i32(intcc.ugt, x, y) or iadd_imm.i32(x, 1)

Trap these predicates in the legalizer code generator since we can't
actually handle them yet.
2017-03-31 13:46:39 -07:00
Jakob Stoklund Olesen
cfe2c7f46f Add more mypy annotations. 2017-03-30 15:16:44 -07:00
Jakob Stoklund Olesen
aa06e40456 Allow dot syntax notation for enumerated immediate operands.
The meta language patterns sometimes need to refer to specific values of
enumerated immediate operands. The dot syntax provides a namespaced,
typed way of doing that: icmp(intcc.ult, a, x).

Add an ast.Enumerator class for representing this kind of AST leaf node.

Add value definitions for the intcc and floatcc immediate operand kinds.
2017-03-30 11:37:05 -07:00
Jakob Stoklund Olesen
c01ff670ed Fixed for mypy 0.501.
The List and Dict types are no longer implicitly available. They must be
imported from typing.

Type annotations must appear before the doc comment in a function. Also
fix type errors in these functions that weren't detected before.
2017-03-03 09:08:28 -08:00
Jakob Stoklund Olesen
59eef69a4f Emit type arguments to builder methods that need it.
Use the inferred type variables to construct a type argument for builder
methods. This is for those instructions where the result types cannot be
computed from the result types.
2016-11-10 15:55:54 -08:00
Jakob Stoklund Olesen
36871d3fb1 Add TypeVar.rust_expr().
Generate a Rust expression that computes the value of a derived type
variable.
2016-11-10 15:47:57 -08:00
Jakob Stoklund Olesen
68c9f20b77 Infer type constraints on patterns.
Each instruction used in a pattern has constraints on the types of its
operands. These constraints are expressed as symbolic type variables.

Compute type variables for each variable used in a transformation
pattern. Some are free type variables, and some are derived from the
free type variables.

The type variables associated with variables can be used for computing
the result types of replacement instructions that don't support simple
forward type inference from their inputs.

The type sets computed by this patch are conservatively too large, so
they can't yet be used to type check patterns.
2016-11-10 13:26:07 -08:00
Jakob Stoklund Olesen
cc86964ab3 Move ast, xform, and legalize modules.
- cdsl.ast defines classes representing abstract syntax trees.
- cdsl.xform defines classes for instruction transformations.
- base.legalize defines legalization patterns.
2016-11-08 12:33:50 -08:00