Rename Cretonne to Cranelift!

This commit is contained in:
Dan Gohman
2018-07-13 09:01:28 -07:00
parent 19a636af96
commit f4dbd38a4c
306 changed files with 977 additions and 975 deletions

View File

@@ -1,22 +1,22 @@
[package]
authors = ["The Cretonne Project Developers"]
name = "cretonne-codegen"
authors = ["The Cranelift Project Developers"]
name = "cranelift-codegen"
version = "0.13.0"
description = "Low-level code generator library"
license = "Apache-2.0 WITH LLVM-exception"
documentation = "https://cretonne.readthedocs.io/"
repository = "https://github.com/cretonne/cretonne"
documentation = "https://cranelift.readthedocs.io/"
repository = "https://github.com/cranelift/cranelift"
readme = "README.md"
keywords = ["compile", "compiler", "jit"]
build = "build.rs"
[dependencies]
cretonne-entity = { path = "../entity", version = "0.13.0", default-features = false }
cranelift-entity = { path = "../entity", version = "0.13.0", default-features = false }
failure = { version = "0.1.1", default-features = false, features = ["derive"] }
failure_derive = { version = "0.1.1", default-features = false }
hashmap_core = { version = "0.1.8", optional = true }
target-lexicon = { version = "0.0.2", default-features = false }
# It is a goal of the cretonne-codegen crate to have minimal external dependencies.
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
# Please don't add any unless they are essential to the task of creating binary
# machine code. Integration tests that need external dependencies can be
# accomodated in `tests`.
@@ -26,9 +26,9 @@ target-lexicon = { version = "0.0.2", default-features = false }
# of some minimal std-like replacement libraries. At least one of these two
# features need to be enabled.
default = ["std"]
std = ["cretonne-entity/std", "target-lexicon/std"]
std = ["cranelift-entity/std", "target-lexicon/std"]
core = ["hashmap_core"]
[badges]
maintenance = { status = "experimental" }
travis-ci = { repository = "cretonne/cretonne" }
travis-ci = { repository = "cranelift/cranelift" }

View File

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

View File

