// Copyright (c) 2025 taitep // SPDX-License-Identifier: MIT // // This file is part of TRVE (https://gitea.taitep.se/taitep/trve) // See LICENSE file in the project root for full license text. use std::hint::unreachable_unchecked; use crate::instructions::{OpcodeHandler, Splitter}; pub fn insert_funct3_splitter(splitter: &mut Option) -> &mut [OpcodeHandler; 8] { match splitter { Some(Splitter::Funct3Splitter(s)) => s.as_mut(), Some(_) => panic!("Unexpected splitter variant"), None => { *splitter = Some(Splitter::Funct3Splitter(Box::new(std::array::from_fn( |_i| OpcodeHandler { handler: None, splitter: None, }, )))); match splitter { Some(Splitter::Funct3Splitter(s)) => s.as_mut(), _ => unsafe { unreachable_unchecked() }, } } } }