Commit Graph

901 Commits

Author SHA1 Message Date
Pat Hickey
eb49d9f8bf tests: update ExternalName api 2017-11-23 14:08:47 -08:00
Pat Hickey
894268233e ir::ExternalName representation and constructors rewritten 2017-11-23 14:08:47 -08:00
Jakob Stoklund Olesen
95bdf91e3e Use a bforest::Map for the predecessors in the CFG.
Like before, we store a redundant EBB with each predecessor instruction
which allows invalidate_ebb_successors() to clean up the successor's
predecessor lists even after instructions have been moved around in the
layout.
2017-11-22 13:52:42 -08:00
Jakob Stoklund Olesen
a960730add Add retain() methods to bforest::{Set,Map}.
These work just like their counterparts in HashMap and HashSet.
2017-11-22 13:43:41 -08:00
Jakob Stoklund Olesen
92f378de76 Expose CFG predecessors only as an iterator.
Define two public iterator types in the flowgraph module, PredIter and
SuccIter, which are by-value iterators over an EBB's predecessors and
successors respectively.

Provide matching pred_iter() and succ_iter() methods for inspecting the
CFG. Remove the get_predecessors() method which returned a slice.

Update the uses of get_predecessors(), none of which depended on it
being a slice.

This abstraction makes it possible to change the internal representation
of the CFG.
2017-11-22 09:13:04 -08:00
Tyler McMullen
7956084121 Treat VmContext as positional when using Native CallConv (#195)
* Treat VMContext as standard positional argument when using Native CallConv.

This requires threading the CallConv through legalize_args and into ArgAssigner.

* Stash CallConv in the intel-specific Args struct, for use ArgAssigner.
2017-11-21 17:08:31 -08:00
Jakob Stoklund Olesen
b5d4fb66d9 Use a bforest::Set to represent CFG successor sets.
This has two advantages over the previous Vec<Ebb>:

- Duplicates are removed.
- Clearing the control flow graph is constant time.

The set of EBB successors is simply ordered by EBB number.
2017-11-21 15:03:09 -08:00
Jakob Stoklund Olesen
cf45afa1e7 Avoid the CFG get_successors() when computing a post-order.
The control flow graph does not guarantee any particular ordering for
its successor lists, and the post-order we are computing for building
the dominator tree needs to be "split-invariant".

See #146 for details.

- Discover EBB successors directly from the EBB instruction sequence to
  guarantee that the post-order we compute is canonical/split-invariant.
- Use an alternative graph DFS algorithm which doesn't require indexing
  into a slice of successors.

This changes cfg_postorder in some cases because the edge pruning when
converting the (DAG) CFG to a tree for the DFT is different.
2017-11-21 14:20:57 -08:00
Jakob Stoklund Olesen
2e0b931590 Provide an fmt::Debug impl for entity references.
Instead of deriving a Debug impl: Ebb(45), use the Display version for
Debug too: ebb45.

This is more readable, and no information is lost.
2017-11-21 10:01:55 -08:00
Jakob Stoklund Olesen
2d7b54373f Implement Clone and Default for bforest::{Set,Map}.
The default container is empty. We need a manual implementation of
Default because deriving it seems to imply that K and V generic
parameter types must also implement Default.

Cloning can be used to clone an empty container or for cloning the whole
forest. We can derive this trait because we already require Copy for K
and V.
2017-11-20 15:06:00 -08:00
Jakob Stoklund Olesen
8eaf7d3904 Add iterators for bforest::{Set,Map}.
The iter() methods return an iterator that traverses all set elements /
map key-value pairs. The iterator doesn't require a mutable container
and forest reference, unlike the cursor types.
2017-11-20 14:20:19 -08:00
Jakob Stoklund Olesen
a2ff2a6836 Add goto_first() methods to SetCursor and MapCursor. 2017-11-20 14:16:39 -08:00
Jakob Stoklund Olesen
3389eaef29 Add a clear() method to bforest::{Set,Map}.
This is a lot more efficient that removing entries one by one.
2017-11-20 14:16:19 -08:00
Jakob Stoklund Olesen
d3778e56bb Remove the "BPlus" prefix from bforest::* types.
We'll just use the bforest:: namespace for these types, avoiding the
confusing mix of prefixed and non-prefixed names.

No functional change intended.
2017-11-20 14:15:56 -08:00
Jakob Stoklund Olesen
aa6f5c0db3 Forests of B+ trees.
Add new ordered set and map data structures based on B+-trees. These are
not general-purpose data structures like the BTreeSet and BTreeMap types
in the standard library. They are specialized for:

- Keys and values are small `Copy` types, optimized for 32-bit entities.
- Each set or map has a very small footprint, using only 32 bits of
  memory when empty.
- Keys are compared using a borrowed comparator object which can provide
  context for comparing tiny types that don't contain enough information
  to implement `Ord`.
- A whole forest of B-trees can be cleared in constant time without
  having to traverse the whole data structure.
2017-11-17 07:21:19 -08:00
Jakob Stoklund Olesen
94921c0b74 Remove the dead B-Tree interface.
We're starting over from scratch.
2017-11-17 07:21:19 -08:00
Dan Gohman
bfa5a72b77 Use reserve_exact instead of reserve when the max size is known. 2017-11-16 15:16:23 -08:00
Dan Gohman
4d9aedbaca Add a 'clear()' function to Context.
This includes adding `clear()` functions to its (transitive) members.
2017-11-15 11:15:30 -08:00
Dan Gohman
8dd46054a5 In the verifier, clarify expected versus observed values. 2017-11-09 22:02:07 -08:00
Dan Gohman
ced7a88ecc Use consistent formatting for module-level comments. 2017-11-08 14:49:27 -08:00
Dan Gohman
e213c2654f Fix branch_destination/analyze_branch for BranchInt/BranchFloat. 2017-11-08 10:58:03 -08:00
Dan Gohman
889b06fd16 Replace as casts with type-conversion functions. 2017-11-08 10:48:44 -08:00
Dan Gohman
d939bc5137 Use is_empty() instead of comparing len() with 0. 2017-11-08 10:43:12 -08:00
Dan Gohman
5d3ae0596c Avoid matching with reference patterns. 2017-11-08 10:43:12 -08:00
Dan Gohman
809e2f0c91 Avoid unneeded return keywords. 2017-11-08 10:43:12 -08:00
Dan Gohman
0d825b4643 Remove a redundant .into(). 2017-11-08 10:43:11 -08:00
Dan Gohman
3ab4349c1b Use Self instead of repeating the type name. 2017-11-08 10:43:11 -08:00
Dan Gohman
388ebde41d Use .any(...) rather than .position(...).is_some(). 2017-11-08 10:40:42 -08:00
Dan Gohman
8b053aa923 Remove a trivial cast. 2017-11-08 10:40:39 -08:00
Dan Gohman
d7796cbf25 Suppress an unused-import warning on AsciiExt.
See

https://users.rust-lang.org/t/psa-dealing-with-warning-unused-import-std-ascii-asciiext-in-today-s-nightly/13726

for details.
2017-11-08 10:40:29 -08:00
Dan Gohman
2b6502ac6e Fix handling of CFG triangles in compute_postorder.
For example, in `loops_one`, ebb3 is the bottom of a triangle, so
postorder should order it after the rest of the triangle.
2017-11-07 16:57:22 -08:00
Dan Gohman
5dda19035d Implement Hash for ExternalName.
This allows users to have HashMaps etc. with ExternalNames as keys.
2017-11-06 11:34:09 -08:00
Dan Gohman
4091688cc0 Avoid unnecessary name qualification. 2017-11-06 11:10:03 -08:00
Dan Gohman
d9743290ea Elide elidable lifetime parameters. 2017-11-06 11:09:56 -08:00
Dan Gohman
8501cb798e Minor comment cleanups. 2017-11-03 16:43:29 -07:00
Dan Gohman
acc6d941a3 Combine redundant match arm bodies. 2017-11-03 16:40:51 -07:00
Dan Gohman
5f8b1b9f04 Fix a flake8 lint. 2017-10-31 13:05:26 -07:00
Dan Gohman
871bf95acf Change reloc_ebb to pass a CodeOffset rather than an Ebb index. 2017-10-31 12:26:38 -07:00
Dan Gohman
5d063eb8bc Merge reloc_func and reloc_globalsym into reloc_external. 2017-10-31 12:26:33 -07:00
Dan Gohman
b60b2ce135 Change parse_multiline to follow PEP 257.
The main change is that it avoids creating blank lines when processing
docstrings.

This also adds blank lines in various places to make the generated code
prettier.
2017-10-31 12:21:23 -07:00
Dan Gohman
149a41a684 Clean up copypasta. 2017-10-31 12:21:14 -07:00
Dan Gohman
9c54c3fff0 Introduce globalsym_addr.
This is an instruction used in legalization of GlobalVarData::Sym global
variables.
2017-10-30 13:26:56 -07:00
Dan Gohman
cb805f704d Put BaldrMonkey-specific behavior under a setting.
BaldrMonkey will need to enable allones_funcaddrs.
2017-10-30 13:26:56 -07:00
Dan Gohman
6fc45b070a Add a new kind of GlobalVar for symbolic addresses.
These addresses will allow referencing C/C++/Rust-style global variables
by name directly.
2017-10-30 13:26:56 -07:00
Dan Gohman
c2665385b1 Rename FunctionName to ExternalName. 2017-10-30 13:26:56 -07:00
Dan Gohman
fae5ffb556 Make generated code more consistent with current rustfmt. 2017-10-30 10:06:23 -07:00
Jakob Stoklund Olesen
d37126565e Also consider fixed outputs for replace_global_defines.
Fixes #178.

When an instruction with a fixed output operand defines a globally live
SSA value, we need to check if the fixed register is available in the
`regs.global` set of registers that can be used across EBB boundaries.

If the fixed output register is not available in regs.global, set the
replace_global_defines flag so the output operands are rewritten as
local values.
2017-10-25 14:28:30 -07:00
Jakob Stoklund Olesen
1b71285b34 Return bools in GPR registers.
Boolean types are returned in %rax, so regclass_for_abi_type() should
return GPR.

Fixes #179.
2017-10-25 13:34:55 -07:00
Jakob Stoklund Olesen
02e81dd1d7 Fix build after flake8 update.
There's a new version of flake8 out which doesn't like variables names
i, l, I.

No functional change intended.
2017-10-25 11:40:37 -07:00
Jakob Stoklund Olesen
e8ecf1f809 Add a FixedTied constraint kind for operand constraints.
Fixes #175.

The Intel division instructions have fixed input operands that are
clobbered by fixed output operands, so the value passed as an input will
be clobbered just like a tied operand.

The FixedTied operand constraint is used to indicate a fixed input
operand that has a corresponding output operand with the same fixed
register.

Teach the spiller to teach a FixedTied operand the same as a Tied
operand constraint and make sure that the input value is killed by the
instruction.
2017-10-25 11:22:20 -07:00