Rustfmt and update docs

This commit is contained in:
bjorn3
2020-10-01 09:53:23 +02:00
parent 9ccf837092
commit b061694491
7 changed files with 15 additions and 15 deletions

View File

@@ -6,14 +6,13 @@ This crate is structured as an optional layer on top of cranelift-codegen.
It provides additional functionality, such as linking, however users that It provides additional functionality, such as linking, however users that
require greater flexibility don't need to use it. require greater flexibility don't need to use it.
A `Module` is a collection of functions and data objects that are linked A module is a collection of functions and data objects that are linked
together. `Backend` is a trait that defines an interface for backends together. The `Module` trait that defines a common interface for various kinds
that compile modules into various forms. Most users will use one of the of modules. Most users will use one of the following `Module` implementations:
following `Backend` implementations:
- `SimpleJITBackend`, provided by [cranelift-simplejit], which JITs - `SimpleJITModule`, provided by [cranelift-simplejit], which JITs
code to memory for direct execution. code to memory for direct execution.
- `ObjectBackend`, provided by [cranelift-object], which emits native - `ObjectModule`, provided by [cranelift-object], which emits native
object files. object files.
[cranelift-simplejit]: https://crates.io/crates/cranelift-simplejit [cranelift-simplejit]: https://crates.io/crates/cranelift-simplejit

View File

@@ -50,7 +50,8 @@ pub struct DataDescription {
pub data_relocs: Vec<(CodeOffset, ir::GlobalValue, Addend)>, pub data_relocs: Vec<(CodeOffset, ir::GlobalValue, Addend)>,
/// Object file section /// Object file section
pub custom_segment_section: Option<(String, String)>, pub custom_segment_section: Option<(String, String)>,
/// Alignment /// Alignment in bytes. `None` means that the default alignment of the respective module should
/// be used.
pub align: Option<u64>, pub align: Option<u64>,
} }

View File

@@ -142,7 +142,7 @@ impl FunctionDeclaration {
} }
} }
/// Error messages for all `Module` and `Backend` methods /// Error messages for all `Module` methods
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum ModuleError { pub enum ModuleError {
/// Indicates an identifier was used before it was declared /// Indicates an identifier was used before it was declared

View File

@@ -1,4 +1,4 @@
//! Defines `ObjectBackend`. //! Defines `ObjectModule`.
use anyhow::anyhow; use anyhow::anyhow;
use cranelift_codegen::binemit::{ use cranelift_codegen::binemit::{
@@ -23,7 +23,7 @@ use std::convert::TryInto;
use std::mem; use std::mem;
use target_lexicon::PointerWidth; use target_lexicon::PointerWidth;
/// A builder for `ObjectBackend`. /// A builder for `ObjectModule`.
pub struct ObjectBuilder { pub struct ObjectBuilder {
isa: Box<dyn TargetIsa>, isa: Box<dyn TargetIsa>,
binary_format: object::BinaryFormat, binary_format: object::BinaryFormat,
@@ -37,7 +37,7 @@ pub struct ObjectBuilder {
impl ObjectBuilder { impl ObjectBuilder {
/// Create a new `ObjectBuilder` using the given Cranelift target, that /// Create a new `ObjectBuilder` using the given Cranelift target, that
/// can be passed to [`Module::new`](cranelift_module::Module::new). /// can be passed to [`ObjectModule::new`].
/// ///
/// The `libcall_names` function provides a way to translate `cranelift_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 /// enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain

View File

@@ -27,7 +27,7 @@
mod backend; mod backend;
pub use crate::backend::{ObjectModule, ObjectBuilder, ObjectProduct}; pub use crate::backend::{ObjectBuilder, ObjectModule, ObjectProduct};
/// Version number of this crate. /// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");

View File

@@ -164,7 +164,7 @@ pub struct SimpleJITCompiledData {
relocs: Vec<RelocRecord>, relocs: Vec<RelocRecord>,
} }
/// A handle to allow freeing memory allocated by the `Backend`. /// A handle to allow freeing memory allocated by the `Module`.
struct SimpleJITMemoryHandle { struct SimpleJITMemoryHandle {
code: Memory, code: Memory,
readonly: Memory, readonly: Memory,
@@ -360,7 +360,7 @@ impl SimpleJITModule {
} }
} }
/// Create a new `SimpleJITBackend`. /// Create a new `SimpleJITModule`.
pub fn new(builder: SimpleJITBuilder) -> Self { pub fn new(builder: SimpleJITBuilder) -> Self {
let memory = SimpleJITMemoryHandle { let memory = SimpleJITMemoryHandle {
code: Memory::new(), code: Memory::new(),

View File

@@ -26,7 +26,7 @@
mod backend; mod backend;
mod memory; mod memory;
pub use crate::backend::{SimpleJITModule, SimpleJITBuilder, SimpleJITProduct}; pub use crate::backend::{SimpleJITBuilder, SimpleJITModule, SimpleJITProduct};
/// Version number of this crate. /// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");