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§

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

Structs§

Enums§

Constants§

  • 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§

  • 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 Aliases§

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