//! Generated from token-registry.toml — DO NOT EDIT.
//!
//! Regenerate with: cargo run -p xtask -- generate

/// Maps a token type name to its required target features.
///
/// Generated from token-registry.toml. One complete feature list per token.
pub(crate) fn token_to_features(token_name: &str) -> Option<&'static [&'static str]> {
    match token_name {
        "X64V1Token" | "Sse2Token" => Some(&["sse", "sse2"]),
        "X64V2Token" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
        ]),
        "X64CryptoToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "pclmulqdq",
            "aes",
        ]),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
        ]),
        "X64V3CryptoToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "vpclmulqdq",
            "vaes",
        ]),
        "X64V4Token" | "Avx512Token" | "Server64" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
        ]),
        "X64V4xToken" | "Avx512ModernToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
            "avx512vpopcntdq",
            "avx512ifma",
            "avx512vbmi",
            "avx512vbmi2",
            "avx512bitalg",
            "avx512vnni",
            "vpclmulqdq",
            "gfni",
            "vaes",
        ]),
        "Avx512Fp16Token" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
            "avx512fp16",
        ]),
        "NeonToken" | "Arm64" => Some(&["neon"]),
        "NeonAesToken" => Some(&["neon", "aes"]),
        "NeonSha3Token" => Some(&["neon", "sha3"]),
        "NeonCrcToken" => Some(&["neon", "crc"]),
        "Arm64V2Token" => Some(&["neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2"]),
        "Arm64V3Token" => Some(&[
            "neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2", "fhm", "fcma", "sha3", "i8mm",
            "bf16",
        ]),
        "Wasm128Token" => Some(&["simd128"]),
        "Wasm128RelaxedToken" => Some(&["simd128", "relaxed-simd"]),
        _ => None,
    }
}

/// Maps a trait bound name to its required target features.
///
/// Generated from token-registry.toml. Includes token type names
/// so `impl TokenType` patterns work in the macro.
pub(crate) fn trait_to_features(trait_name: &str) -> Option<&'static [&'static str]> {
    match trait_name {
        "Has128BitSimd" => Some(&["sse", "sse2"]),
        "Has256BitSimd" => Some(&["sse", "sse2", "avx"]),
        "Has512BitSimd" => Some(&["sse", "sse2", "avx", "avx2", "avx512f"]),
        "HasX64V2" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
        ]),
        "HasX64V4" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
        ]),
        "HasNeon" => Some(&["neon"]),
        "HasNeonAes" => Some(&["neon", "aes"]),
        "HasNeonSha3" => Some(&["neon", "sha3"]),
        "HasArm64V2" => Some(&["neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2"]),
        "HasArm64V3" => Some(&[
            "neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2", "fhm", "fcma", "sha3", "i8mm",
            "bf16",
        ]),

        // Token types used as bounds — full feature sets
        "X64V1Token" | "Sse2Token" => Some(&["sse", "sse2"]),
        "X64V2Token" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
        ]),
        "X64CryptoToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "pclmulqdq",
            "aes",
        ]),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
        ]),
        "X64V3CryptoToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "vpclmulqdq",
            "vaes",
        ]),
        "X64V4Token" | "Avx512Token" | "Server64" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
        ]),
        "X64V4xToken" | "Avx512ModernToken" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
            "avx512vpopcntdq",
            "avx512ifma",
            "avx512vbmi",
            "avx512vbmi2",
            "avx512bitalg",
            "avx512vnni",
            "vpclmulqdq",
            "gfni",
            "vaes",
        ]),
        "Avx512Fp16Token" => Some(&[
            "sse",
            "sse2",
            "sse3",
            "ssse3",
            "sse4.1",
            "sse4.2",
            "popcnt",
            "cmpxchg16b",
            "avx",
            "avx2",
            "fma",
            "bmi1",
            "bmi2",
            "f16c",
            "lzcnt",
            "movbe",
            "pclmulqdq",
            "aes",
            "avx512f",
            "avx512bw",
            "avx512cd",
            "avx512dq",
            "avx512vl",
            "avx512fp16",
        ]),
        "NeonToken" | "Arm64" => Some(&["neon"]),
        "NeonAesToken" => Some(&["neon", "aes"]),
        "NeonSha3Token" => Some(&["neon", "sha3"]),
        "NeonCrcToken" => Some(&["neon", "crc"]),
        "Arm64V2Token" => Some(&["neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2"]),
        "Arm64V3Token" => Some(&[
            "neon", "crc", "rdm", "dotprod", "fp16", "aes", "sha2", "fhm", "fcma", "sha3", "i8mm",
            "bf16",
        ]),
        "Wasm128Token" => Some(&["simd128"]),
        "Wasm128RelaxedToken" => Some(&["simd128", "relaxed-simd"]),

        _ => None,
    }
}

