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 ...
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.
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.
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.
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.
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.
RISC-V does not have a flags register, and thus no add-with-carry
instructions. Neither does MIPS.
Add expansions of these instructions in terms of iadd and icmp.
The make_inst_results() method now understands direct and indirect
calls, and can allocate result values matching the return types of the
function call.
These two tables are used to keep track of type signatures of function
calls as well as external function references used in direct function
calls.
Also add an ExtFuncData struct representing an external function that
can be called directly.
Use this source map method for assigning a location to any entity whose
source number is not exposed. This could be
- Instructions.
- Signatures defined implicitly by function decls.
These entities only appear in the location map, not the entity number
maps.
Give these crates each a more standard directory layout with sources in
a 'src' sub-sirectory and Cargo.toml in the top lib/foo directory.
Add license and description fields to each.
The build script for the cretonne crate now lives in
'lib/cretonne/build.rs' separating it from the normal library sources
under 'lib/cretonne/src'.
The 'lib/cretonne' directory will be the new root of a stand-alone
cretonne crate containg both Python and Rust sources.
This is in preparation for publishing crates on crates.io.
The Builder keeps track of a position in the layout and inserts new
instructions there.
Add insert_ebb() and ebb() methods to Builder.
Use Builder in the cfg tests.
The Builder provides a convenient interface for inserting instructions
into an extended basic block.
The bulk of the builder methods are generated automatically from the
meta language instruction descriptions.
Still TODO: Keep track of an insertion position.
In instruction formats that have multiple results AND boxed storage,
place the second_result field outside the boxed storage. The 16-byte
instruction format has room for opcode, type, second_result in the first
8 bytes, and the boxed pointer in the last 8 bytes.
This provides a simpler implementation of the second_result() and
second_result_mut() InstructionData methods.
The Rust type is usually the camel-cased name of the operand kind, but
there are variations, so allow an explicit rust_type='IntCC' when
defining operand kinds.
These refer to external functions and function signatures declared in
the preamble. Since we're already using the type names 'Signature' and
'Function', these entity references don't folow the usual EntityData /
Entity naming convention.
Entity references in instruction format operands also have member names
in the InstructionData struct. Track them the same way we track immediate operand member names.
Value operands still go in the arg / args members.
Enable syntax: iadd(x, y) which creates an Apply node.
Enable syntax: z << iadd(x, y) which creates a Def node.
Add an XForm class which represents source and destination patterns as
RTL lists.
The isplit_lohi instruction breaks an integer into two halves. This will
typically be used to get the two halves of an `i64` value on 32-bit
CPUs.
The iconcat_lohi is the reverse operation. It reconstructs the `i64`
from the low and high bits.