Commit Graph

6452 Commits

Author SHA1 Message Date
Joel Gallant
65052b8450 Typo fix 2016-10-28 08:38:23 -07:00
Joel Gallant
72479b53ff Typo fix 2016-10-28 08:38:23 -07:00
Benjamin Bouvier
18f32f8b56 Add build instructions in the REAME; 2016-10-28 08:36:21 -07:00
Benjamin Bouvier
2cb126341b Add build instructions in the REAME; 2016-10-28 08:36:21 -07:00
Jakob Stoklund Olesen
baf9195080 Add a document comparing Cretonne and LLVM. 2016-10-27 13:41:39 -07:00
Jakob Stoklund Olesen
2fa707bc4f Add a document comparing Cretonne and LLVM. 2016-10-27 13:41:39 -07:00
Jakob Stoklund Olesen
80823b5fc4 Require documentation on cretonne public items. 2016-10-26 19:10:06 -07:00
Jakob Stoklund Olesen
3da569de06 Require documentation on cretonne public items. 2016-10-26 19:10:06 -07:00
Jakob Stoklund Olesen
e2418c6ec9 Require documentation on reader public items. 2016-10-26 17:43:18 -07:00
Jakob Stoklund Olesen
7b3160dbbb Require documentation on reader public items. 2016-10-26 17:43:18 -07:00
Jakob Stoklund Olesen
447baf015e Require documentation on filecheck public items. 2016-10-26 17:34:45 -07:00
Jakob Stoklund Olesen
77cc962380 Require documentation on filecheck public items. 2016-10-26 17:34:45 -07:00
Jakob Stoklund Olesen
15f626ccc0 Begin generating code for the legalizer.
This is a work in progress. The 'legalizer.rs' file generated by
gen_legalizer.py is not used for anything yet.

Add PEP 484 type annotations to a bunch of Python code.
2016-10-26 16:06:57 -07:00
Jakob Stoklund Olesen
bcd5bc559c Begin generating code for the legalizer.
This is a work in progress. The 'legalizer.rs' file generated by
gen_legalizer.py is not used for anything yet.

Add PEP 484 type annotations to a bunch of Python code.
2016-10-26 16:06:57 -07:00
Jakob Stoklund Olesen
d7a479de6d Run mypy if it's available.
The Python tools pyliint, flake8, and mypy are only run if they exist in
$PATH.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
5dc9ea1de4 Run mypy if it's available.
The Python tools pyliint, flake8, and mypy are only run if they exist in
$PATH.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
2a8f8f79ff Create FormatField attributes on demand.
The InstructionFormat objects make their non-value operands available as
FormatField attributes for use by predicates etc.

Compute these on demand instead of up front. This makes it possible for
the mypy tool to infer the types of these attributes from the
__getattr__ signature.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
7722ba91ff Create FormatField attributes on demand.
The InstructionFormat objects make their non-value operands available as
FormatField attributes for use by predicates etc.

Compute these on demand instead of up front. This makes it possible for
the mypy tool to infer the types of these attributes from the
__getattr__ signature.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
ed917c394f Add PEP 484 type annotations to a bunch of Python code.
Along with the mypy tool, this helps find bugs in the Python code
handling the instruction definition data structures.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
6748817985 Add PEP 484 type annotations to a bunch of Python code.
Along with the mypy tool, this helps find bugs in the Python code
handling the instruction definition data structures.
2016-10-26 15:15:51 -07:00
Jakob Stoklund Olesen
31e033af49 File stale path references.
After rearranging the directory layout, some paths in documentation
needed updating.

Fix some typos too.
2016-10-24 13:27:10 -07:00
Jakob Stoklund Olesen
b6ff2621f9 File stale path references.
After rearranging the directory layout, some paths in documentation
needed updating.

Fix some typos too.
2016-10-24 13:27:10 -07:00
Jakob Stoklund Olesen
cf1996b036 Introduce value aliases.
A extended value can now be changed to a third form: An alias of another
value. This is like a copy instruction, but implicit in the value table.

Value aliases are used in lieu of use-def chains which would be used to
implement replace-all-uses-with.

Added new DFG methods:

- change_to_alias() changes an existing extended value into an alias.
  Primay values can't be changed, replace their definition with a copy
  instruction instead.
- resolve_aliases() find the original non-alias value.
- resolve_copies() like resolve_aliases(), but also sees through
  copy/spill/fill instructions.
2016-10-21 11:18:12 -07:00
Jakob Stoklund Olesen
84faddbf65 Introduce value aliases.
A extended value can now be changed to a third form: An alias of another
value. This is like a copy instruction, but implicit in the value table.

