Say "IR" instead of "IL".

While the specifics of these terms are debatable, "IR" generally
isn't incorrect in this context, and is the more widely recognized
term at this time.

See also the discussion in #267.

Fixes #267.
This commit is contained in:
Dan Gohman
2018-03-28 14:15:01 -07:00
parent a297465c25
commit 57cd69d8b4
45 changed files with 106 additions and 119 deletions

View File

@@ -3,7 +3,7 @@ Cretonne Code Generator
======================= =======================
Cretonne is a low-level retargetable code generator. It translates a `target-independent Cretonne is a low-level retargetable code generator. It translates a `target-independent
intermediate language <https://cretonne.readthedocs.io/en/latest/langref.html>`_ into executable intermediate representation <https://cretonne.readthedocs.io/en/latest/langref.html>`_ into executable
machine code. machine code.
*This is a work in progress that is not yet functional.* *This is a work in progress that is not yet functional.*

View File

@@ -16,8 +16,8 @@ highlighting some of the differences and similarities. Both projects:
- Use an ISA-agnostic input language in order to mostly abstract away the - Use an ISA-agnostic input language in order to mostly abstract away the
differences between target instruction set architectures. differences between target instruction set architectures.
- Depend extensively on SSA form. - Depend extensively on SSA form.
- Have both textual and in-memory forms of their primary intermediate language. - Have both textual and in-memory forms of their primary intermediate
(LLVM also has a binary bitcode format; Cretonne doesn't.) representation. (LLVM also has a binary bitcode format; Cretonne doesn't.)
- Can target multiple ISAs. - Can target multiple ISAs.
- Can cross-compile by default without rebuilding the code generator. - Can cross-compile by default without rebuilding the code generator.
@@ -41,8 +41,8 @@ LLVM uses multiple intermediate representations as it translates a program to
binary machine code: binary machine code:
`LLVM IR <https://llvm.org/docs/LangRef.html>`_ `LLVM IR <https://llvm.org/docs/LangRef.html>`_
This is the primary intermediate language which has textual, binary, and This is the primary intermediate representation which has textual, binary, and
in-memory representations. It serves two main purposes: in-memory forms. It serves two main purposes:
- An ISA-agnostic, stable(ish) input language that front ends can generate - An ISA-agnostic, stable(ish) input language that front ends can generate
easily. easily.
@@ -89,9 +89,9 @@ representation. Some target ISAs have a fast instruction selector that can
translate simple code directly to MachineInstrs, bypassing SelectionDAG when translate simple code directly to MachineInstrs, bypassing SelectionDAG when
possible. possible.
:doc:`Cretonne <langref>` uses a single intermediate language to cover these :doc:`Cretonne <langref>` uses a single intermediate representation to cover
levels of abstraction. This is possible in part because of Cretonne's smaller these levels of abstraction. This is possible in part because of Cretonne's
scope. smaller scope.
- Cretonne does not provide assemblers and disassemblers, so it is not - Cretonne does not provide assemblers and disassemblers, so it is not
necessary to be able to represent every weird instruction in an ISA. Only necessary to be able to represent every weird instruction in an ISA. Only
@@ -102,7 +102,7 @@ scope.
- SSA form is preserved throughout. After register allocation, each SSA value - SSA form is preserved throughout. After register allocation, each SSA value
is annotated with an assigned ISA register or stack slot. is annotated with an assigned ISA register or stack slot.
The Cretonne intermediate language is similar to LLVM IR, but at a slightly The Cretonne intermediate representation is similar to LLVM IR, but at a slightly
lower level of abstraction. lower level of abstraction.
Program structure Program structure
@@ -112,12 +112,12 @@ In LLVM IR, the largest representable unit is the *module* which corresponds
more or less to a C translation unit. It is a collection of functions and more or less to a C translation unit. It is a collection of functions and
global variables that may contain references to external symbols too. global variables that may contain references to external symbols too.
In Cretonne IL, the largest representable unit is the *function*. This is so In Cretonne IR, the largest representable unit is the *function*. This is so
that functions can easily be compiled in parallel without worrying about that functions can easily be compiled in parallel without worrying about
references to shared data structures. Cretonne does not have any references to shared data structures. Cretonne does not have any
inter-procedural optimizations like inlining. inter-procedural optimizations like inlining.
An LLVM IR function is a graph of *basic blocks*. A Cretonne IL function is a An LLVM IR function is a graph of *basic blocks*. A Cretonne IR function is a
graph of *extended basic blocks* that may contain internal branch instructions. graph of *extended basic blocks* that may contain internal branch instructions.
The main difference is that an LLVM conditional branch instruction has two The main difference is that an LLVM conditional branch instruction has two
target basic blocks---a true and a false edge. A Cretonne branch instruction target basic blocks---a true and a false edge. A Cretonne branch instruction

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Sphinx domain for documenting compiler intermediate languages. # Sphinx domain for documenting compiler intermediate representations.
# #
# This defines a 'cton' Sphinx domain with the following directives and roles: # This defines a 'cton' Sphinx domain with the following directives and roles:
# #
@@ -29,10 +29,10 @@ import sphinx.ext.autodoc
class CtonObject(ObjectDescription): class CtonObject(ObjectDescription):
""" """
Any kind of Cretonne IL object. Any kind of Cretonne IR object.
This is a shared base class for the different kinds of indexable objects This is a shared base class for the different kinds of indexable objects
in the Cretonne IL reference. in the Cretonne IR reference.
""" """
option_spec = { option_spec = {
'noindex': directives.flag, 'noindex': directives.flag,
@@ -98,7 +98,7 @@ def parse_type(name, signode):
class CtonType(CtonObject): class CtonType(CtonObject):
"""A Cretonne IL type description.""" """A Cretonne IR type description."""
def handle_signature(self, sig, signode): def handle_signature(self, sig, signode):
""" """
@@ -112,7 +112,7 @@ class CtonType(CtonObject):
return name return name
def get_index_text(self, name): def get_index_text(self, name):
return name + ' (IL type)' return name + ' (IR type)'
sep_equal = re.compile('\s*=\s*') sep_equal = re.compile('\s*=\s*')
@@ -127,7 +127,7 @@ def parse_params(s, signode):
class CtonInst(CtonObject): class CtonInst(CtonObject):
"""A Cretonne IL instruction.""" """A Cretonne IR instruction."""
doc_field_types = [ doc_field_types = [
TypedField('argument', label=l_('Arguments'), TypedField('argument', label=l_('Arguments'),
@@ -176,11 +176,11 @@ class CtonInst(CtonObject):
class CtonInstGroup(CtonObject): class CtonInstGroup(CtonObject):
"""A Cretonne IL instruction group.""" """A Cretonne IR instruction group."""
class CretonneDomain(Domain): class CretonneDomain(Domain):
"""Cretonne domain for intermediate language objects.""" """Cretonne domain for IR objects."""
name = 'cton' name = 'cton'
label = 'Cretonne' label = 'Cretonne'

View File

@@ -5,19 +5,19 @@ Cretonne Language Reference
.. default-domain:: cton .. default-domain:: cton
.. highlight:: cton .. highlight:: cton
The Cretonne intermediate language (:term:`IL`) has two equivalent The Cretonne intermediate representation (:term:`IR`) has two primary forms:
representations: an *in-memory data structure* that the code generator library an *in-memory data structure* that the code generator library is using, and a
is using, and a *text format* which is used for test cases and debug output. *text format* which is used for test cases and debug output.
Files containing Cretonne textual IL have the ``.cton`` filename extension. Files containing Cretonne textual IR have the ``.cton`` filename extension.
This reference uses the text format to describe IL semantics but glosses over This reference uses the text format to describe IR semantics but glosses over
the finer details of the lexical and syntactic structure of the format. the finer details of the lexical and syntactic structure of the format.
Overall structure Overall structure
================= =================
Cretonne compiles functions independently. A ``.cton`` IL file may contain Cretonne compiles functions independently. A ``.cton`` IR file may contain
multiple functions, and the programmatic API can create multiple function multiple functions, and the programmatic API can create multiple function
handles at the same time, but the functions don't share any data or reference handles at the same time, but the functions don't share any data or reference
each other directly. each other directly.
@@ -27,7 +27,7 @@ This is a simple C function that computes the average of an array of floats:
.. literalinclude:: example.c .. literalinclude:: example.c
:language: c :language: c
Here is the same function compiled into Cretonne IL: Here is the same function compiled into Cretonne IR:
.. literalinclude:: example.cton .. literalinclude:: example.cton
:language: cton :language: cton
@@ -77,7 +77,7 @@ variable value for the next iteration.
The `cton_frontend` crate contains utilities for translating from programs The `cton_frontend` crate contains utilities for translating from programs
containing multiple assignments to the same variables into SSA form for containing multiple assignments to the same variables into SSA form for
Cretonne :term:`IL`. Cretonne :term:`IR`.
Such variables can also be presented to Cretonne as :term:`stack slot`\s. Such variables can also be presented to Cretonne as :term:`stack slot`\s.
Stack slots are accessed with the :inst:`stack_store` and :inst:`stack_load` Stack slots are accessed with the :inst:`stack_store` and :inst:`stack_load`
@@ -303,7 +303,7 @@ indicate the different kinds of immediate operands on an instruction.
A floating point condition code. See the :inst:`fcmp` instruction for details. A floating point condition code. See the :inst:`fcmp` instruction for details.
The two IEEE floating point immediate types :type:`ieee32` and :type:`ieee64` The two IEEE floating point immediate types :type:`ieee32` and :type:`ieee64`
are displayed as hexadecimal floating point literals in the textual :term:`IL` are displayed as hexadecimal floating point literals in the textual :term:`IR`
format. Decimal floating point literals are not allowed because some computer format. Decimal floating point literals are not allowed because some computer
systems can round differently when converting to binary. The hexadecimal systems can round differently when converting to binary. The hexadecimal
floating point format is mostly the same as the one used by C99, but extended floating point format is mostly the same as the one used by C99, but extended
@@ -563,7 +563,7 @@ runtime data structures.
alignment for storing a pointer. alignment for storing a pointer.
Chains of ``deref`` global variables are possible, but cycles are not Chains of ``deref`` global variables are possible, but cycles are not
allowed. They will be caught by the IL verifier. allowed. They will be caught by the IR verifier.
:arg BaseGV: Global variable containing the base pointer. :arg BaseGV: Global variable containing the base pointer.
:arg Offset: Byte offset from the loaded base pointer to the global :arg Offset: Byte offset from the loaded base pointer to the global
@@ -1154,19 +1154,11 @@ Glossary
The extended basic blocks which contain all the executable code in a The extended basic blocks which contain all the executable code in a
function. The function body follows the function preamble. function. The function body follows the function preamble.
intermediate language
IL
The language used to describe functions to Cretonne. This reference
describes the syntax and semantics of the Cretonne IL. The IL has two
forms: Textual and an in-memory intermediate representation
(:term:`IR`).
intermediate representation intermediate representation
IR IR
The in-memory representation of :term:`IL`. The data structures The language used to describe functions to Cretonne. This reference
Cretonne uses to represent a program internally are called the describes the syntax and semantics of Cretonne IR. The IR has two
intermediate representation. Cretonne's IR can be converted to text forms: Textual, and an in-memory data structure.
losslessly.
stack slot stack slot
A fixed size memory allocation in the current function's activation A fixed size memory allocation in the current function's activation

View File

@@ -89,7 +89,7 @@ easier to provide substantial input functions for the compiler tests.
File tests are :file:`*.cton` files in the :file:`filetests/` directory File tests are :file:`*.cton` files in the :file:`filetests/` directory
hierarchy. Each file has a header describing what to test followed by a number hierarchy. Each file has a header describing what to test followed by a number
of input functions in the :doc:`Cretonne textual intermediate language of input functions in the :doc:`Cretonne textual intermediate representation
<langref>`: <langref>`:
.. productionlist:: .. productionlist::
@@ -166,7 +166,7 @@ Cretonne's tests don't need this.
---------- ----------
This is one of the simplest file tests, used for testing the conversion to and This is one of the simplest file tests, used for testing the conversion to and
from textual IL. The ``test cat`` command simply parses each function and from textual IR. The ``test cat`` command simply parses each function and
converts it back to text again. The text of each function is then matched converts it back to text again. The text of each function is then matched
against the associated filecheck directives. against the associated filecheck directives.
@@ -188,7 +188,7 @@ Example::
`test verifier` `test verifier`
--------------- ---------------
Run each function through the IL verifier and check that it produces the Run each function through the IR verifier and check that it produces the
expected error messages. expected error messages.
Expected error messages are indicated with an ``error:`` directive *on the Expected error messages are indicated with an ``error:`` directive *on the
@@ -351,4 +351,4 @@ Each function is passed through the full ``Context::compile()`` function
which is normally used to compile code. This type of test often depends which is normally used to compile code. This type of test often depends
on assertions or verifier errors, but it is also possible to use on assertions or verifier errors, but it is also possible to use
filecheck directives which will be matched against the final form of the filecheck directives which will be matched against the final form of the
Cretonne IL right before binary machine code emission. Cretonne IR right before binary machine code emission.

View File

@@ -1,6 +1,6 @@
//! The `cat` sub-command. //! The `cat` sub-command.
//! //!
//! Read a sequence of Cretonne IL files and print them again to stdout. This has the effect of //! Read a sequence of Cretonne IR files and print them again to stdout. This has the effect of
//! normalizing formatting and removing comments. //! normalizing formatting and removing comments.
use cton_reader::parse_functions; use cton_reader::parse_functions;

View File

@@ -1,6 +1,4 @@
//! CLI tool to compile cretonne IL into native code. //! CLI tool to read Cretonne IR files and compile them into native code.
//!
//! Reads IR files into Cretonne IL and compiles it.
use cton_reader::parse_test; use cton_reader::parse_test;
use std::path::PathBuf; use std::path::PathBuf;

View File

@@ -38,12 +38,12 @@ Options:
-T, --time-passes -T, --time-passes
print pass timing report print pass timing report
-t, --just-decode -t, --just-decode
just decode WebAssembly to Cretonne IL just decode WebAssembly to Cretonne IR
-s, --print-size -s, --print-size
prints generated code size prints generated code size
-c, --check-translation -c, --check-translation
just checks the correctness of Cretonne IL translated from WebAssembly just checks the correctness of Cretonne IR translated from WebAssembly
-p, --print print the resulting Cretonne IL -p, --print print the resulting Cretonne IR
-h, --help print this help message -h, --help print this help message
--set=<set> configure Cretonne settings --set=<set> configure Cretonne settings
--isa=<isa> specify the Cretonne ISA --isa=<isa> specify the Cretonne ISA

View File

@@ -1,6 +1,6 @@
//! The `print-cfg` sub-command. //! The `print-cfg` sub-command.
//! //!
//! Read a series of Cretonne IL files and print their control flow graphs //! Read a series of Cretonne IR files and print their control flow graphs
//! in graphviz format. //! in graphviz format.
use CommandResult; use CommandResult;

View File

@@ -1,6 +1,6 @@
//! CLI tool to use the functions provided by the [cretonne-wasm](../cton_wasm/index.html) crate. //! CLI tool to use the functions provided by the [cretonne-wasm](../cton_wasm/index.html) crate.
//! //!
//! Reads Wasm binary files, translates the functions' code to Cretonne IL. //! Reads Wasm binary files, translates the functions' code to Cretonne IR.
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, cyclomatic_complexity))] #![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, cyclomatic_complexity))]
use cton_wasm::{translate_module, DummyEnvironment, ModuleEnvironment}; use cton_wasm::{translate_module, DummyEnvironment, ModuleEnvironment};

View File

@@ -1,2 +1,2 @@
This crate contains the core Cretonne code generator. It translates code from an This crate contains the core Cretonne code generator. It translates code from an
intermediate language into executable machine code. intermediate representation into executable machine code.

View File

@@ -2,7 +2,7 @@
The cretonne.formats defines all instruction formats. The cretonne.formats defines all instruction formats.
Every instruction format has a corresponding `InstructionData` variant in the Every instruction format has a corresponding `InstructionData` variant in the
Rust representation of cretonne IL, so all instruction formats must be defined Rust representation of Cretonne IR, so all instruction formats must be defined
in this module. in this module.
""" """
from __future__ import absolute_import from __future__ import absolute_import

View File

@@ -20,10 +20,10 @@ opt_level = EnumSetting(
enable_verifier = BoolSetting( enable_verifier = BoolSetting(
""" """
Run the Cretonne IL verifier at strategic times during compilation. Run the Cretonne IR verifier at strategic times during compilation.
This makes compilation slower but catches many bugs. The verifier is This makes compilation slower but catches many bugs. The verifier is
disabled by default, except when reading Cretonne IL from a text file. disabled by default, except when reading Cretonne IR from a text file.
""", """,
default=True) default=True)

View File

@@ -559,7 +559,7 @@ class Enumerator(Literal):
is an AST leaf node representing one of the values. is an AST leaf node representing one of the values.
:param kind: The enumerated `ImmediateKind` containing the value. :param kind: The enumerated `ImmediateKind` containing the value.
:param value: The textual IL representation of the value. :param value: The textual IR representation of the value.
`Enumerator` nodes are not usually created directly. They are created by `Enumerator` nodes are not usually created directly. They are created by
using the dot syntax on immediate kinds: `intcc.ult`. using the dot syntax on immediate kinds: `intcc.ult`.

View File

@@ -20,7 +20,7 @@ use std::ptr::write_unaligned;
/// A `CodeSink` that writes binary machine code directly into memory. /// A `CodeSink` that writes binary machine code directly into memory.
/// ///
/// A `MemoryCodeSink` object should be used when emitting a Cretonne IL function into executable /// A `MemoryCodeSink` object should be used when emitting a Cretonne IR function into executable
/// memory. It writes machine code directly to a raw pointer without any bounds checking, so make /// memory. It writes machine code directly to a raw pointer without any bounds checking, so make
/// sure to allocate enough memory for the whole function. The number of bytes required is returned /// sure to allocate enough memory for the whole function. The number of bytes required is returned
/// by the `Context::compile()` function. /// by the `Context::compile()` function.

View File

@@ -1,6 +1,6 @@
//! IL entity references. //! Cretonne IR entity references.
//! //!
//! Instructions in Cretonne IL need to reference other entities in the function. This can be other //! Instructions in Cretonne IR need to reference other entities in the function. This can be other
//! parts of the function like extended basic blocks or stack slots, or it can be external entities //! parts of the function like extended basic blocks or stack slots, or it can be external entities
//! that are declared in the function preamble in the text format. //! that are declared in the function preamble in the text format.
//! //!
@@ -16,7 +16,7 @@
//! data structures use the `PackedOption<EntityRef>` representation, while function arguments and //! data structures use the `PackedOption<EntityRef>` representation, while function arguments and
//! return values prefer the more Rust-like `Option<EntityRef>` variant. //! return values prefer the more Rust-like `Option<EntityRef>` variant.
//! //!
//! The entity references all implement the `Display` trait in a way that matches the textual IL //! The entity references all implement the `Display` trait in a way that matches the textual IR
//! format. //! format.
use std::fmt; use std::fmt;

View File

@@ -55,7 +55,7 @@ pub struct Function {
/// ///
/// This information is only transiently available after the `binemit::relax_branches` function /// This information is only transiently available after the `binemit::relax_branches` function
/// computes it, and it can easily be recomputed by calling that function. It is not included /// computes it, and it can easily be recomputed by calling that function. It is not included
/// in the textual IL format. /// in the textual IR format.
pub offsets: EbbOffsets, pub offsets: EbbOffsets,
/// Source locations. /// Source locations.

View File

@@ -1,7 +1,7 @@
//! Instruction formats and opcodes. //! Instruction formats and opcodes.
//! //!
//! The `instructions` module contains definitions for instruction formats, opcodes, and the //! The `instructions` module contains definitions for instruction formats, opcodes, and the
//! in-memory representation of IL instructions. //! in-memory representation of IR instructions.
//! //!
//! A large part of this module is auto-generated from the instruction descriptions in the meta //! A large part of this module is auto-generated from the instruction descriptions in the meta
//! directory. //! directory.

View File

@@ -71,8 +71,7 @@ impl Layout {
// within an EBB. The instruction sequence numbers are all between the sequence number of their // within an EBB. The instruction sequence numbers are all between the sequence number of their
// containing EBB and the following EBB. // containing EBB and the following EBB.
// //
// The result is that sequence numbers work like BASIC line numbers for the textual representation // The result is that sequence numbers work like BASIC line numbers for the textual form of the IR.
// of the IL.
type SequenceNumber = u32; type SequenceNumber = u32;
// Initial stride assigned to new sequence numbers. // Initial stride assigned to new sequence numbers.

View File

@@ -6,7 +6,7 @@ use std::str::FromStr;
/// The name of a runtime library routine. /// The name of a runtime library routine.
/// ///
/// Runtime library calls are generated for Cretonne IL instructions that don't have an equivalent /// Runtime library calls are generated for Cretonne IR instructions that don't have an equivalent
/// ISA instruction or an easy macro expansion. A `LibCall` is used as a well-known name to refer to /// ISA instruction or an easy macro expansion. A `LibCall` is used as a well-known name to refer to
/// the runtime library routine. This way, Cretonne doesn't have to know about the naming /// the runtime library routine. This way, Cretonne doesn't have to know about the naming
/// convention in the embedding VM's runtime library. /// convention in the embedding VM's runtime library.

View File

@@ -1,4 +1,4 @@
//! Representation of Cretonne IL functions. //! Representation of Cretonne IR functions.
pub mod types; pub mod types;
pub mod entities; pub mod entities;

View File

@@ -12,7 +12,7 @@ use std::cmp;
/// 1. An instruction or /// 1. An instruction or
/// 2. An EBB header. /// 2. An EBB header.
/// ///
/// This corresponds more or less to the lines in the textual representation of Cretonne IL. /// This corresponds more or less to the lines in the textual form of Cretonne IR.
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
pub struct ProgramPoint(u32); pub struct ProgramPoint(u32);

View File

@@ -7,7 +7,7 @@ use std::fmt;
/// A source location. /// A source location.
/// ///
/// This is an opaque 32-bit number attached to each Cretonne IL instruction. Cretonne does not /// This is an opaque 32-bit number attached to each Cretonne IR instruction. Cretonne does not
/// interpret source locations in any way, they are simply preserved from the input to the output. /// interpret source locations in any way, they are simply preserved from the input to the output.
/// ///
/// The default source location uses the all-ones bit pattern `!0`. It is used for instructions /// The default source location uses the all-ones bit pattern `!0`. It is used for instructions

View File

@@ -45,7 +45,7 @@ fn vmctx_addr(inst: ir::Inst, func: &mut ir::Function, offset: i64) {
/// Expand a `global_addr` instruction for a deref global. /// Expand a `global_addr` instruction for a deref global.
fn deref_addr(inst: ir::Inst, func: &mut ir::Function, base: ir::GlobalVar, offset: i64) { fn deref_addr(inst: ir::Inst, func: &mut ir::Function, base: ir::GlobalVar, offset: i64) {
// We need to load a pointer from the `base` global variable, so insert a new `global_addr` // We need to load a pointer from the `base` global variable, so insert a new `global_addr`
// instruction. This depends on the iterative legalization loop. Note that the IL verifier // instruction. This depends on the iterative legalization loop. Note that the IR verifier
// detects any cycles in the `deref` globals. // detects any cycles in the `deref` globals.
let ptr_ty = func.dfg.value_type(func.dfg.first_result(inst)); let ptr_ty = func.dfg.value_type(func.dfg.first_result(inst));
let mut pos = FuncCursor::new(func).at_inst(inst); let mut pos = FuncCursor::new(func).at_inst(inst);

View File

@@ -15,7 +15,7 @@ use std::vec::Vec;
/// A diversion of a value from its original location to a new register or stack location. /// A diversion of a value from its original location to a new register or stack location.
/// ///
/// In IL, a diversion is represented by a `regmove` instruction, possibly a chain of them for the /// In IR, a diversion is represented by a `regmove` instruction, possibly a chain of them for the
/// same value. /// same value.
/// ///
/// When tracking diversions, the `from` field is the original assigned value location, and `to` is /// When tracking diversions, the `from` field is the original assigned value location, and `to` is

View File

@@ -15,9 +15,9 @@ pub enum CtonError {
/// code. This should never happen for validated WebAssembly code. /// code. This should never happen for validated WebAssembly code.
InvalidInput, InvalidInput,
/// An IL verifier error. /// An IR verifier error.
/// ///
/// This always represents a bug, either in the code that generated IL for Cretonne, or a bug /// This always represents a bug, either in the code that generated IR for Cretonne, or a bug
/// in Cretonne itself. /// in Cretonne itself.
Verifier(verifier::Error), Verifier(verifier::Error),

View File

@@ -41,11 +41,11 @@ define_passes!{
Pass, NUM_PASSES, DESCRIPTIONS; Pass, NUM_PASSES, DESCRIPTIONS;
process_file: "Processing test file", process_file: "Processing test file",
parse_text: "Parsing textual Cretonne IL", parse_text: "Parsing textual Cretonne IR",
wasm_translate_module: "Translate WASM module", wasm_translate_module: "Translate WASM module",
wasm_translate_function: "Translate WASM function", wasm_translate_function: "Translate WASM function",
verifier: "Verify Cretonne IL", verifier: "Verify Cretonne IR",
verify_cssa: "Verify CSSA", verify_cssa: "Verify CSSA",
verify_liveness: "Verify live ranges", verify_liveness: "Verify live ranges",
verify_locations: "Verify value locations", verify_locations: "Verify value locations",

View File

@@ -1,8 +1,7 @@
//! Converting Cretonne IL to text. //! Converting Cretonne IR to text.
//! //!
//! The `write` module provides the `write_function` function which converts an IL `Function` to an //! The `write` module provides the `write_function` function which converts an IR `Function` to an
//! equivalent textual representation. This textual representation can be read back by the //! equivalent textual form. This textual form can be read back by the `cretonne-reader` crate.
//! `cretonne-reader` crate.
use ir::{Function, DataFlowGraph, Ebb, Inst, Value, ValueDef, Type, SigRef}; use ir::{Function, DataFlowGraph, Ebb, Inst, Value, ValueDef, Type, SigRef};
use isa::{TargetIsa, RegInfo}; use isa::{TargetIsa, RegInfo};

View File

@@ -1,4 +1,4 @@
//! Test command for checking the IL legalizer. //! Test command for checking the IR legalizer.
//! //!
//! The `test legalizer` test command runs each function through `legalize_function()` and sends //! The `test legalizer` test command runs each function through `legalize_function()` and sends
//! the result to filecheck. //! the result to filecheck.

View File

@@ -1,6 +1,6 @@
//! The `print-cfg` sub-command. //! The `print-cfg` sub-command.
//! //!
//! Read a series of Cretonne IL files and print their control flow graphs //! Read a series of Cretonne IR files and print their control flow graphs
//! in graphviz format. //! in graphviz format.
use std::borrow::Cow; use std::borrow::Cow;

View File

@@ -1,4 +1,4 @@
//! Test command for checking the IL verifier. //! Test command for checking the IR verifier.
//! //!
//! The `test verifier` test command looks for annotations on instructions like this: //! The `test verifier` test command looks for annotations on instructions like this:
//! //!

View File

@@ -2,7 +2,7 @@
authors = ["The Cretonne Project Developers"] authors = ["The Cretonne Project Developers"]
name = "cretonne-frontend" name = "cretonne-frontend"
version = "0.4.1" version = "0.4.1"
description = "Cretonne IL builder helper" description = "Cretonne IR builder helper"
license = "Apache-2.0" license = "Apache-2.0"
documentation = "https://cretonne.readthedocs.io/" documentation = "https://cretonne.readthedocs.io/"
repository = "https://github.com/Cretonne/cretonne" repository = "https://github.com/Cretonne/cretonne"

View File

@@ -1,5 +1,5 @@
This crate provides a straightforward way to create a This crate provides a straightforward way to create a
[Cretonne](https://crates.io/crates/cretonne) IL function and fill it with [Cretonne](https://crates.io/crates/cretonne) IR function and fill it with
instructions translated from another language. It contains an SSA construction instructions translated from another language. It contains an SSA construction
module that provides convenient methods for translating non-SSA variables into module that provides convenient methods for translating non-SSA variables into
SSA Cretonne IL values via `use_var` and `def_var` calls. SSA Cretonne IR values via `use_var` and `def_var` calls.

View File

@@ -1,4 +1,4 @@
//! A frontend for building Cretonne IL from other languages. //! A frontend for building Cretonne IR from other languages.
use cretonne::cursor::{Cursor, FuncCursor}; use cretonne::cursor::{Cursor, FuncCursor};
use cretonne::ir; use cretonne::ir;
use cretonne::ir::{Ebb, Type, Value, Function, Inst, JumpTable, StackSlot, JumpTableData, use cretonne::ir::{Ebb, Type, Value, Function, Inst, JumpTable, StackSlot, JumpTableData,
@@ -10,7 +10,7 @@ use ssa::{SSABuilder, SideEffects, Block};
use cretonne::entity::{EntityRef, EntityMap, EntitySet}; use cretonne::entity::{EntityRef, EntityMap, EntitySet};
use cretonne::packed_option::PackedOption; use cretonne::packed_option::PackedOption;
/// Structure used for translating a series of functions into Cretonne IL. /// Structure used for translating a series of functions into Cretonne IR.
/// ///
/// In order to reduce memory reallocations when compiling multiple functions, /// In order to reduce memory reallocations when compiling multiple functions,
/// `FunctionBuilderContext` holds various data structures which are cleared between /// `FunctionBuilderContext` holds various data structures which are cleared between
@@ -29,7 +29,7 @@ where
} }
/// Temporary object used to build a single Cretonne IL `Function`. /// Temporary object used to build a single Cretonne IR `Function`.
pub struct FunctionBuilder<'a, Variable: 'a> pub struct FunctionBuilder<'a, Variable: 'a>
where where
Variable: EntityRef, Variable: EntityRef,
@@ -103,7 +103,7 @@ where
} }
/// Implementation of the [`InstBuilder`](../cretonne/ir/builder/trait.InstBuilder.html) that has /// Implementation of the [`InstBuilder`](../cretonne/ir/builder/trait.InstBuilder.html) that has
/// one convenience method per Cretonne IL instruction. /// one convenience method per Cretonne IR instruction.
pub struct FuncInstBuilder<'short, 'long: 'short, Variable: 'long> pub struct FuncInstBuilder<'short, 'long: 'short, Variable: 'long>
where where
Variable: EntityRef, Variable: EntityRef,
@@ -191,7 +191,7 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
} }
} }
/// This module allows you to create a function in Cretonne IL in a straightforward way, hiding /// This module allows you to create a function in Cretonne IR in a straightforward way, hiding
/// all the complexity of its internal representation. /// all the complexity of its internal representation.
/// ///
/// The module is parametrized by one type which is the representation of variables in your /// The module is parametrized by one type which is the representation of variables in your
@@ -203,10 +203,10 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
/// - the last instruction of each block is a terminator instruction which has no natural successor, /// - the last instruction of each block is a terminator instruction which has no natural successor,
/// and those instructions can only appear at the end of extended blocks. /// and those instructions can only appear at the end of extended blocks.
/// ///
/// The parameters of Cretonne IL instructions are Cretonne IL values, which can only be created /// The parameters of Cretonne IR instructions are Cretonne IR values, which can only be created
/// as results of other Cretonne IL instructions. To be able to create variables redefined multiple /// as results of other Cretonne IR instructions. To be able to create variables redefined multiple
/// times in your program, use the `def_var` and `use_var` command, that will maintain the /// times in your program, use the `def_var` and `use_var` command, that will maintain the
/// correspondence between your variables and Cretonne IL SSA values. /// correspondence between your variables and Cretonne IR SSA values.
/// ///
/// The first block for which you call `switch_to_block` will be assumed to be the beginning of /// The first block for which you call `switch_to_block` will be assumed to be the beginning of
/// the function. /// the function.
@@ -220,7 +220,7 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
/// ///
/// # Errors /// # Errors
/// ///
/// The functions below will panic in debug mode whenever you try to modify the Cretonne IL /// The functions below will panic in debug mode whenever you try to modify the Cretonne IR
/// function in a way that violate the coherence of the code. For instance: switching to a new /// function in a way that violate the coherence of the code. For instance: switching to a new
/// `Ebb` when you haven't filled the current one with a terminator instruction, inserting a /// `Ebb` when you haven't filled the current one with a terminator instruction, inserting a
/// return instruction with arguments that don't match the function's signature. /// return instruction with arguments that don't match the function's signature.
@@ -311,7 +311,7 @@ where
self.func_ctx.types[var] = ty; self.func_ctx.types[var] = ty;
} }
/// Returns the Cretonne IL value corresponding to the utilization at the current program /// Returns the Cretonne IR value corresponding to the utilization at the current program
/// position of a previously defined user variable. /// position of a previously defined user variable.
pub fn use_var(&mut self, var: Variable) -> Value { pub fn use_var(&mut self, var: Variable) -> Value {
let ty = *self.func_ctx.types.get(var).expect( let ty = *self.func_ctx.types.get(var).expect(
@@ -462,8 +462,8 @@ where
} }
/// All the functions documented in the previous block are write-only and help you build a valid /// All the functions documented in the previous block are write-only and help you build a valid
/// Cretonne IL functions via multiple debug asserts. However, you might need to improve the /// Cretonne IR functions via multiple debug asserts. However, you might need to improve the
/// performance of your translation perform more complex transformations to your Cretonne IL /// performance of your translation perform more complex transformations to your Cretonne IR
/// function. The functions below help you inspect the function you're creating and modify it /// function. The functions below help you inspect the function you're creating and modify it
/// in ways that can be unsafe if used incorrectly. /// in ways that can be unsafe if used incorrectly.
impl<'a, Variable> FunctionBuilder<'a, Variable> impl<'a, Variable> FunctionBuilder<'a, Variable>

View File

@@ -1,15 +1,15 @@
//! Cretonne IL builder library. //! Cretonne IR builder library.
//! //!
//! Provides a straightforward way to create a Cretonne IL function and fill it with instructions //! Provides a straightforward way to create a Cretonne IR function and fill it with instructions
//! translated from another language. Contains an SSA construction module that lets you translate //! translated from another language. Contains an SSA construction module that lets you translate
//! your non-SSA variables into SSA Cretonne IL values via `use_var` and `def_var` calls. //! your non-SSA variables into SSA Cretonne IR values via `use_var` and `def_var` calls.
//! //!
//! To get started, create an [`FunctionBuilderContext`](struct.FunctionBuilderContext.html) and //! To get started, create an [`FunctionBuilderContext`](struct.FunctionBuilderContext.html) and
//! pass it as an argument to a [`FunctionBuilder`](struct.FunctionBuilder.html). //! pass it as an argument to a [`FunctionBuilder`](struct.FunctionBuilder.html).
//! //!
//! # Example //! # Example
//! //!
//! Here is a pseudo-program we want to transform into Cretonne IL: //! Here is a pseudo-program we want to transform into Cretonne IR:
//! //!
//! ```cton //! ```cton
//! function(x) { //! function(x) {
@@ -29,7 +29,7 @@
//! } //! }
//! ``` //! ```
//! //!
//! Here is how you build the corresponding Cretonne IL function using `FunctionBuilderContext`: //! Here is how you build the corresponding Cretonne IR function using `FunctionBuilderContext`:
//! //!
//! ```rust //! ```rust
//! extern crate cretonne; //! extern crate cretonne;

View File

@@ -231,7 +231,7 @@ fn emit_zero(ty: Type, mut cur: FuncCursor) -> Value {
} }
} }
/// The following methods are the API of the SSA builder. Here is how it should be used when /// The following methods are the API of the SSA builder. Here is how it should be used when
/// translating to Cretonne IL: /// translating to Cretonne IR:
/// ///
/// - for each sequence of contiguous instructions (with no branches), create a corresponding /// - for each sequence of contiguous instructions (with no branches), create a corresponding
/// basic block with `declare_ebb_body_block` or `declare_ebb_header_block` depending on the /// basic block with `declare_ebb_body_block` or `declare_ebb_header_block` depending on the

View File

@@ -2,7 +2,7 @@
authors = ["The Cretonne Project Developers"] authors = ["The Cretonne Project Developers"]
name = "cretonne-reader" name = "cretonne-reader"
version = "0.4.1" version = "0.4.1"
description = "Cretonne textual IL reader" description = "Cretonne textual IR reader"
license = "Apache-2.0" license = "Apache-2.0"
documentation = "https://cretonne.readthedocs.io/" documentation = "https://cretonne.readthedocs.io/"
repository = "https://github.com/Cretonne/cretonne" repository = "https://github.com/Cretonne/cretonne"

View File

@@ -1782,7 +1782,7 @@ impl<'a> Parser<'a> {
// explicit type specified. Look up `ctrl_value` to see if it was defined // explicit type specified. Look up `ctrl_value` to see if it was defined
// already. // already.
// TBD: If it is defined in another block, the type should have been // TBD: If it is defined in another block, the type should have been
// specified explicitly. It is unfortunate that the correctness of IL // specified explicitly. It is unfortunate that the correctness of IR
// depends on the layout of the blocks. // depends on the layout of the blocks.
let ctrl_src_value = inst_data let ctrl_src_value = inst_data
.typevar_operand(&ctx.function.dfg.value_lists) .typevar_operand(&ctx.function.dfg.value_lists)

View File

@@ -2,7 +2,7 @@
name = "cretonne-wasm" name = "cretonne-wasm"
version = "0.4.1" version = "0.4.1"
authors = ["The Cretonne Project Developers"] authors = ["The Cretonne Project Developers"]
description = "Translator from WebAssembly to Cretonne IL" description = "Translator from WebAssembly to Cretonne IR"
repository = "https://github.com/Cretonne/cretonne" repository = "https://github.com/Cretonne/cretonne"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@@ -1,3 +1,2 @@
This crate performs the translation from a wasm module in binary format to the This crate performs the translation from a wasm module in binary format to the
in-memory representation of the [Cretonne](https://crates.io/crates/cretonne) in-memory form of the [Cretonne](https://crates.io/crates/cretonne) IR.
IL.

View File

@@ -1,5 +1,5 @@
//! This module contains the bulk of the interesting code performing the translation between //! This module contains the bulk of the interesting code performing the translation between
//! WebAssembly and Cretonne IL. //! WebAssembly and Cretonne IR.
//! //!
//! The translation is done in one pass, opcode by opcode. Two main data structures are used during //! The translation is done in one pass, opcode by opcode. Two main data structures are used during
//! code translations: the value stack and the control stack. The value stack mimics the execution //! code translations: the value stack and the control stack. The value stack mimics the execution
@@ -38,7 +38,7 @@ use std::vec::Vec;
// Clippy warns about "flags: _" but its important to document that the flags field is ignored // Clippy warns about "flags: _" but its important to document that the flags field is ignored
#[cfg_attr(feature = "cargo-clippy", allow(unneeded_field_pattern))] #[cfg_attr(feature = "cargo-clippy", allow(unneeded_field_pattern))]
/// Translates wasm operators into Cretonne IL instructions. Returns `true` if it inserted /// Translates wasm operators into Cretonne IR instructions. Returns `true` if it inserted
/// a return. /// a return.
pub fn translate_operator<FE: FuncEnvironment + ?Sized>( pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
op: Operator, op: Operator,

View File

@@ -26,7 +26,7 @@ pub enum GlobalValue {
/// Environment affecting the translation of a single WebAssembly function. /// Environment affecting the translation of a single WebAssembly function.
/// ///
/// A `FuncEnvironment` trait object is required to translate a WebAssembly function to Cretonne /// A `FuncEnvironment` trait object is required to translate a WebAssembly function to Cretonne
/// IL. The function environment provides information about the WebAssembly module as well as the /// IR. The function environment provides information about the WebAssembly module as well as the
/// runtime environment. /// runtime environment.
pub trait FuncEnvironment { pub trait FuncEnvironment {
/// Get the flags for the current compilation. /// Get the flags for the current compilation.

View File

@@ -1,7 +1,7 @@
//! Stand-alone WebAssembly to Cretonne IL translator. //! Stand-alone WebAssembly to Cretonne IR translator.
//! //!
//! This module defines the `FuncTranslator` type which can translate a single WebAssembly //! This module defines the `FuncTranslator` type which can translate a single WebAssembly
//! function to Cretonne IL guided by a `FuncEnvironment` which provides information about the //! function to Cretonne IR guided by a `FuncEnvironment` which provides information about the
//! WebAssembly module and the runtime environment. //! WebAssembly module and the runtime environment.
use code_translator::translate_operator; use code_translator::translate_operator;
@@ -14,9 +14,9 @@ use environ::FuncEnvironment;
use state::TranslationState; use state::TranslationState;
use wasmparser::{self, BinaryReader}; use wasmparser::{self, BinaryReader};
/// WebAssembly to Cretonne IL function translator. /// WebAssembly to Cretonne IR function translator.
/// ///
/// A `FuncTranslator` is used to translate a binary WebAssembly function into Cretonne IL guided /// A `FuncTranslator` is used to translate a binary WebAssembly function into Cretonne IR guided
/// by a `FuncEnvironment` object. A single translator instance can be reused to translate multiple /// by a `FuncEnvironment` object. A single translator instance can be reused to translate multiple
/// functions which will reduce heap allocation traffic. /// functions which will reduce heap allocation traffic.
pub struct FuncTranslator { pub struct FuncTranslator {

View File

@@ -1,5 +1,5 @@
//! Performs the translation from a wasm module in binary format to the in-memory representation //! Performs translation from a wasm module in binary format to the in-memory form
//! of the Cretonne IL. More particularly, it translates the code of all the functions bodies and //! of Cretonne IR. More particularly, it translates the code of all the functions bodies and
//! interacts with an environment implementing the //! interacts with an environment implementing the
//! [`ModuleEnvironment`](trait.ModuleEnvironment.html) //! [`ModuleEnvironment`](trait.ModuleEnvironment.html)
//! trait to deal with tables, globals and linear memory. //! trait to deal with tables, globals and linear memory.

View File

@@ -10,7 +10,7 @@ use environ::ModuleEnvironment;
use std::string::String; use std::string::String;
/// Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cretonne IL /// Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cretonne IR
/// [`Function`](../cretonne/ir/function/struct.Function.html). /// [`Function`](../cretonne/ir/function/struct.Function.html).
/// Returns the functions and also the mappings for imported functions and signature between the /// Returns the functions and also the mappings for imported functions and signature between the
/// indexes in the wasm module and the indexes inside each functions. /// indexes in the wasm module and the indexes inside each functions.