/// Maps a token type name to its target architecture.
///
/// Returns the `target_arch` value (e.g., "x86_64", "aarch64", "wasm32").
pub(crate) fn token_to_arch(token_name: &str) -> Option<&'static str> {
    match token_name {
        "X64V1Token" | "Sse2Token" => Some("x86_64"),
        "X64V2Token" => Some("x86_64"),
        "X64CryptoToken" => Some("x86_64"),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some("x86_64"),
        "X64V3CryptoToken" => Some("x86_64"),
        "X64V4Token" | "Avx512Token" | "Server64" => Some("x86_64"),
        "X64V4xToken" | "Avx512ModernToken" => Some("x86_64"),
        "Avx512Fp16Token" => Some("x86_64"),
        "NeonToken" | "Arm64" => Some("aarch64"),
        "NeonAesToken" => Some("aarch64"),
        "NeonSha3Token" => Some("aarch64"),
        "NeonCrcToken" => Some("aarch64"),
        "Arm64V2Token" => Some("aarch64"),
        "Arm64V3Token" => Some("aarch64"),
        "Wasm128Token" => Some("wasm32"),
        "Wasm128RelaxedToken" => Some("wasm32"),
        _ => None,
    }
}

/// Maps a token type name to its magetypes width namespace.
///
/// Returns the namespace name (e.g., "v3", "v4", "neon", "wasm128", "scalar").
/// Used by `import_magetypes` to inject `use magetypes::simd::{ns}::*;`.
pub(crate) fn token_to_magetypes_namespace(token_name: &str) -> Option<&'static str> {
    match token_name {
        "X64V1Token" | "Sse2Token" => Some("v3"),
        "X64V2Token" => Some("v3"),
        "X64CryptoToken" => Some("v3"),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some("v3"),
        "X64V3CryptoToken" => Some("v3"),
        "X64V4Token" | "Avx512Token" | "Server64" => Some("v4"),
        "X64V4xToken" | "Avx512ModernToken" => Some("v4x"),
        "Avx512Fp16Token" => Some("v4"),
        "NeonToken" | "Arm64" => Some("neon"),
        "NeonAesToken" => Some("neon"),
        "NeonSha3Token" => Some("neon"),
        "NeonCrcToken" => Some("neon"),
        "Arm64V2Token" => Some("neon"),
        "Arm64V3Token" => Some("neon"),
        "Wasm128Token" => Some("wasm128"),
        "Wasm128RelaxedToken" => Some("wasm128"),
        _ => None,
    }
}