@@ -11,7 +11,7 @@
// TARGET
// Target triple provided by Cargo.
//
// CRETONNE_TARGETS (Optional)
// CRANELIFT_TARGETS (Optional)
// A setting for conditional compilation of isa targets. Possible values can be "native" or
// known isa targets separated by ','.
//
@@ -24,12 +24,12 @@ use std::process;
fn main() {
let out_dir = env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set");
let target_triple = env::var("TARGET").expect("The TARGET environment variable must be set");
let cretonne_targets = env::var("CRETONNE_TARGETS").ok();
let cretonne_targets = cretonne_targets.as_ref().map(|s| s.as_ref());
let cranelift_targets = env::var("CRANELIFT_TARGETS").ok();
let cranelift_targets = cranelift_targets.as_ref().map(|s| s.as_ref());
let python = identify_python();
// Configure isa targets cfg.
match isa_targets(cretonne_targets, &target_triple) {
match isa_targets(cranelift_targets, &target_triple) {
Ok(isa_targets) => {
for isa in &isa_targets {
println!("cargo:rustc-cfg=build_{}", isa.name());
@@ -84,7 +84,7 @@ fn identify_python() -> &'static str {
return python;
}
}
panic!("The Cretonne build requires Python (version 2.7 or version 3)");
panic!("The Cranelift build requires Python (version 2.7 or version 3)");
}
/// Represents known ISA target.
@@ -142,8 +142,8 @@ impl Isa {
}
/// Returns isa targets to configure conditional compilation.
fn isa_targets(cretonne_targets: Option<&str>, target_triple: &str) -> Result<Vec<Isa>, String> {
match cretonne_targets {
fn isa_targets(cranelift_targets: Option<&str>, target_triple: &str) -> Result<Vec<Isa>, String> {
match cranelift_targets {
Some("native") => Isa::from_arch(target_triple.split('-').next().unwrap())
.map(|isa| vec![isa])
.ok_or_else(|| {

View File

@@ -1 +1 @@
"""Definitions for the base Cretonne language."""
"""Definitions for the base Cranelift language."""

View File

@@ -1,6 +1,6 @@
"""
The `cretonne.entities` module predefines all the Cretonne entity reference
operand types. There are corresponding definitions in the `cretonne.entities`
The `cranelift.entities` module predefines all the Cranelift entity reference
operand types. There are corresponding definitions in the `cranelift.entities`
Rust module.
"""
from __future__ import absolute_import

View File

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

View File

@@ -1,6 +1,6 @@
"""
The `cretonne.immediates` module predefines all the Cretonne immediate operand
types.
The `cranelift.immediates` module predefines all the Cranelift immediate
operand types.
"""
from __future__ import absolute_import
from cdsl.operands import ImmediateKind
@@ -8,7 +8,7 @@ from cdsl.operands import ImmediateKind
#: A 64-bit immediate integer operand.
#:
#: This type of immediate integer can interact with SSA values with any
#: :py:class:`cretonne.IntType` type.
#: :py:class:`cranelift.IntType` type.
imm64 = ImmediateKind('imm64', 'A 64-bit immediate integer.')
#: An unsigned 8-bit immediate integer operand.
@@ -42,13 +42,13 @@ ieee64 = ImmediateKind('ieee64', 'A 64-bit immediate floating point number.')
#: An immediate boolean operand.
#:
#: This type of immediate boolean can interact with SSA values with any
#: :py:class:`cretonne.BoolType` type.
#: :py:class:`cranelift.BoolType` type.
boolean = ImmediateKind('bool', 'An immediate boolean.',
rust_type='bool')
#: A condition code for comparing integer values.
#:
#: This enumerated operand kind is used for the :cton:inst:`icmp` instruction
#: This enumerated operand kind is used for the :clif:inst:`icmp` instruction
#: and corresponds to the `condcodes::IntCC` Rust type.
intcc = ImmediateKind(
'intcc',
@@ -70,7 +70,7 @@ intcc = ImmediateKind(
#: A condition code for comparing floating point values.
#:
#: This enumerated operand kind is used for the :cton:inst:`fcmp` instruction
#: This enumerated operand kind is used for the :clif:inst:`fcmp` instruction
#: and corresponds to the `condcodes::FloatCC` Rust type.
floatcc = ImmediateKind(
'floatcc',
@@ -94,7 +94,7 @@ floatcc = ImmediateKind(
'uge': 'UnorderedOrGreaterThanOrEqual',
})
#: Flags for memory operations like :cton:inst:`load` and :cton:inst:`store`.
#: Flags for memory operations like :clif:inst:`load` and :clif:inst:`store`.
memflags = ImmediateKind(
'memflags',
'Memory operation flags',

View File

@@ -1,7 +1,7 @@
"""
Cretonne base instruction set.
Cranelift base instruction set.
This module defines the basic Cretonne instruction set that all targets
This module defines the basic Cranelift instruction set that all targets
support.
"""
from __future__ import absolute_import
@@ -1524,8 +1524,8 @@ fdiv = Instruction(
'fdiv', r"""
Floating point division.
Unlike the integer division instructions :cton:inst:`sdiv` and
:cton:inst:`udiv`, this can't trap. Division by zero is infinity or
Unlike the integer division instructions :clif:inst:`sdiv` and
:clif:inst:`udiv`, this can't trap. Division by zero is infinity or
NaN, depending on the dividend.
""",
ins=(x, y), outs=a)
@@ -1800,7 +1800,7 @@ fpromote = Instruction(
Each lane in `x` is converted to the destination floating point format.
This is an exact operation.
Cretonne currently only supports two floating point formats
Cranelift currently only supports two floating point formats
- :type:`f32` and :type:`f64`. This may change in the future.
The result type must have the same number of vector lanes as the input,
@@ -1816,7 +1816,7 @@ fdemote = Instruction(
Each lane in `x` is converted to the destination floating point format
by rounding to nearest, ties to even.
Cretonne currently only supports two floating point formats
Cranelift currently only supports two floating point formats
- :type:`f32` and :type:`f64`. This may change in the future.
The result type must have the same number of vector lanes as the input,

View File

@@ -1,7 +1,7 @@
"""
Patterns for legalizing the `base` instruction set.
The base Cretonne instruction set is 'fat', and many instructions don't have
The base Cranelift instruction set is 'fat', and many instructions don't have
legal representations in a given target ISA. This module defines legalization
patterns that describe how base instructions can be transformed to other base
instructions that are legal.

View File

@@ -1,5 +1,5 @@
"""
Cretonne predicates that consider `Function` fields.
Cranelift predicates that consider `Function` fields.
"""
from cdsl.predicates import FieldPredicate
from .formats import UnaryGlobalValue, InstructionFormat

View File

@@ -1,5 +1,5 @@
"""
Cretonne shared settings.
Cranelift shared settings.
This module defines settings relevant for all code generators.
"""
@@ -20,10 +20,10 @@ opt_level = EnumSetting(
enable_verifier = BoolSetting(
"""
Run the Cretonne IR verifier at strategic times during compilation.
Run the Cranelift IR verifier at strategic times during compilation.
This makes compilation slower but catches many bugs. The verifier is
disabled by default, except when reading Cretonne IR from a text file.
disabled by default, except when reading Cranelift IR from a text file.
""",
default=True)
@@ -51,8 +51,8 @@ call_conv = EnumSetting(
'probestack'
)
# Note that Cretonne doesn't currently need an is_pie flag, because PIE is just
# PIC where symbols can't be pre-empted, which can be expressed with the
# Note that Cranelift doesn't currently need an is_pie flag, because PIE is
# just PIC where symbols can't be pre-empted, which can be expressed with the
# `colocated` flag on external functions and global values.
is_pic = BoolSetting("Enable Position-Independent Code generation")
@@ -126,7 +126,7 @@ baldrdash_prologue_words = NumSetting(
in the epilogue.
This setting configures the number of pointer-sized words pushed on the
stack when the Cretonne-generated code is entered. This includes the
stack when the Cranelift-generated code is entered. This includes the
pushed return address on x86.
""")

View File

@@ -1,5 +1,5 @@
"""
The base.types module predefines all the Cretonne scalar types.
The base.types module predefines all the Cranelift scalar types.
"""
from __future__ import absolute_import
from cdsl.types import IntType, FloatType, BoolType, FlagsType

View File

@@ -18,7 +18,7 @@ import gen_binemit
def main():
# type: () -> None
parser = argparse.ArgumentParser(
description='Generate sources for Cretonne.')
description='Generate sources for Cranelift.')
parser.add_argument('--out-dir', help='set output directory')
args = parser.parse_args()

View File

@@ -1,7 +1,7 @@
"""
Cretonne DSL classes.
Cranelift DSL classes.
This module defines the classes that are used to define Cretonne instructions
This module defines the classes that are used to define Cranelift instructions
and other entitties.
"""
from __future__ import absolute_import

View File

@@ -2,7 +2,7 @@
Abstract syntax trees.
This module defines classes that can be used to create abstract syntax trees
for patern matching an rewriting of cretonne instructions.
for patern matching an rewriting of cranelift instructions.
"""
from __future__ import absolute_import
from . import instructions

View File

@@ -50,7 +50,7 @@ class InstructionFormat(object):
of values.
All instruction formats must be predefined in the
:py:mod:`cretonne.formats` module.
:py:mod:`cranelift.formats` module.
:param kinds: List of `OperandKind` objects describing the operands.
:param name: Instruction format name in CamelCase. This is used as a Rust

View File

@@ -67,7 +67,7 @@ VARIABLE_ARGS = OperandKind(
# Instances of immediate operand types are provided in the
# `cretonne.immediates` module.
# `cranelift.immediates` module.
class ImmediateKind(OperandKind):
"""
The kind of an immediate instruction operand.
@@ -152,7 +152,7 @@ class ImmediateKind(OperandKind):
# Instances of entity reference operand types are provided in the
# `cretonne.entities` module.
# `cranelift.entities` module.
class EntityRefKind(OperandKind):
"""
The kind of an entity reference instruction operand.

View File

@@ -1,5 +1,5 @@
"""
Cretonne predicates.
Cranelift predicates.
A *predicate* is a function that computes a boolean result. The inputs to the
function determine the kind of predicate:

View File

@@ -14,7 +14,7 @@ except ImportError:
class Setting(object):
"""
A named setting variable that can be configured externally to Cretonne.
A named setting variable that can be configured externally to Cranelift.
Settings are normally not named when they are created. They get their name
from the `extract_names` method.

View File

@@ -1,4 +1,4 @@
"""Cretonne ValueType hierarchy"""
"""Cranelift ValueType hierarchy"""
from __future__ import absolute_import
import math

View File

@@ -1,7 +1,7 @@
"""
Type variables for Parametric polymorphism.
Cretonne instructions and instruction transformations can be specified to be
Cranelift instructions and instruction transformations can be specified to be
polymorphic by using type variables.
"""
from __future__ import absolute_import

View File

@@ -1,7 +1,7 @@
"""
Generate legalizer transformations.
The transformations defined in the `cretonne.legalize` module are all of the
The transformations defined in the `cranelift.legalize` module are all of the
macro-expansion form where the input pattern is a single instruction. We
generate a Rust function for each `XFormGroup` which takes a `Cursor` pointing
at the instruction to be legalized. The expanded destination pattern replaces

View File

@@ -1,9 +1,9 @@
"""
Cretonne target ISA definitions
-------------------------------
Cranelift target ISA definitions
--------------------------------
The :py:mod:`isa` package contains sub-packages for each target instruction set
architecture supported by Cretonne.
architecture supported by Cranelift.
"""
from __future__ import absolute_import
from cdsl.isa import TargetISA # noqa
@@ -19,6 +19,6 @@ def all_isas():
# type: () -> List[TargetISA]
"""
Get a list of all the supported target ISAs. Each target ISA is represented
as a :py:class:`cretonne.TargetISA` instance.
as a :py:class:`cranelift.TargetISA` instance.
"""
return [riscv.ISA, x86.ISA, arm32.ISA, arm64.ISA]

View File

@@ -61,7 +61,7 @@ RV32.enc(base.iconst.i32, Iz, OPIMM(0b000))
RV64.enc(base.iconst.i32, Iz, OPIMM(0b000))
RV64.enc(base.iconst.i64, Iz, OPIMM(0b000))
# Dynamic shifts have the same masking semantics as the cton base instructions.
# Dynamic shifts have the same masking semantics as the clif base instructions.
for inst, inst_imm, f3, f7 in [
(base.ishl, base.ishl_imm, 0b001, 0b0000000),
(base.ushr, base.ushr_imm, 0b101, 0b0000000),

View File

@@ -1,12 +1,12 @@
"""
x86 Target Architecture
-------------------------
-----------------------
This target ISA generates code for x86 CPUs with two separate CPU modes:
`I32`
32-bit x86 architecture, also known as 'IA-32', also sometimes referred
to as 'i386', however note that Cretonne depends on instructions not
to as 'i386', however note that Cranelift depends on instructions not
in the original `i386`, such as SSE2, CMOVcc, and UD2.
`I64`

View File

@@ -34,7 +34,7 @@ except ImportError:
# Opcode representation.
#
# Cretonne requires each recipe to have a single encoding size in bytes, and
# Cranelift requires each recipe to have a single encoding size in bytes, and
# x86 opcodes are variable length, so we use separate recipes for different
# styles of opcodes and prefixes. The opcode format is indicated by the recipe
# name prefix:
@@ -1600,7 +1600,7 @@ rcmp_sp = TailRecipe(
#
# 1. Guarantee that the test and branch get scheduled next to each other so
# macro fusion is guaranteed to be possible.
# 2. Hide the status flags from Cretonne which doesn't currently model flags.
# 2. Hide the status flags from Cranelift which doesn't currently model flags.
#
# The encoding bits affect both the test and the branch instruction:
#

View File

@@ -1,4 +1,4 @@
"""Definitions for the semantics segment of the Cretonne language."""
"""Definitions for the semantics segment of the Cranelift language."""
from cdsl.ti import TypeEnv, ti_rtl, get_type_env
from cdsl.operands import ImmediateKind
from cdsl.ast import Var

View File

@@ -1,7 +1,7 @@
"""
Tools to elaborate a given Rtl with concrete types into its semantically
equivalent primitive version. Its elaborated primitive version contains only
primitive cretonne instructions, which map well to SMTLIB functions.
primitive cranelift instructions, which map well to SMTLIB functions.
"""
from .primitives import GROUP as PRIMITIVES, prim_to_bv, prim_from_bv
from cdsl.xform import Rtl

View File

@@ -1,5 +1,5 @@
"""
Cretonne primitive instruction set.
Cranelift primitive instruction set.
This module defines a primitive instruction set, in terms of which the base set
is described. Most instructions in this set correspond 1-1 with an SMTLIB
@@ -26,9 +26,9 @@ y = Operand('x', BV, doc="A semantic value Y (same width as X)")
a = Operand('a', BV, doc="A semantic value A (same width as X)")
cond = Operand('b', TypeVar.singleton(b1), doc='A b1 value')
real = Operand('real', Real, doc="A real cretonne value")
real = Operand('real', Real, doc="A real cranelift value")
fromReal = Operand('fromReal', Real.to_bitvec(),
doc="A real cretonne value converted to a BV")
doc="A real cranelift value converted to a BV")
#
# BV Conversion/Materialization

View File

@@ -186,14 +186,16 @@ def equivalent(r1, r2, inp_m, out_m):
(q1, m1) = to_smt(r1)
(q2, m2) = to_smt(r2)
# Build an expression for the equality of real Cretone inputs of r1 and r2
# Build an expression for the equality of real Cranelift inputs of
# r1 and r2
args_eq_exp = [] # type: List[ExprRef]
for (v1, v2) in inp_m.items():
assert isinstance(v2, Var)
args_eq_exp.append(mk_eq(m1[v1], m2[v2]))
# Build an expression for the equality of real Cretone outputs of r1 and r2
# Build an expression for the equality of real Cranelift outputs of
# r1 and r2
results_eq_exp = [] # type: List[ExprRef]
for (v1, v2) in out_m.items():
assert isinstance(v2, Var)

View File

@@ -1,6 +1,6 @@
//! Code sink that writes binary machine code into contiguous memory.
//!
//! The `CodeSink` trait is the most general way of extracting binary machine code from Cretonne,
//! The `CodeSink` trait is the most general way of extracting binary machine code from Cranelift,
//! and it is implemented by things like the `test binemit` file test driver to generate
//! hexadecimal machine code. The `CodeSink` has some undesirable performance properties because of
//! the dual abstraction: `TargetIsa` is a trait object implemented by each supported ISA, so it
@@ -20,7 +20,7 @@ use std::ptr::write_unaligned;
/// A `CodeSink` that writes binary machine code directly into memory.
///
/// A `MemoryCodeSink` object should be used when emitting a Cretonne IR function into executable
/// A `MemoryCodeSink` object should be used when emitting a Cranelift IR function into executable
/// 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
/// by the `Context::compile()` function.

View File

@@ -1,6 +1,6 @@
//! Binary machine code emission.
//!
//! The `binemit` module contains code for translating Cretonne's intermediate representation into
//! The `binemit` module contains code for translating Cranelift's intermediate representation into
//! binary machine code.
mod memorysink;
@@ -17,7 +17,7 @@ use std::fmt;
/// Offset in bytes from the beginning of the function.
///
/// Cretonne can be used as a cross compiler, so we don't want to use a type like `usize` which
/// Cranelift can be used as a cross compiler, so we don't want to use a type like `usize` which
/// depends on the *host* platform, not the *target* platform.
pub type CodeOffset = u32;
@@ -49,7 +49,7 @@ pub enum Reloc {
impl fmt::Display for Reloc {
/// Display trait implementation drops the arch, since its used in contexts where the arch is
/// already unambigious, e.g. cton syntax with isa specified. In other contexts, use Debug.
/// already unambigious, e.g. clif syntax with isa specified. In other contexts, use Debug.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Reloc::Abs4 => write!(f, "Abs4"),

View File

@@ -15,13 +15,13 @@
//! On RISC architectures, it can happen that conditional branches have a shorter range than
//! unconditional branches:
//!
//! ```cton
//! ```clif
//! brz v1, ebb17
//! ```
//!
//! can be transformed into:
//!
//! ```cton
//! ```clif
//! brnz v1, ebb23
//! jump ebb17
//! ebb23:

View File

@@ -1,6 +1,6 @@
//! Instruction shrinking.
//!
//! Sometimes there are multiple valid encodings for a given instruction. Cretonne often initially
//! Sometimes there are multiple valid encodings for a given instruction. Cranelift often initially
//! chooses the largest one, because this typically provides the register allocator the most
//! flexibility. However, once register allocation is done, this is no longer important, and we
//! can switch to smaller encodings when possible.

View File

@@ -1,4 +1,4 @@
//! Cretonne compilation context and main entry point.
//! Cranelift compilation context and main entry point.
//!
//! When compiling many small functions, it is important to avoid repeatedly allocating and
//! deallocating the data structures needed for compilation. The `Context` struct is used to hold

View File

@@ -46,8 +46,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, SourceLoc};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, SourceLoc};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, srcloc: SourceLoc) {
/// let mut pos = FuncCursor::new(func).with_srcloc(srcloc);
///
@@ -76,8 +76,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, inst: Inst) {
/// let mut pos = FuncCursor::new(func).at_inst(inst);
///
@@ -99,8 +99,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, ebb: Ebb) {
/// let mut pos = FuncCursor::new(func).at_first_insertion_point(ebb);
///
@@ -120,8 +120,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, ebb: Ebb) {
/// let mut pos = FuncCursor::new(func).at_first_inst(ebb);
///
@@ -141,8 +141,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, ebb: Ebb) {
/// let mut pos = FuncCursor::new(func).at_last_inst(ebb);
///
@@ -162,8 +162,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, inst: Inst) {
/// let mut pos = FuncCursor::new(func).after_inst(inst);
///
@@ -183,8 +183,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, ebb: Ebb) {
/// let mut pos = FuncCursor::new(func).at_top(ebb);
///
@@ -204,8 +204,8 @@ pub trait Cursor {
/// This is intended to be used as a builder method:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb, Inst};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb, Inst};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function, ebb: Ebb) {
/// let mut pos = FuncCursor::new(func).at_bottom(ebb);
///
@@ -311,8 +311,8 @@ pub trait Cursor {
/// The `next_ebb()` method is intended for iterating over the EBBs in layout order:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function) {
/// let mut cursor = FuncCursor::new(func);
/// while let Some(ebb) = cursor.next_ebb() {
@@ -344,8 +344,8 @@ pub trait Cursor {
/// The `prev_ebb()` method is intended for iterating over the EBBs in backwards layout order:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function) {
/// let mut cursor = FuncCursor::new(func);
/// while let Some(ebb) = cursor.prev_ebb() {
@@ -381,8 +381,8 @@ pub trait Cursor {
/// this:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_ebb(func: &mut Function, ebb: Ebb) {
/// let mut cursor = FuncCursor::new(func).at_top(ebb);
/// while let Some(inst) = cursor.next_inst() {
@@ -395,8 +395,8 @@ pub trait Cursor {
/// Iterating over all the instructions in a function looks like this:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_func(func: &mut Function) {
/// let mut cursor = FuncCursor::new(func);
/// while let Some(ebb) = cursor.next_ebb() {
@@ -451,8 +451,8 @@ pub trait Cursor {
/// EBB like this:
///
/// ```
/// # use cretonne_codegen::ir::{Function, Ebb};
/// # use cretonne_codegen::cursor::{Cursor, FuncCursor};
/// # use cranelift_codegen::ir::{Function, Ebb};
/// # use cranelift_codegen::cursor::{Cursor, FuncCursor};
/// fn edit_ebb(func: &mut Function, ebb: Ebb) {
/// let mut cursor = FuncCursor::new(func).at_bottom(ebb);
/// while let Some(inst) = cursor.prev_inst() {

View File

@@ -1,12 +1,12 @@
//! Debug tracing macros.
//!
//! This module defines the `dbg!` macro which works like `println!` except it writes to the
//! Cretonne tracing output file if enabled.
//! Cranelift tracing output file if enabled.
//!
//! Tracing can be enabled by setting the `CRETONNE_DBG` environment variable to something
//! Tracing can be enabled by setting the `CRANELIFT_DBG` environment variable to something
/// other than `0`.
///
/// The output will appear in files named `cretonne.dbg.*`, where the suffix is named after the
/// The output will appear in files named `cranelift.dbg.*`, where the suffix is named after the
/// thread doing the logging.
#[cfg(feature = "std")]
use std::cell::RefCell;
@@ -29,7 +29,7 @@ static STATE: atomic::AtomicIsize = atomic::ATOMIC_ISIZE_INIT;
/// Is debug tracing enabled?
///
/// Debug tracing can be enabled by setting the `CRETONNE_DBG` environment variable to something
/// Debug tracing can be enabled by setting the `CRANELIFT_DBG` environment variable to something
/// other than `0`.
///
/// This inline function turns into a constant `false` when debug assertions are disabled.
@@ -56,7 +56,7 @@ pub fn enabled() -> bool {
/// Initialize `STATE` from the environment variable.
#[cfg(feature = "std")]
fn initialize() -> bool {
let enable = match env::var_os("CRETONNE_DBG") {
let enable = match env::var_os("CRANELIFT_DBG") {
Some(s) => s != OsStr::new("0"),
None => false,
};
@@ -92,7 +92,7 @@ pub fn writeln_with_format_args(args: fmt::Arguments) -> io::Result<()> {
fn open_file() -> io::BufWriter<File> {
let curthread = thread::current();
let tmpstr;
let mut path = "cretonne.dbg.".to_owned();
let mut path = "cranelift.dbg.".to_owned();
path.extend(
match curthread.name() {
Some(name) => name.chars(),

View File

@@ -1,6 +1,6 @@
//! Cretonne instruction builder.
//! Cranelift instruction builder.
//!
//! A `Builder` provides a convenient interface for inserting instructions into a Cretonne
//! A `Builder` provides a convenient interface for inserting instructions into a Cranelift
//! function. Many of its methods are generated from the meta language instruction definitions.
use ir;

View File

@@ -1,4 +1,4 @@
//! Condition codes for the Cretonne code generator.
//! Condition codes for the Cranelift code generator.
//!
//! A condition code here is an enumerated type that determined how to compare two numbers. There
//! are different rules for comparing integers and floating point numbers, so they use different

View File

@@ -1,6 +1,6 @@
//! Cretonne IR entity references.
//! Cranelift IR entity references.
//!
//! Instructions in Cretonne IR need to reference other entities in the function. This can be other
//! Instructions in Cranelift 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
//! that are declared in the function preamble in the text format.
//!

View File

@@ -1,6 +1,6 @@
//! External function calls.
//!
//! To a Cretonne function, all functions are "external". Directly called functions must be
//! To a Cranelift function, all functions are "external". Directly called functions must be
//! declared in the preamble, and all function calls must have a signature.
//!
//! This module declares the data types used to represent external functions and call signatures.

View File

@@ -2,7 +2,7 @@
//!
//! These are identifiers for declaring entities defined outside the current
//! function. The name of an external declaration doesn't have any meaning to
//! Cretonne, which compiles functions independently.
//! Cranelift, which compiles functions independently.
use ir::LibCall;
use std::cmp;
@@ -15,16 +15,16 @@ const TESTCASE_NAME_LENGTH: usize = 16;
/// table, or a short sequence of ascii bytes so that test cases do not have
/// to keep track of a sy mbol table.
///
/// External names are primarily used as keys by code using Cretonne to map
/// from a `cretonne_codegen::ir::FuncRef` or similar to additional associated
/// External names are primarily used as keys by code using Cranelift to map
/// from a `cranelift_codegen::ir::FuncRef` or similar to additional associated
/// data.
///
/// External names can also serve as a primitive testing and debugging tool.
/// In particular, many `.cton` test files use function names to identify
/// In particular, many `.clif` test files use function names to identify
/// functions.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ExternalName {
/// A name in a user-defined symbol table. Cretonne does not interpret
/// A name in a user-defined symbol table. Cranelift does not interpret
/// these numbers in any way.
User {
/// Arbitrary.
@@ -51,7 +51,7 @@ impl ExternalName {
/// # Examples
///
/// ```rust
/// # use cretonne_codegen::ir::ExternalName;
/// # use cranelift_codegen::ir::ExternalName;
/// // Create `ExternalName` from a string.
/// let name = ExternalName::testcase("hello");
/// assert_eq!(name.to_string(), "%hello");
@@ -72,7 +72,7 @@ impl ExternalName {
///
/// # Examples
/// ```rust
/// # use cretonne_codegen::ir::ExternalName;
/// # use cranelift_codegen::ir::ExternalName;
/// // Create `ExternalName` from integer indicies
/// let name = ExternalName::user(123, 456);
/// assert_eq!(name.to_string(), "u123:456");

View File

@@ -23,7 +23,7 @@ use write::write_function;
/// The clone will have all the same entity numbers as the original.
#[derive(Clone)]
pub struct Function {
/// Name of this function. Mostly used by `.cton` files.
/// Name of this function. Mostly used by `.clif` files.
pub name: ExternalName,
/// Signature of this function.
@@ -68,7 +68,7 @@ pub struct Function {
/// Source locations.
///
/// Track the original source location for each instruction. The source locations are not
/// interpreted by Cretonne, only preserved.
/// interpreted by Cranelift, only preserved.
pub srclocs: SourceLocs,
}

View File

@@ -27,7 +27,7 @@ pub enum GlobalValueData {
offset: Offset32,
},
/// Value is identified by a symbolic name. Cretonne itself does not interpret this name;
/// Value is identified by a symbolic name. Cranelift itself does not interpret this name;
/// it's used by embedders to link with other data structures.
Sym {
/// The symbolic name.

View File

@@ -1,7 +1,7 @@
//! Immediate operands for Cretonne instructions
//! Immediate operands for Cranelift instructions
//!
//! This module defines the types of immediate operands that can appear on Cretonne instructions.
//! Each type here should have a corresponding definition in the `cretonne.immediates` Python
//! This module defines the types of immediate operands that can appear on Cranelift instructions.
//! Each type here should have a corresponding definition in the `cranelift.immediates` Python
//! module in the meta language.
use std::fmt::{self, Display, Formatter};

View File

@@ -64,7 +64,7 @@ impl Opcode {
}
}
// This trait really belongs in lib/reader where it is used by the `.cton` file parser, but since
// This trait really belongs in lib/reader where it is used by the `.clif` file parser, but since
// it critically depends on the `opcode_name()` function which is needed here anyway, it lives in
// this module. This also saves us from running the build script twice to generate code for the two
// separate crates.

View File

@@ -11,9 +11,9 @@ use std::str::FromStr;
/// The name of a runtime library routine.
///
/// Runtime library calls are generated for Cretonne IR instructions that don't have an equivalent
/// Runtime library calls are generated for Cranelift 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
/// the runtime library routine. This way, Cretonne doesn't have to know about the naming
/// the runtime library routine. This way, Cranelift doesn't have to know about the naming
/// convention in the embedding VM's runtime library.
///
/// This list is likely to grow over time.

View File

@@ -51,10 +51,10 @@ impl MemFlags {
/// Test if the `notrap` flag is set.
///
/// Normally, trapping is part of the semantics of a load/store operation. If the platform
/// would cause a trap when accessing the effective address, the Cretonne memory operation is
/// would cause a trap when accessing the effective address, the Cranelift memory operation is
/// also required to trap.
///
/// The `notrap` flag tells Cretonne that the memory is *accessible*, which means that
/// The `notrap` flag tells Cranelift that the memory is *accessible*, which means that
/// accesses will not trap. This makes it possible to delete an unused load or a dead store
/// instruction.
pub fn notrap(self) -> bool {
@@ -68,7 +68,7 @@ impl MemFlags {
/// Test if the `aligned` flag is set.
///
/// By default, Cretonne memory instructions work with any unaligned effective address. If the
/// By default, Cranelift memory instructions work with any unaligned effective address. If the
/// `aligned` flag is set, the instruction is permitted to trap or return a wrong result if the
/// effective address is misaligned.
pub fn aligned(self) -> bool {

View File

@@ -1,4 +1,4 @@
//! Representation of Cretonne IR functions.
//! Representation of Cranelift IR functions.
mod builder;
pub mod condcodes;

View File

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

View File

@@ -1,13 +1,13 @@
//! Source locations.
//!
//! Cretonne tracks the original source location of each instruction, and preserves the source
//! Cranelift tracks the original source location of each instruction, and preserves the source
//! location when instructions are transformed.
use std::fmt;
/// A source location.
///
/// This is an opaque 32-bit number attached to each Cretonne IR instruction. Cretonne does not
/// This is an opaque 32-bit number attached to each Cranelift IR instruction. Cranelift does not
/// 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

View File

@@ -15,7 +15,7 @@ use std::vec::Vec;
/// The size of an object on the stack, or the size of a stack frame.
///
/// We don't use `usize` to represent object sizes on the target platform because Cretonne supports
/// We don't use `usize` to represent object sizes on the target platform because Cranelift supports
/// cross-compilation, and `usize` is a type that depends on the host platform, not the target
/// platform.
pub type StackSize = u32;

View File

@@ -1,4 +1,4 @@
//! Common types for the Cretonne code generator.
//! Common types for the Cranelift code generator.
use std::default::Default;
use std::fmt::{self, Debug, Display, Formatter};

View File

@@ -2,15 +2,15 @@
//!
//! The `isa` module provides a `TargetIsa` trait which provides the behavior specialization needed
//! by the ISA-independent code generator. The sub-modules of this module provide definitions for
//! the instruction sets that Cretonne can target. Each sub-module has it's own implementation of
//! the instruction sets that Cranelift can target. Each sub-module has it's own implementation of
//! `TargetIsa`.
//!
//! # Constructing a `TargetIsa` instance
//!
//! The target ISA is built from the following information:
//!
//! - The name of the target ISA as a string. Cretonne is a cross-compiler, so the ISA to target
//! can be selected dynamically. Individual ISAs can be left out when Cretonne is compiled, so a
//! - The name of the target ISA as a string. Cranelift is a cross-compiler, so the ISA to target
//! can be selected dynamically. Individual ISAs can be left out when Cranelift is compiled, so a
//! string is used to identify the proper sub-module.
//! - Values for settings that apply to all ISAs. This is represented by a `settings::Flags`
//! instance.
@@ -20,11 +20,11 @@
//! appropriate for the requested ISA:
//!
//! ```
//! # extern crate cretonne_codegen;
//! # extern crate cranelift_codegen;
//! # #[macro_use] extern crate target_lexicon;
//! # fn main() {
//! use cretonne_codegen::settings::{self, Configurable};
//! use cretonne_codegen::isa;
//! use cranelift_codegen::settings::{self, Configurable};
//! use cranelift_codegen::isa;
//! use std::str::FromStr;
//! use target_lexicon::Triple;
//!

View File

@@ -274,7 +274,7 @@ pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenRes
pub fn baldrdash_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenResult<()> {
debug_assert!(
!isa.flags().probestack_enabled(),
"baldrdash does not expect cretonne to emit stack probes"
"baldrdash does not expect cranelift to emit stack probes"
);
// Baldrdash on 32-bit x86 always aligns its stack pointer to 16 bytes.
@@ -325,7 +325,7 @@ pub fn fastcall_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> C
let csr_stack_size = ((csrs.iter(GPR).len() + 2) * word_size) as i32;
// TODO: eventually use the 32 bytes (shadow store) as spill slot. This currently doesn't work
// since cretonne does not support spill slots before incoming args
// since cranelift does not support spill slots before incoming args
func.create_stack_slot(ir::StackSlotData {
kind: ir::StackSlotKind::IncomingArg,

View File

@@ -14,13 +14,13 @@
//!
//! When legalizing a single instruction, it is wrapped in splits and concatenations:
//!
//!```cton
//!```clif
//! v1 = bxor.i64 v2, v3
//! ```
//!
//! becomes:
//!
//!```cton
//!```clif
//! v20, v21 = isplit v2
//! v30, v31 = isplit v3
//! v10 = bxor.i32 v20, v30
@@ -38,13 +38,13 @@
//! first check if the value is defined by the corresponding concatenation. If so, then just use
//! the two concatenation inputs directly:
//!
//! ```cton
//! ```clif
//! v4 = iadd_imm.i64 v1, 1
//! ```
//!
//! becomes, using the expanded code from above:
//!
//! ```cton
//! ```clif
//! v40, v5 = iadd_imm_cout.i32 v10, 1
//! v6 = bint.i32
//! v41 = iadd.i32 v11, v6
@@ -283,7 +283,7 @@ fn add_repair(
///
/// Given this input:
///
/// ```cton
/// ```clif
/// v10 = iconcat v1, v2
/// v11, v12 = isplit v10
/// ```

View File

@@ -1,4 +1,4 @@
//! Cretonne code generation library.
//! Cranelift code generation library.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)]
@@ -56,11 +56,11 @@ pub use legalizer::legalize_function;
pub use verifier::verify_function;
pub use write::write_function;
/// Version number of the cretonne-codegen crate.
/// Version number of the cranelift-codegen crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[macro_use]
pub extern crate cretonne_entity as entity;
pub extern crate cranelift_entity as entity;
#[macro_use]
pub mod dbg;

View File

@@ -65,7 +65,7 @@ fn pretty_function_error(
}
}
/// Pretty-print a Cretonne error.
/// Pretty-print a Cranelift error.
pub fn pretty_error(func: &ir::Function, isa: Option<&TargetIsa>, err: CodegenError) -> String {
if let CodegenError::Verifier(e) = err {
pretty_verifier_error(func, isa, &e)

View File

@@ -64,7 +64,7 @@
//! LLVM's register allocator computes liveness per *virtual register*, where a virtual register is
//! a disjoint union of related SSA values that should be assigned to the same physical register.
//! It uses a compact data structure very similar to our `LiveRange`. The important difference is
//! that Cretonne's `LiveRange` only describes a single SSA value, while LLVM's `LiveInterval`
//! that Cranelift's `LiveRange` only describes a single SSA value, while LLVM's `LiveInterval`
//! describes the live range of a virtual register *and* which one of the related SSA values is
//! live at any given program point.
//!
@@ -93,11 +93,11 @@
//! functions.
//! - A single live range can be recomputed after making modifications to the IR. No global
//! algorithm is necessary. This feature depends on having use-def chains for virtual registers
//! which Cretonne doesn't.
//! which Cranelift doesn't.
//!
//! Cretonne uses a very similar data structures and algorithms to LLVM, with the important
//! Cranelift uses a very similar data structures and algorithms to LLVM, with the important
//! difference that live ranges are computed per SSA value instead of per virtual register, and the
//! uses in Cretonne IR refers to SSA values instead of virtual registers. This means that Cretonne
//! uses in Cranelift IR refers to SSA values instead of virtual registers. This means that Cranelift
//! can skip the last step of reconstructing SSA form for the virtual register uses.
//!
//! ## Fast Liveness Checking for SSA-Form Programs
@@ -112,27 +112,27 @@
//! then allows liveness queries for any (value, program point) pair. Each query traverses the use
//! chain of the value and performs lookups in the precomputed bit-vectors.
//!
//! I did not seriously consider this analysis for Cretonne because:
//! I did not seriously consider this analysis for Cranelift because:
//!
//! - It depends critically on use chains which Cretonne doesn't have.
//! - It depends critically on use chains which Cranelift doesn't have.
//! - Popular variables like the `this` pointer in a C++ method can have very large use chains.
//! Traversing such a long use chain on every liveness lookup has the potential for some nasty
//! quadratic behavior in unfortunate cases.
//! - It says "fast" in the title, but the paper only claims to be 16% faster than a data-flow
//! based approach, which isn't that impressive.
//!
//! Nevertheless, the property of only depending in the CFG structure is very useful. If Cretonne
//! Nevertheless, the property of only depending in the CFG structure is very useful. If Cranelift
//! gains use chains, this approach would be worth a proper evaluation.
//!
//!
//! # Cretonne's liveness analysis
//! # Cranelift's liveness analysis
//!
//! The algorithm implemented in this module is similar to LLVM's with these differences:
//!
//! - The `LiveRange` data structure describes the liveness of a single SSA value, not a virtual
//! register.
//! - Instructions in Cretonne IR contains references to SSA values, not virtual registers.
//! - All live ranges are computed in one traversal of the program. Cretonne doesn't have use
//! - Instructions in Cranelift IR contains references to SSA values, not virtual registers.
//! - All live ranges are computed in one traversal of the program. Cranelift doesn't have use
//! chains, so it is not possible to compute the live range for a single SSA value independently.
//!
//! The liveness computation visits all instructions in the program. The order is not important for
@@ -150,18 +150,18 @@
//! visited. No data about each value beyond the live range is needed between visiting uses, so
//! nothing is lost by computing the live range of all values simultaneously.
//!
//! ## Cache efficiency of Cretonne vs LLVM
//! ## Cache efficiency of Cranelift vs LLVM
//!
//! Since LLVM computes the complete live range of a virtual register in one go, it can keep the
//! whole `LiveInterval` for the register in L1 cache. Since it is visiting the instructions in use
//! chain order, some cache thrashing can occur as a result of pulling instructions into cache
//! somewhat chaotically.
//!
//! Cretonne uses a transposed algorithm, visiting instructions in order. This means that each
//! Cranelift uses a transposed algorithm, visiting instructions in order. This means that each
//! instruction is brought into cache only once, and it is likely that the other instructions on
//! the same cache line will be visited before the line is evicted.
//!
//! Cretonne's problem is that the `LiveRange` structs are visited many times and not always
//! Cranelift's problem is that the `LiveRange` structs are visited many times and not always
//! regularly. We should strive to make the `LiveRange` struct as small as possible such that
//! multiple related values can live on the same cache line.
//!

View File

@@ -41,7 +41,7 @@
//!
//! If one live range ends at an instruction that defines another live range, those two live ranges
//! are not considered to interfere. This is because most ISAs allow instructions to reuse an input
//! register for an output value. If Cretonne gets support for inline assembly, we will need to
//! register for an output value. If Cranelift gets support for inline assembly, we will need to
//! handle *early clobbers* which are output registers that are not allowed to alias any input
//! registers.
//!

View File

@@ -4,22 +4,22 @@ use verifier::VerifierError;
/// A compilation error.
///
/// When Cretonne fails to compile a function, it will return one of these error codes.
/// When Cranelift fails to compile a function, it will return one of these error codes.
#[derive(Fail, Debug, PartialEq, Eq)]
pub enum CodegenError {
/// An IR verifier error.
///
/// This always represents a bug, either in the code that generated IR for Cretonne, or a bug
/// in Cretonne itself.
/// This always represents a bug, either in the code that generated IR for Cranelift, or a bug
/// in Cranelift itself.
#[fail(display = "Verifier error: {}", _0)]
Verifier(#[cause] VerifierError),
/// An implementation limit was exceeded.
///
/// Cretonne can compile very large and complicated functions, but the [implementation has
/// Cranelift can compile very large and complicated functions, but the [implementation has
/// limits][limits] that cause compilation to fail when they are exceeded.
///
/// [limits]: https://cretonne.readthedocs.io/en/latest/langref.html#implementation-limits
/// [limits]: https://cranelift.readthedocs.io/en/latest/langref.html#implementation-limits
#[fail(display = "Implementation limit exceeded")]
ImplLimitExceeded,

View File

@@ -11,7 +11,7 @@
//!
//! # Example
//! ```
//! use cretonne_codegen::settings::{self, Configurable};
//! use cranelift_codegen::settings::{self, Configurable};
//!
//! let mut b = settings::builder();
//! b.set("opt_level", "fastest");

View File

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

View File

@@ -11,7 +11,7 @@ use verifier::VerifierResult;
/// Verify conventional SSA form for `func`.
///
/// Conventional SSA form is represented in Cretonne with the help of virtual registers:
/// Conventional SSA form is represented in Cranelift with the help of virtual registers:
///
/// - Two values are said to be *PHI-related* if one is an EBB argument and the other is passed as
/// a branch argument in a location that matches the first value.

View File

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

View File

@@ -1,11 +1,11 @@
[package]
authors = ["The Cretonne Project Developers"]
name = "cretonne-entity"
authors = ["The Cranelift Project Developers"]
name = "cranelift-entity"
version = "0.13.0"
description = "Data structures using entity references as mapping keys"
license = "Apache-2.0 WITH LLVM-exception"
documentation = "https://cretonne.readthedocs.io/"
repository = "https://github.com/cretonne/cretonne"
documentation = "https://cranelift.readthedocs.io/"
repository = "https://github.com/cranelift/cranelift"
readme = "README.md"
keywords = ["entity", "set", "map"]
@@ -15,4 +15,4 @@ std = []
[badges]
maintenance = { status = "experimental" }
travis-ci = { repository = "cretonne/cretonne" }
travis-ci = { repository = "cranelift/cranelift" }

View File

@@ -1,2 +1,2 @@
This crate contains array-based data structures used by the core Cretonne code
This crate contains array-based data structures used by the core Cranelift code
generator which use densely numbered entity references as mapping keys.

View File

@@ -1,6 +1,6 @@
//! Compact representation of `Option<T>` for types with a reserved value.
//!
//! Small Cretonne types like the 32-bit entity references are often used in tables and linked
//! Small Cranelift types like the 32-bit entity references are often used in tables and linked
//! lists where an `Option<T>` is needed. Unfortunately, that would double the size of the tables
//! because `Option<T>` is twice as big as `T`.
//!

View File

@@ -1,16 +1,16 @@
[package]
name = "cretonne-faerie"
name = "cranelift-faerie"
version = "0.13.0"
authors = ["The Cretonne Project Developers"]
description = "Emit Cretonne output to native object files with Faerie"
repository = "https://github.com/cretonne/cretonne"
documentation = "https://cretonne.readthedocs.io/"
authors = ["The Cranelift Project Developers"]
description = "Emit Cranelift output to native object files with Faerie"
repository = "https://github.com/cranelift/cranelift"
documentation = "https://cranelift.readthedocs.io/"
license = "Apache-2.0 WITH LLVM-exception"
readme = "README.md"
[dependencies]
cretonne-codegen = { path = "../codegen", version = "0.13.0" }
cretonne-module = { path = "../module", version = "0.13.0" }
cranelift-codegen = { path = "../codegen", version = "0.13.0" }
cranelift-module = { path = "../module", version = "0.13.0" }
faerie = "0.4.2"
goblin = "0.0.15"
failure = "0.1.1"
@@ -18,4 +18,4 @@ target-lexicon = "0.0.2"
[badges]
maintenance = { status = "experimental" }
travis-ci = { repository = "cretonne/cretonne" }
travis-ci = { repository = "cranelift/cranelift" }

View File

@@ -1,4 +1,4 @@
This crate contains a library that enables
[Cretonne](https://crates.io/crates/cretonne)
[Cranelift](https://crates.io/crates/cranelift)
to emit native object (".o") files, using the
[Faerie](https://crates.io/crates/faerie) library.

View File

@@ -1,10 +1,10 @@
//! Defines `FaerieBackend`.
use container;
use cretonne_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink};
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::{self, binemit, ir};
use cretonne_module::{
use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink};
use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::{self, binemit, ir};
use cranelift_module::{
Backend, DataContext, DataDescription, Init, Linkage, ModuleError, ModuleNamespace,
ModuleResult,
};
@@ -34,16 +34,16 @@ pub struct FaerieBuilder {
}
impl FaerieBuilder {
/// Create a new `FaerieBuilder` using the given Cretonne target, that
/// Create a new `FaerieBuilder` using the given Cranelift target, that
/// can be passed to
/// [`Module::new`](cretonne_module/struct.Module.html#method.new].
/// [`Module::new`](cranelift_module/struct.Module.html#method.new].
///
/// Faerie output requires that TargetIsa have PIC (Position Independent Code) enabled.
///
/// `collect_traps` setting determines whether trap information is collected in a
/// `FaerieTrapManifest` available in the `FaerieProduct`.
///
/// The `libcall_names` function provides a way to translate `cretonne_codegen`'s `ir::LibCall`
/// The `libcall_names` function provides a way to translate `cranelift_codegen`'s `ir::LibCall`
/// enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain
/// floating point instructions, and for stack probes. If you don't know what to use for this
/// argument, use `FaerieBuilder::default_libcall_names()`.
@@ -68,10 +68,10 @@ impl FaerieBuilder {
/// Default names for `ir::LibCall`s. A function by this name is imported into the object as
/// part of the translation of a `ir::ExternalName::LibCall` variant. Calls to a LibCall should
/// only be inserted into the IR by the `cretonne_codegen` legalizer pass.
/// only be inserted into the IR by the `cranelift_codegen` legalizer pass.
pub fn default_libcall_names() -> Box<Fn(ir::LibCall) -> String> {
Box::new(move |libcall| match libcall {
ir::LibCall::Probestack => "__cretonne_probestack".to_owned(),
ir::LibCall::Probestack => "__cranelift_probestack".to_owned(),
ir::LibCall::CeilF32 => "ceilf".to_owned(),
ir::LibCall::CeilF64 => "ceil".to_owned(),
ir::LibCall::FloorF32 => "floorf".to_owned(),
@@ -111,7 +111,7 @@ impl Backend for FaerieBackend {
/// to memory and files.
type Product = FaerieProduct;
/// Create a new `FaerieBackend` using the given Cretonne target.
/// Create a new `FaerieBackend` using the given Cranelift target.
fn new(builder: FaerieBuilder) -> Self {
Self {
artifact: faerie::Artifact::new(builder.isa.triple().clone(), builder.name),
@@ -143,7 +143,7 @@ impl Backend for FaerieBackend {
fn define_function(
&mut self,
name: &str,
ctx: &cretonne_codegen::Context,
ctx: &cranelift_codegen::Context,
namespace: &ModuleNamespace<Self>,
code_size: u32,
) -> ModuleResult<FaerieCompiledFunction> {
@@ -290,7 +290,7 @@ impl Backend for FaerieBackend {
}
/// This is the output of `Module`'s
/// [`finish`](../cretonne_module/struct.Module.html#method.finish) function.
/// [`finish`](../cranelift_module/struct.Module.html#method.finish) function.
/// It provides functions for writing out the object file to memory or a file.
pub struct FaerieProduct {
/// Faerie artifact with all functions, data, and links from the module defined

View File

@@ -1,6 +1,6 @@
//! Utilities for working with Faerie container formats.
use cretonne_codegen::binemit::Reloc;
use cranelift_codegen::binemit::Reloc;
use target_lexicon::{Architecture, BinaryFormat, Triple};
/// An object file format.
@@ -12,7 +12,7 @@ pub enum Format {
MachO,
}
/// Translate from a Cretonne `Reloc` to a raw object-file-format-specific
/// Translate from a Cranelift `Reloc` to a raw object-file-format-specific
/// relocation code and relocation-implied addend.
pub fn raw_relocation(reloc: Reloc, triple: &Triple) -> (u32, i64) {
match triple.binary_format {
@@ -25,7 +25,7 @@ pub fn raw_relocation(reloc: Reloc, triple: &Triple) -> (u32, i64) {
Reloc::Abs4 => elf::reloc::R_X86_64_32,
Reloc::Abs8 => elf::reloc::R_X86_64_64,
Reloc::X86PCRel4 | Reloc::X86CallPCRel4 => elf::reloc::R_X86_64_PC32,
// TODO: Get Cretonne to tell us when we can use
// TODO: Get Cranelift to tell us when we can use
// R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX.
Reloc::X86CallPLTRel4 => elf::reloc::R_X86_64_PLT32,
Reloc::X86GOTPCRel4 => elf::reloc::R_X86_64_GOTPCREL,

View File

@@ -1,4 +1,4 @@
//! Top-level lib.rs for `cretonne_faerie`.
//! Top-level lib.rs for `cranelift_faerie`.
//!
//! Users of this module should not have to depend on faerie directly.
@@ -14,8 +14,8 @@
)
)]
extern crate cretonne_codegen;
extern crate cretonne_module;
extern crate cranelift_codegen;
extern crate cranelift_module;
extern crate faerie;
extern crate failure;
extern crate goblin;

View File

@@ -1,15 +1,15 @@
//! Faerie trap manifests record every `TrapCode` that cretonne outputs during code generation,
//! Faerie trap manifests record every `TrapCode` that cranelift outputs during code generation,
//! for every function in the module. This data may be useful at runtime.
use cretonne_codegen::{binemit, ir};
use cranelift_codegen::{binemit, ir};
/// Record of the arguments cretonne passes to `TrapSink::trap`
/// Record of the arguments cranelift passes to `TrapSink::trap`
pub struct FaerieTrapSite {
/// Offset into function
pub offset: binemit::CodeOffset,
/// Source location given to cretonne
/// Source location given to cranelift
pub srcloc: ir::SourceLoc,
/// Trap code, as determined by cretonne
/// Trap code, as determined by cranelift
pub code: ir::TrapCode,
}

View File

@@ -1,15 +1,15 @@
[package]
name = "cretonne-filetests"
authors = ["The Cretonne Project Developers"]
name = "cranelift-filetests"
authors = ["The Cranelift Project Developers"]
version = "0.13.0"
description = "Test driver and implementations of the filetest commands"
license = "Apache-2.0 WITH LLVM-exception"
documentation = "https://cretonne.readthedocs.io/en/latest/testing.html#file-tests"
repository = "https://github.com/cretonne/cretonne"
documentation = "https://cranelift.readthedocs.io/en/latest/testing.html#file-tests"
repository = "https://github.com/cranelift/cranelift"
publish = false
[dependencies]
cretonne-codegen = { path = "../codegen", version = "0.13.0" }
cretonne-reader = { path = "../reader", version = "0.13.0" }
cranelift-codegen = { path = "../codegen", version = "0.13.0" }
cranelift-reader = { path = "../reader", version = "0.13.0" }
filecheck = "0.3.0"
num_cpus = "1.8.0"

View File

@@ -3,7 +3,7 @@
//! This module provides the `ConcurrentRunner` struct which uses a pool of threads to run tests
//! concurrently.
use cretonne_codegen::timing;
use cranelift_codegen::timing;
use num_cpus;
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};

View File

@@ -18,12 +18,12 @@
)]
#[macro_use(dbg)]
extern crate cretonne_codegen;
extern crate cretonne_reader;
extern crate cranelift_codegen;
extern crate cranelift_reader;
extern crate filecheck;
extern crate num_cpus;
use cretonne_reader::TestCommand;
use cranelift_reader::TestCommand;
use runner::TestRunner;
use std::path::Path;
use std::time;
@@ -52,13 +52,13 @@ mod test_verifier;
/// The result of running the test in a file.
type TestResult = Result<time::Duration, String>;
/// Main entry point for `cton-util test`.
/// Main entry point for `clif-util test`.
///
/// Take a list of filenames which can be either `.cton` files or directories.
/// Take a list of filenames which can be either `.clif` files or directories.
///
/// Files are interpreted as test cases and executed immediately.
///
/// Directories are scanned recursively for test cases ending in `.cton`. These test cases are
/// Directories are scanned recursively for test cases ending in `.clif`. These test cases are
/// executed on background threads.
///
pub fn run(verbose: bool, files: &[String]) -> TestResult {
@@ -79,7 +79,7 @@ pub fn run(verbose: bool, files: &[String]) -> TestResult {
/// Create a new subcommand trait object to match `parsed.command`.
///
/// This function knows how to create all of the possible `test <foo>` commands that can appear in
/// a `.cton` test file.
/// a `.clif` test file.
fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<subtest::SubTest>> {
match parsed.command {
"binemit" => test_binemit::subtest(parsed),

View File

@@ -116,7 +116,7 @@ impl TestRunner {
// This recursive search tries to minimize statting in a directory hierarchy containing
// mostly test cases.
//
// - Directory entries with a "cton" extension are presumed to be test case files.
// - Directory entries with a "clif" extension are presumed to be test case files.
// - Directory entries with no extension are presumed to be subdirectories.
// - Anything else is ignored.
//
@@ -149,7 +149,7 @@ impl TestRunner {
// Recognize directories and tests by extension.
// Yes, this means we ignore directories with '.' in their name.
match path.extension().and_then(OsStr::to_str) {
Some("cton") => self.push_test(path),
Some("clif") => self.push_test(path),
Some(_) => {}
None => self.push_dir(path),
}

View File

@@ -1,13 +1,13 @@
//! Run the tests in a single test file.
use cretonne_codegen::ir::Function;
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::print_errors::pretty_verifier_error;
use cretonne_codegen::settings::Flags;
use cretonne_codegen::timing;
use cretonne_codegen::verify_function;
use cretonne_reader::parse_test;
use cretonne_reader::IsaSpec;
use cranelift_codegen::ir::Function;
use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::print_errors::pretty_verifier_error;
use cranelift_codegen::settings::Flags;
use cranelift_codegen::timing;
use cranelift_codegen::verify_function;
use cranelift_reader::parse_test;
use cranelift_reader::IsaSpec;
use std::borrow::Cow;
use std::fs;
use std::io::{self, Read};

View File

@@ -1,9 +1,9 @@
//! `SubTest` trait.
use cretonne_codegen::ir::Function;
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::settings::{Flags, FlagsOrIsa};
use cretonne_reader::{Comment, Details};
use cranelift_codegen::ir::Function;
use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::settings::{Flags, FlagsOrIsa};
use cranelift_reader::{Comment, Details};
use filecheck::{Checker, CheckerBuilder, NO_VARIABLES};
use std::borrow::Cow;
@@ -40,7 +40,7 @@ impl<'a> Context<'a> {
/// Common interface for implementations of test commands.
///
/// Each `.cton` test file may contain multiple test commands, each represented by a `SubTest`
/// Each `.clif` test file may contain multiple test commands, each represented by a `SubTest`
/// trait object.
pub trait SubTest {
/// Name identifying this subtest. Typically the same as the test command.

View File

@@ -3,14 +3,14 @@
//! The `binemit` test command generates binary machine code for every instruction in the input
//! functions and compares the results to the expected output.
use cretonne_codegen::binemit;
use cretonne_codegen::binemit::RegDiversions;
use cretonne_codegen::dbg::DisplayList;
use cretonne_codegen::ir;
use cretonne_codegen::ir::entities::AnyEntity;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_codegen::settings::OptLevel;
use cretonne_reader::TestCommand;
use cranelift_codegen::binemit;
use cranelift_codegen::binemit::RegDiversions;
use cranelift_codegen::dbg::DisplayList;
use cranelift_codegen::ir;
use cranelift_codegen::ir::entities::AnyEntity;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::settings::OptLevel;
use cranelift_reader::TestCommand;
use match_directive::match_directive;
use std::borrow::Cow;
use std::collections::HashMap;

View File

@@ -1,7 +1,7 @@
//! The `cat` subtest.
use cretonne_codegen::ir::Function;
use cretonne_reader::TestCommand;
use cranelift_codegen::ir::Function;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{self, Context, SubTest, SubtestResult};

View File

@@ -2,10 +2,10 @@
//!
//! The `compile` test command runs each function through the full code generator pipeline
use cretonne_codegen;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_codegen::{binemit, ir};
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::{binemit, ir};
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -35,7 +35,7 @@ impl SubTest for TestCompile {
fn run(&self, func: Cow<ir::Function>, context: &Context) -> SubtestResult<()> {
let isa = context.isa.expect("compile needs an ISA");
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
let code_size = comp_ctx
.compile(isa)

View File

@@ -5,10 +5,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -33,7 +33,7 @@ impl SubTest for TestDCE {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx.flowgraph();
comp_ctx.compute_loop_analysis();

View File

@@ -2,7 +2,7 @@
//!
//! The `test domtree` test command looks for annotations on instructions like this:
//!
//! ```cton
//! ```clif
//! jump ebb3 ; dominates: ebb3
//! ```
//!
@@ -12,11 +12,11 @@
//! We verify that the dominator tree annotations are complete and correct.
//!
use cretonne_codegen::dominator_tree::{DominatorTree, DominatorTreePreorder};
use cretonne_codegen::flowgraph::ControlFlowGraph;
use cretonne_codegen::ir::entities::AnyEntity;
use cretonne_codegen::ir::Function;
use cretonne_reader::TestCommand;
use cranelift_codegen::dominator_tree::{DominatorTree, DominatorTreePreorder};
use cranelift_codegen::flowgraph::ControlFlowGraph;
use cranelift_codegen::ir::entities::AnyEntity;
use cranelift_codegen::ir::Function;
use cranelift_reader::TestCommand;
use match_directive::match_directive;
use std::borrow::{Borrow, Cow};
use std::collections::HashMap;

View File

@@ -3,10 +3,10 @@
//! The `test legalizer` test command runs each function through `legalize_function()` and sends
//! the result to filecheck.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -35,7 +35,7 @@ impl SubTest for TestLegalizer {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
let isa = context.isa.expect("legalizer needs an ISA");
comp_ctx.compute_cfg();

View File

@@ -5,10 +5,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -33,7 +33,7 @@ impl SubTest for TestLICM {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx.flowgraph();
comp_ctx.compute_loop_analysis();

View File

@@ -2,10 +2,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -30,7 +30,7 @@ impl SubTest for TestPostopt {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
let isa = context.isa.expect("postopt needs an ISA");
comp_ctx.flowgraph();

View File

@@ -2,10 +2,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -30,7 +30,7 @@ impl SubTest for TestPreopt {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
let isa = context.isa.expect("preopt needs an ISA");
comp_ctx.flowgraph();

View File

@@ -1,13 +1,13 @@
//! The `print-cfg` sub-command.
//!
//! Read a series of Cretonne IR files and print their control flow graphs
//! Read a series of Cranelift IR files and print their control flow graphs
//! in graphviz format.
use std::borrow::Cow;
use cretonne_codegen::cfg_printer::CFGPrinter;
use cretonne_codegen::ir::Function;
use cretonne_reader::TestCommand;
use cranelift_codegen::cfg_printer::CFGPrinter;
use cranelift_codegen::ir::Function;
use cranelift_reader::TestCommand;
use subtest::{self, Context, SubTest, SubtestResult};
/// Object implementing the `test print-cfg` sub-test.

View File

@@ -5,10 +5,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -38,7 +38,7 @@ impl SubTest for TestRegalloc {
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let isa = context.isa.expect("register allocator needs an ISA");
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx.compute_cfg();
// TODO: Should we have an option to skip legalization?

View File

@@ -5,10 +5,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -34,7 +34,7 @@ impl SubTest for TestShrink {
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let isa = context.isa.expect("shrink needs an ISA");
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx
.shrink_instructions(isa)

View File

@@ -5,10 +5,10 @@
//!
//! The resulting function is sent to `filecheck`.
use cretonne_codegen;
use cretonne_codegen::ir::Function;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_reader::TestCommand;
use cranelift_codegen;
use cranelift_codegen::ir::Function;
use cranelift_codegen::print_errors::pretty_error;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
@@ -33,7 +33,7 @@ impl SubTest for TestSimpleGVN {
}
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx.flowgraph();
comp_ctx

View File

@@ -2,16 +2,16 @@
//!
//! The `test verifier` test command looks for annotations on instructions like this:
//!
//! ```cton
//! ```clif
//! jump ebb3 ; error: jump to non-existent EBB
//! ```
//!
//! This annotation means that the verifier is expected to given an error for the jump instruction
//! containing the substring "jump to non-existent EBB".
use cretonne_codegen::ir::Function;
use cretonne_codegen::verify_function;
use cretonne_reader::TestCommand;
use cranelift_codegen::ir::Function;
use cranelift_codegen::verify_function;
use cranelift_reader::TestCommand;
use match_directive::match_directive;
use std::borrow::{Borrow, Cow};
use subtest::{Context, SubTest, SubtestResult};

View File

@@ -1,21 +1,21 @@
[package]
authors = ["The Cretonne Project Developers"]
name = "cretonne-frontend"
authors = ["The Cranelift Project Developers"]
name = "cranelift-frontend"
version = "0.13.0"
description = "Cretonne IR builder helper"
description = "Cranelift IR builder helper"
license = "Apache-2.0 WITH LLVM-exception"
documentation = "https://cretonne.readthedocs.io/"
repository = "https://github.com/cretonne/cretonne"
documentation = "https://cranelift.readthedocs.io/"
repository = "https://github.com/cranelift/cranelift"
readme = "README.md"
[dependencies]
cretonne-codegen = { path = "../codegen", version = "0.13.0", default-features = false }
cranelift-codegen = { path = "../codegen", version = "0.13.0", default-features = false }
[features]
default = ["std"]
std = ["cretonne-codegen/std"]
core = ["cretonne-codegen/core"]
std = ["cranelift-codegen/std"]
core = ["cranelift-codegen/core"]
[badges]
maintenance = { status = "experimental" }
travis-ci = { repository = "cretonne/cretonne" }
travis-ci = { repository = "cranelift/cranelift" }

View File

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

View File

@@ -1,19 +1,19 @@
//! A frontend for building Cretonne IR from other languages.
use cretonne_codegen::cursor::{Cursor, FuncCursor};
use cretonne_codegen::entity::{EntityMap, EntityRef, EntitySet};
use cretonne_codegen::ir;
use cretonne_codegen::ir::function::DisplayFunction;
use cretonne_codegen::ir::{
//! A frontend for building Cranelift IR from other languages.
use cranelift_codegen::cursor::{Cursor, FuncCursor};
use cranelift_codegen::entity::{EntityMap, EntityRef, EntitySet};
use cranelift_codegen::ir;
use cranelift_codegen::ir::function::DisplayFunction;
use cranelift_codegen::ir::{
DataFlowGraph, Ebb, ExtFuncData, FuncRef, Function, GlobalValue, GlobalValueData, Heap,
HeapData, Inst, InstBuilderBase, InstructionData, JumpTable, JumpTableData, SigRef, Signature,
StackSlot, StackSlotData, Type, Value,
};
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::packed_option::PackedOption;
use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::packed_option::PackedOption;
use ssa::{Block, SSABuilder, SideEffects};
use std::fmt::Debug;
/// Structure used for translating a series of functions into Cretonne IR.
/// Structure used for translating a series of functions into Cranelift IR.
///
/// In order to reduce memory reallocations when compiling multiple functions,
/// `FunctionBuilderContext` holds various data structures which are cleared between
@@ -31,7 +31,7 @@ where
types: EntityMap<Variable, Type>,
}
/// Temporary object used to build a single Cretonne IR `Function`.
/// Temporary object used to build a single Cranelift IR `Function`.
pub struct FunctionBuilder<'a, Variable: 'a>
where
Variable: EntityRef + Debug,
@@ -105,7 +105,7 @@ where
}
/// Implementation of the [`InstBuilder`](../codegen/ir/builder/trait.InstBuilder.html) that has
/// one convenience method per Cretonne IR instruction.
/// one convenience method per Cranelift IR instruction.
pub struct FuncInstBuilder<'short, 'long: 'short, Variable: 'long>
where
Variable: EntityRef + Debug,
@@ -195,7 +195,7 @@ where
}
}
/// This module allows you to create a function in Cretonne IR in a straightforward way, hiding
/// This module allows you to create a function in Cranelift IR in a straightforward way, hiding
/// all the complexity of its internal representation.
///
/// The module is parametrized by one type which is the representation of variables in your
@@ -207,10 +207,10 @@ where
/// - 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.
///
/// The parameters of Cretonne IR instructions are Cretonne IR values, which can only be created
/// as results of other Cretonne IR instructions. To be able to create variables redefined multiple
/// The parameters of Cranelift IR instructions are Cranelift IR values, which can only be created
/// as results of other Cranelift 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
/// correspondence between your variables and Cretonne IR SSA values.
/// correspondence between your variables and Cranelift IR SSA values.
///
/// The first block for which you call `switch_to_block` will be assumed to be the beginning of
/// the function.
@@ -224,7 +224,7 @@ where
///
/// # Errors
///
/// The functions below will panic in debug mode whenever you try to modify the Cretonne IR
/// The functions below will panic in debug mode whenever you try to modify the Cranelift IR
/// 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
/// return instruction with arguments that don't match the function's signature.
@@ -317,7 +317,7 @@ where
self.func_ctx.types[var] = ty;
}
/// Returns the Cretonne IR value corresponding to the utilization at the current program
/// Returns the Cranelift IR value corresponding to the utilization at the current program
/// position of a previously defined user variable.
pub fn use_var(&mut self, var: Variable) -> Value {
let (val, side_effects) = {
@@ -481,8 +481,8 @@ where
}
/// All the functions documented in the previous block are write-only and help you build a valid
/// 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 IR
/// Cranelift IR functions via multiple debug asserts. However, you might need to improve the
/// performance of your translation perform more complex transformations to your Cranelift IR
/// function. The functions below help you inspect the function you're creating and modify it
/// in ways that can be unsafe if used incorrectly.
impl<'a, Variable> FunctionBuilder<'a, Variable>
@@ -610,12 +610,12 @@ where
#[cfg(test)]
mod tests {
use cretonne_codegen::entity::EntityRef;
use cretonne_codegen::ir::types::*;
use cretonne_codegen::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature};
use cretonne_codegen::settings;
use cretonne_codegen::settings::CallConv;
use cretonne_codegen::verifier::verify_function;
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::ir::types::*;
use cranelift_codegen::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature};
use cranelift_codegen::settings;
use cranelift_codegen::settings::CallConv;
use cranelift_codegen::verifier::verify_function;
use frontend::{FunctionBuilder, FunctionBuilderContext};
use Variable;

View File

@@ -1,17 +1,17 @@
//! Cretonne IR builder library.
//! Cranelift IR builder library.
//!
//! Provides a straightforward way to create a Cretonne IR function and fill it with instructions
//! Provides a straightforward way to create a Cranelift IR function and fill it with instructions
//! translated from another language. Contains an SSA construction module that lets you translate
//! your non-SSA variables into SSA Cretonne IR values via `use_var` and `def_var` calls.
//! your non-SSA variables into SSA Cranelift IR values via `use_var` and `def_var` calls.
//!
//! To get started, create an [`FunctionBuilderContext`](struct.FunctionBuilderContext.html) and
//! pass it as an argument to a [`FunctionBuilder`](struct.FunctionBuilder.html).
//!
//! # Example
//!
//! Here is a pseudo-program we want to transform into Cretonne IR:
//! Here is a pseudo-program we want to transform into Cranelift IR:
//!
//! ```cton
//! ```clif
//! function(x) {
//! x, y, z : i32
//! block0:
@@ -29,18 +29,18 @@
//! }
//! ```
//!
//! Here is how you build the corresponding Cretonne IR function using `FunctionBuilderContext`:
//! Here is how you build the corresponding Cranelift IR function using `FunctionBuilderContext`:
//!
//! ```rust
//! extern crate cretonne_codegen;
//! extern crate cretonne_frontend;
//! extern crate cranelift_codegen;
//! extern crate cranelift_frontend;
//!
//! use cretonne_codegen::entity::EntityRef;
//! use cretonne_codegen::ir::{ExternalName, Function, Signature, AbiParam, InstBuilder};
//! use cretonne_codegen::ir::types::*;
//! use cretonne_codegen::settings::{self, CallConv};
//! use cretonne_frontend::{FunctionBuilderContext, FunctionBuilder, Variable};
//! use cretonne_codegen::verifier::verify_function;
//! use cranelift_codegen::entity::EntityRef;
//! use cranelift_codegen::ir::{ExternalName, Function, Signature, AbiParam, InstBuilder};
//! use cranelift_codegen::ir::types::*;
//! use cranelift_codegen::settings::{self, CallConv};
//! use cranelift_frontend::{FunctionBuilderContext, FunctionBuilder, Variable};
//! use cranelift_codegen::verifier::verify_function;
//!
//! fn main() {
//! let mut sig = Signature::new(CallConv::SystemV);
@@ -141,7 +141,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
extern crate cretonne_codegen;
extern crate cranelift_codegen;
pub use frontend::{FunctionBuilder, FunctionBuilderContext};
pub use variable::Variable;

View File

@@ -5,14 +5,14 @@
//! In: Jhala R., De Bosschere K. (eds) Compiler Construction. CC 2013.
//! Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg
use cretonne_codegen::cursor::{Cursor, FuncCursor};
use cretonne_codegen::entity::{EntityMap, EntityRef, PrimaryMap};
use cretonne_codegen::ir::immediates::{Ieee32, Ieee64};
use cretonne_codegen::ir::instructions::BranchInfo;
use cretonne_codegen::ir::types::{F32, F64};
use cretonne_codegen::ir::{Ebb, Function, Inst, InstBuilder, Type, Value};
use cretonne_codegen::packed_option::PackedOption;
use cretonne_codegen::packed_option::ReservedValue;
use cranelift_codegen::cursor::{Cursor, FuncCursor};
use cranelift_codegen::entity::{EntityMap, EntityRef, PrimaryMap};
use cranelift_codegen::ir::immediates::{Ieee32, Ieee64};
use cranelift_codegen::ir::instructions::BranchInfo;
use cranelift_codegen::ir::types::{F32, F64};
use cranelift_codegen::ir::{Ebb, Function, Inst, InstBuilder, Type, Value};
use cranelift_codegen::packed_option::PackedOption;
use cranelift_codegen::packed_option::ReservedValue;
use std::mem;
use std::u32;
use std::vec::Vec;
@@ -233,7 +233,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
/// translating to Cretonne IR:
/// translating to Cranelift IR:
///
/// - 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
@@ -715,13 +715,13 @@ where
#[cfg(test)]
mod tests {
use cretonne_codegen::cursor::{Cursor, FuncCursor};
use cretonne_codegen::entity::EntityRef;
use cretonne_codegen::ir::instructions::BranchInfo;
use cretonne_codegen::ir::types::*;
use cretonne_codegen::ir::{Function, Inst, InstBuilder, JumpTableData, Opcode};
use cretonne_codegen::settings;
use cretonne_codegen::verify_function;
use cranelift_codegen::cursor::{Cursor, FuncCursor};
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::ir::instructions::BranchInfo;
use cranelift_codegen::ir::types::*;
use cranelift_codegen::ir::{Function, Inst, InstBuilder, JumpTableData, Opcode};
use cranelift_codegen::settings;
use cranelift_codegen::verify_function;
use ssa::SSABuilder;
use Variable;

View File

@@ -5,7 +5,7 @@
//! their own index types to use them directly. Frontends which don't
//! can use the `Variable` defined here.
use cretonne_codegen::entity::EntityRef;
use cranelift_codegen::entity::EntityRef;
use std::u32;
///! An opaque reference to a variable.

Some files were not shown because too many files have changed in this diff Show More