cranelift_codegen

Module isa

Source
Expand description

Instruction Set Architectures.

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 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. 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.
  • Values for ISA-specific settings.

The isa::lookup() function is the main entry point which returns an isa::Builder appropriate for the requested ISA:

use cranelift_codegen::isa;
use cranelift_codegen::settings::{self, Configurable};
use std::str::FromStr;
use target_lexicon::Triple;

let shared_builder = settings::builder();
let shared_flags = settings::Flags::new(shared_builder);

match isa::lookup(triple!("x86_64")) {
    Err(_) => {
        // The x86_64 target ISA is not available.
    }
    Ok(mut isa_builder) => {
        isa_builder.set("use_popcnt", "on");
        let isa = isa_builder.finish(shared_flags);
    }
}

The configured target ISA trait object is a Box<TargetIsa> which can be used for multiple concurrent function compilations.

Modules§

aarch64arm64
ARM 64-bit Instruction Set Architecture.
riscv64riscv64
risc-v 64-bit Instruction Set Architecture.
unwind
Represents information relating to function unwinding.
x64x86
X86_64-bit Instruction Set Architecture.

Structs§

FunctionAlignment
Function alignment specifications as required by an ISA, returned by TargetIsa::function_alignment.
IsaBuilder
Builder for a TargetIsa. Modify the ISA-specific settings before creating the TargetIsa trait object with finish.
TargetFrontendConfig
This struct provides information that a frontend may need to know about a target to produce Cranelift IR for the target.

Enums§

CallConv
Calling convention identifiers.
LookupError
Describes reason for target lookup failure

Constants§

ALL_ARCHITECTURES
The string names of all the supported, but possibly not enabled, architectures. The elements of this slice are suitable to be passed to the lookup_by_name function to obtain the default configuration for that architecture.

Traits§

TargetIsa
Methods that are specialized to a target ISA.

Functions§

lookup
Look for an ISA for the given triple. Return a builder that can create a corresponding TargetIsa.
lookup_by_name
Look for a supported ISA with the given name. Return a builder that can create a corresponding TargetIsa.

Type Aliases§

Builder
Type alias of IsaBuilder used for building Cranelift’s ISAs.
Legalize
After determining that an instruction doesn’t have an encoding, how should we proceed to legalize it?
OwnedTargetIsa
The type of a polymorphic TargetISA object which is ’static.