/// Maps a trait bound name to its magetypes width namespace.
///
/// Returns the namespace name (e.g., "v3", "v4", "neon").
/// Used by `import_magetypes` when a trait bound is used instead of a concrete token.
pub(crate) fn trait_to_magetypes_namespace(trait_name: &str) -> Option<&'static str> {
    match trait_name {
        "Has128BitSimd" => Some("v3"),
        "Has256BitSimd" => Some("v3"),
        "Has512BitSimd" => Some("v4"),
        "HasX64V2" => Some("v3"),
        "HasX64V4" => Some("v4"),
        "HasNeon" => Some("neon"),
        "HasNeonAes" => Some("neon"),
        "HasNeonSha3" => Some("neon"),
        "HasArm64V2" => Some("neon"),
        "HasArm64V3" => Some("neon"),

        // Token types used as bounds
        "X64V1Token" | "Sse2Token" => Some("v3"),
        "X64V2Token" => Some("v3"),
        "X64CryptoToken" => Some("v3"),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some("v3"),
        "X64V3CryptoToken" => Some("v3"),
        "X64V4Token" | "Avx512Token" | "Server64" => Some("v4"),
        "X64V4xToken" | "Avx512ModernToken" => Some("v4x"),
        "Avx512Fp16Token" => Some("v4"),
        "NeonToken" | "Arm64" => Some("neon"),
        "NeonAesToken" => Some("neon"),
        "NeonSha3Token" => Some("neon"),
        "NeonCrcToken" => Some("neon"),
        "Arm64V2Token" => Some("neon"),
        "Arm64V3Token" => Some("neon"),
        "Wasm128Token" => Some("wasm128"),
        "Wasm128RelaxedToken" => Some("wasm128"),

        _ => None,
    }
}

/// Maps a trait bound name to its target architecture.
///
/// Returns the architecture (e.g., "x86_64", "aarch64").
/// Used by `import_intrinsics` when a trait bound is used instead of a concrete token.
pub(crate) fn trait_to_arch(trait_name: &str) -> Option<&'static str> {
    match trait_name {
        "Has128BitSimd" => Some("x86_64"),
        "Has256BitSimd" => Some("x86_64"),
        "Has512BitSimd" => Some("x86_64"),
        "HasX64V2" => Some("x86_64"),
        "HasX64V4" => Some("x86_64"),
        "HasNeon" => Some("aarch64"),
        "HasNeonAes" => Some("aarch64"),
        "HasNeonSha3" => Some("aarch64"),
        "HasArm64V2" => Some("aarch64"),
        "HasArm64V3" => Some("aarch64"),

        // Token types used as bounds
        "X64V1Token" | "Sse2Token" => Some("x86"),
        "X64V2Token" => Some("x86"),
        "X64CryptoToken" => Some("x86"),
        "X64V3Token" | "Desktop64" | "Avx2FmaToken" => Some("x86"),
        "X64V3CryptoToken" => Some("x86"),
        "X64V4Token" | "Avx512Token" | "Server64" => Some("x86"),
        "X64V4xToken" | "Avx512ModernToken" => Some("x86"),
        "Avx512Fp16Token" => Some("x86"),
        "NeonToken" | "Arm64" => Some("aarch64"),
        "NeonAesToken" => Some("aarch64"),
        "NeonSha3Token" => Some("aarch64"),
        "NeonCrcToken" => Some("aarch64"),
        "Arm64V2Token" => Some("aarch64"),
        "Arm64V3Token" => Some("aarch64"),
        "Wasm128Token" => Some("wasm"),
        "Wasm128RelaxedToken" => Some("wasm"),

        _ => None,
    }
}

/// All concrete token names that exist in the runtime crate.
#[cfg(test)]
pub(crate) const ALL_CONCRETE_TOKENS: &[&str] = &[
    "X64V1Token",
    "Sse2Token",
    "X64V2Token",
    "X64CryptoToken",
    "X64V3Token",
    "Desktop64",
    "Avx2FmaToken",
    "X64V3CryptoToken",
    "X64V4Token",
    "Avx512Token",
    "Server64",
    "X64V4xToken",
    "Avx512ModernToken",
    "Avx512Fp16Token",
    "NeonToken",
    "Arm64",
    "NeonAesToken",
    "NeonSha3Token",
    "NeonCrcToken",
    "Arm64V2Token",
    "Arm64V3Token",
    "Wasm128Token",
    "Wasm128RelaxedToken",
];

/// All trait names that exist in the runtime crate.
#[cfg(test)]
pub(crate) const ALL_TRAIT_NAMES: &[&str] = &[
    "Has128BitSimd",
    "Has256BitSimd",
    "Has512BitSimd",
    "HasX64V2",
    "HasX64V4",
    "HasNeon",
    "HasNeonAes",
    "HasNeonSha3",
    "HasArm64V2",
    "HasArm64V3",
];