Value aliases are used in lieu of use-def chains which would be used to
implement replace-all-uses-with.

Added new DFG methods:

- change_to_alias() changes an existing extended value into an alias.
  Primay values can't be changed, replace their definition with a copy
  instruction instead.
- resolve_aliases() find the original non-alias value.
- resolve_copies() like resolve_aliases(), but also sees through
  copy/spill/fill instructions.
2016-10-21 11:18:12 -07:00
Jakob Stoklund Olesen
e7a17a1b59 Properly infer result type for single-result instructions.
Polymorphic single-result instructions don't always return the
controlling type variable as their first result. They may use a derived
type variable, as for example icmp does.
2016-10-21 11:10:26 -07:00
Jakob Stoklund Olesen
61f5eeee2f Properly infer result type for single-result instructions.
Polymorphic single-result instructions don't always return the
controlling type variable as their first result. They may use a derived
type variable, as for example icmp does.
2016-10-21 11:10:26 -07:00
Jakob Stoklund Olesen
3791e8660d Make Type::as_bool() less pedantic for scalars.
All scalar types are mapped to b1 which is usually what you want for a
scalar. Vector types have their lanes mapped to the wider boolean types.

Add an as_bool_pedantic() methos that produces the scalar sized boolean
types as before.

Also add a friendlier Debug implementation for Type.
2016-10-21 10:43:33 -07:00
Jakob Stoklund Olesen
20aabcd1c7 Make Type::as_bool() less pedantic for scalars.
All scalar types are mapped to b1 which is usually what you want for a
scalar. Vector types have their lanes mapped to the wider boolean types.

Add an as_bool_pedantic() methos that produces the scalar sized boolean
types as before.

Also add a friendlier Debug implementation for Type.
2016-10-21 10:43:33 -07:00
Jakob Stoklund Olesen
ce9049af90 Implement From<i64> for Imm64.
This makes it possible to use literal integers as arguments to
InstBuilder methods.
2016-10-21 10:43:33 -07:00
Jakob Stoklund Olesen
853e995c99 Implement From<i64> for Imm64.
This makes it possible to use literal integers as arguments to
InstBuilder methods.
2016-10-21 10:43:33 -07:00
Jakob Stoklund Olesen
1305283ed8 Move the 'ins' method to DataFlowGraph.
This given us better symmetry between the replace and insert builder operations:

    dfg.replace(inst).iadd(x, y)
    dfg.ins(cursor).imul(x, y)
2016-10-21 09:46:17 -07:00
Jakob Stoklund Olesen
6aa3e4594a Move the 'ins' method to DataFlowGraph.
This given us better symmetry between the replace and insert builder operations:

    dfg.replace(inst).iadd(x, y)
    dfg.ins(cursor).imul(x, y)
2016-10-21 09:46:17 -07:00
Jakob Stoklund Olesen
0acabc80d0 Define live range splitting instructions.
The copy/spill/fill instructions will be used by the register allocator
for splitting live ranges. The copy instruction is also useful when
rewriting values:

If a primary value is rewritten as a secondary result, a copy
instruction can be used instead:

  a = foo x
=>
  t, vx1 = call ...
  a = copy vx1

Since a primary value must be the first value of an instruction, this
doesn't work:

  a = foo x
=>
  t, a = call ...
2016-10-20 15:34:16 -07:00
Jakob Stoklund Olesen
84172ddf98 Define live range splitting instructions.
The copy/spill/fill instructions will be used by the register allocator
for splitting live ranges. The copy instruction is also useful when
rewriting values:

If a primary value is rewritten as a secondary result, a copy
instruction can be used instead:

  a = foo x
=>
  t, vx1 = call ...
  a = copy vx1

Since a primary value must be the first value of an instruction, this
doesn't work:

  a = foo x
=>
  t, a = call ...
2016-10-20 15:34:16 -07:00
Jakob Stoklund Olesen
8422976d78 Add a ReplaceBuilder instruction builder.
The DataFlowGraph::replace(inst) method returns an instruction builder
that will replace an instruction in-place.

This will be used when transforming instructions, replacing an old
instruction with a new (legal) way of computing its primary value. Since
primary result values are essentially instruction pointers, this is the
only way of replacing the definition of a value.

If secondary result values match the old instruction in both number and
types, they can be reused. If not, added a detach_secondary_results()
method for detaching old secondary values.
2016-10-20 13:33:49 -07:00
Jakob Stoklund Olesen
bb0bb1e91c Add a ReplaceBuilder instruction builder.
The DataFlowGraph::replace(inst) method returns an instruction builder
that will replace an instruction in-place.

