FIRST INSTRUCTION WORKING
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
static INSTRUCTIONS: Lazy<[Option<OpcodeHandler>; 32]> = Lazy::new(|| {
|
||||
let mut instructions = std::array::from_fn(|_i| None);
|
||||
mod gen_tools;
|
||||
mod opcodes;
|
||||
mod rvi;
|
||||
|
||||
static INSTRUCTIONS: Lazy<[OpcodeHandler; 32]> = Lazy::new(|| {
|
||||
let mut instructions = std::array::from_fn(|_i| OpcodeHandler {
|
||||
handler: None,
|
||||
splitter: None,
|
||||
});
|
||||
|
||||
rvi::add_instrs(&mut instructions);
|
||||
|
||||
instructions
|
||||
});
|
||||
@@ -26,10 +35,7 @@ struct OpcodeHandler {
|
||||
|
||||
pub fn find_runner(instruction: Instruction) -> Option<Runner> {
|
||||
let opcode_handler = &INSTRUCTIONS[instruction.opcode_noncompressed() as usize];
|
||||
match opcode_handler {
|
||||
Some(h) => h.find_runner(instruction),
|
||||
None => None,
|
||||
}
|
||||
opcode_handler.find_runner(instruction)
|
||||
}
|
||||
|
||||
impl OpcodeHandler {
|
||||
@@ -43,16 +49,16 @@ impl OpcodeHandler {
|
||||
}
|
||||
|
||||
enum Splitter {
|
||||
Funct3Splitter(Box<[Option<OpcodeHandler>; 8]>),
|
||||
Funct3Splitter(Box<[OpcodeHandler; 8]>),
|
||||
GeneralSplitter(Box<[GeneralSplitterEntry]>),
|
||||
}
|
||||
|
||||
impl Splitter {
|
||||
fn find_runner(&self, instruction: Instruction) -> Option<Runner> {
|
||||
match self {
|
||||
Splitter::Funct3Splitter(f3s) => f3s[instruction.funct3() as usize]
|
||||
.as_ref()
|
||||
.and_then(|h| h.find_runner(instruction)),
|
||||
Splitter::Funct3Splitter(f3s) => {
|
||||
f3s[instruction.funct3() as usize].find_runner(instruction)
|
||||
}
|
||||
Splitter::GeneralSplitter(entries) => {
|
||||
for entry in entries {
|
||||
if instruction.0 & entry.mask == entry.value {
|
||||
|
||||
Reference in New Issue
Block a user