Module cranelift_codegen::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

Represents information relating to function unwinding.
X86_64-bit Instruction Set Architecture.

Structs

Builder for a TargetIsa. Modify the ISA-specific settings before creating the TargetIsa trait object with finish.
This struct provides information that a frontend may need to know about a target to produce Cranelift IR for the target.

Enums

Calling convention identifiers.
Describes reason for target lookup failure

Traits

Methods that are specialized to a target ISA.

Functions

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

Type Definitions

After determining that an instruction doesn’t have an encoding, how should we proceed to legalize it?