This will be used when transforming instructions, replacing an old
instruction with a new (legal) way of computing its primary value. Since
primary result values are essentially instruction pointers, this is the
only way of replacing the definition of a value.

If secondary result values match the old instruction in both number and
types, they can be reused. If not, added a detach_secondary_results()
method for detaching old secondary values.
2016-10-20 13:33:49 -07:00
Jakob Stoklund Olesen
d763bedeaa Rename Builder to InsertBuilder.
This instruction builder inserts an instruction at the cursor position.
We'll add other kinds of builders shortly.
2016-10-20 11:16:58 -07:00
Jakob Stoklund Olesen
634de93337 Rename Builder to InsertBuilder.
This instruction builder inserts an instruction at the cursor position.
We'll add other kinds of builders shortly.
2016-10-20 11:16:58 -07:00
Jakob Stoklund Olesen
5f140eddf7 Switch InstrBuilder to the one-shot builder pattern.
All the InstrBuilder methods now consume the builder, and the non-leaf
methods return the dfg mutable reference they were holding.

This makes it possible to construct instruction builders that are only
safe to use once because they are doing more advanced value rewriting.
2016-10-19 19:33:48 -07:00
Jakob Stoklund Olesen
6db94bb980 Switch InstrBuilder to the one-shot builder pattern.
All the InstrBuilder methods now consume the builder, and the non-leaf
methods return the dfg mutable reference they were holding.

This makes it possible to construct instruction builders that are only
safe to use once because they are doing more advanced value rewriting.
2016-10-19 19:33:48 -07:00
Jakob Stoklund Olesen
78312c6c46 Add a Cursor::ins() method which constructs a Builder.
Rewrite Builder uses in test cases to use this method and construct a
new builder for each instruction. This pattern allows us to change the
InstBuilder trait to a one-shot implementation that can only create a
single instruction.

Don't re-export the Builder struct, it is less important than the
InstBuilder trait, and we may get more implementations.
2016-10-19 19:33:19 -07:00
Jakob Stoklund Olesen
ab910b3f58 Add a Cursor::ins() method which constructs a Builder.
Rewrite Builder uses in test cases to use this method and construct a
new builder for each instruction. This pattern allows us to change the
InstBuilder trait to a one-shot implementation that can only create a
single instruction.

Don't re-export the Builder struct, it is less important than the
InstBuilder trait, and we may get more implementations.
2016-10-19 19:33:19 -07:00
Jakob Stoklund Olesen
4cd33b210e Use more precise lifetimes for Builder.
Distinguish the lifetime of the Cursor and its referenced function
layout.

Use two separate function lifetimes: 'fc and 'fd. The borrow checker
seems to get confused if we don't.
2016-10-19 19:32:57 -07:00
Jakob Stoklund Olesen
368b12e7cd Use more precise lifetimes for Builder.
Distinguish the lifetime of the Cursor and its referenced function
layout.

Use two separate function lifetimes: 'fc and 'fd. The borrow checker
seems to get confused if we don't.
2016-10-19 19:32:57 -07:00
Jakob Stoklund Olesen
eef5de1cf0 Generate an InstBuilder trait.
All of the instruction format an opcode methods are emitted as an
InstBuilder trait instead of adding them to the Bulder struct directly.
The methods only make use of the InstBuilderBase methods to create new
instructions.

This makes it possible to reuse the InstBuilder trait for different ways
of inserting instructions.
2016-10-19 18:21:17 -07:00
Jakob Stoklund Olesen
58168bcd07 Generate an InstBuilder trait.
All of the instruction format an opcode methods are emitted as an
InstBuilder trait instead of adding them to the Bulder struct directly.
The methods only make use of the InstBuilderBase methods to create new
instructions.

This makes it possible to reuse the InstBuilder trait for different ways
of inserting instructions.
2016-10-19 18:21:17 -07:00
Jakob Stoklund Olesen
499fefebd9 Rename lifetimes in layout.rs to 'f
These lifetimes all represent the lifetime of the Function.
2016-10-19 16:23:08 -07:00
Jakob Stoklund Olesen
c8f28e5902 Rename lifetimes in layout.rs to 'f
These lifetimes all represent the lifetime of the Function.
2016-10-19 16:23:08 -07:00
Jakob Stoklund Olesen
cdb141d138 Also rebuild if build.rs itself changes.
We already have all the meta/**.py as dependencies.
2016-10-19 12:03:50 -07:00
Jakob Stoklund Olesen
cba5cdd22e Also rebuild if build.rs itself changes.
We already have all the meta/**.py as dependencies.
2016-10-19 12:03:50 -07:00