Sha256: d9414af46a4f8bf598786948d33f53bd87b0cf0c01185a2774302c2fd2bb5376

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

//! Dynamic IR types

use crate::ir::entities::DynamicType;
use crate::ir::types::*;
use crate::ir::GlobalValue;
use crate::ir::PrimaryMap;

#[cfg(feature = "enable-serde")]
use serde_derive::{Deserialize, Serialize};

/// A dynamic type object which has a base vector type and a scaling factor.
#[derive(Clone, PartialEq, Hash)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct DynamicTypeData {
    /// Base vector type, this is the minimum size of the type.
    pub base_vector_ty: Type,
    /// The dynamic scaling factor of the base vector type.
    pub dynamic_scale: GlobalValue,
}

impl DynamicTypeData {
    /// Create a new dynamic type.
    pub fn new(base_vector_ty: Type, dynamic_scale: GlobalValue) -> Self {
        assert!(base_vector_ty.is_vector());
        Self {
            base_vector_ty,
            dynamic_scale,
        }
    }

    /// Convert 'base_vector_ty' into a concrete dynamic vector type.
    pub fn concrete(&self) -> Option<Type> {
        self.base_vector_ty.vector_to_dynamic()
    }
}

/// All allocated dynamic types.
pub type DynamicTypes = PrimaryMap<DynamicType, DynamicTypeData>;

/// Convert a dynamic-vector type to a fixed-vector type.
pub fn dynamic_to_fixed(ty: Type) -> Type {
    match ty {
        I8X8XN => I8X8,
        I8X16XN => I8X16,
        I16X4XN => I16X4,
        I16X8XN => I16X8,
        I32X2XN => I32X2,
        I32X4XN => I32X4,
        I64X2XN => I64X2,
        F32X4XN => F32X4,
        F64X2XN => F64X2,
        _ => unreachable!("unhandled type: {}", ty),
    }
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/cranelift-codegen-0.116.0/src/ir/dynamic_type.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cranelift-codegen-0.115.0/src/ir/dynamic_type.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cranelift-codegen-0.114.0/src/ir/dynamic_type.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cranelift-codegen-0.113.0/src/ir/dynamic_type.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cranelift-codegen-0.112.2/src/ir/dynamic_type.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cranelift-codegen-0.112.1/src/ir/dynamic_type.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cranelift-codegen-0.112.0/src/ir/dynamic_type.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cranelift-codegen-0.111.0/src/ir/dynamic_type.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cranelift-codegen-0.110.2/src/ir/dynamic_type.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cranelift-codegen-0.109.0/src/ir/dynamic_type.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cranelift-codegen-0.108.1/src/ir/dynamic_type.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cranelift-codegen-0.107.2/src/ir/dynamic_type.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cranelift-codegen-0.107.2/src/ir/dynamic_type.rs