-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename 'ARM' interpreter 'InterpreterCPU'
- Loading branch information
Showing
13 changed files
with
162 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
|
||
enum class MultiplyOpcode { | ||
MUL = 0b000, | ||
MLA = 0b001, | ||
UMULL = 0b100, | ||
UMLAL = 0b101, | ||
SMULL = 0b110, | ||
SMLAL = 0b111 | ||
}; | ||
|
||
enum class SignedMultiplyOpcode { | ||
SMLAxy = 0b1000, | ||
SM__Wy = 0b1001, | ||
SMLALxy = 0b1010, | ||
SMULxy = 0b1011 | ||
}; | ||
|
||
template <u32 instruction> | ||
static constexpr auto GenerateHandlerARM() -> Handler32 { | ||
const bool pre = instruction & (1 << 24); | ||
const bool add = instruction & (1 << 23); | ||
const bool wb = instruction & (1 << 21); | ||
const bool load = instruction & (1 << 20); | ||
|
||
switch(GetARMInstructionType(instruction)) { | ||
case ARMInstrType::HalfwordSignedTransfer: { | ||
const bool immediate = instruction & (1 << 22); | ||
const auto opcode = (instruction >> 5) & 3; | ||
|
||
return &InterpreterCPU::ARM_HalfDoubleAndSignedTransfer<pre, add, immediate, wb, load, opcode>; | ||
} | ||
case ARMInstrType::Multiply: { | ||
const bool set_flags = instruction & (1 << 20); | ||
|
||
switch(static_cast<MultiplyOpcode>((instruction >> 21) & 0xF)) { | ||
case MultiplyOpcode::MUL: return &InterpreterCPU::ARM_Multiply<false, set_flags>; | ||
case MultiplyOpcode::MLA: return &InterpreterCPU::ARM_Multiply<true, set_flags>; | ||
case MultiplyOpcode::UMULL: return &InterpreterCPU::ARM_MultiplyLong<false, false, set_flags>; | ||
case MultiplyOpcode::UMLAL: return &InterpreterCPU::ARM_MultiplyLong<false, true, set_flags>; | ||
case MultiplyOpcode::SMULL: return &InterpreterCPU::ARM_MultiplyLong<true, false, set_flags>; | ||
case MultiplyOpcode::SMLAL: return &InterpreterCPU::ARM_MultiplyLong<true, true, set_flags>; | ||
} | ||
|
||
break; | ||
} | ||
case ARMInstrType::SingleDataSwap: { | ||
const bool byte = instruction & (1 << 22); | ||
|
||
return &InterpreterCPU::ARM_SingleDataSwap<byte>; | ||
} | ||
case ARMInstrType::StatusTransfer: { | ||
const bool immediate = instruction & (1 << 25); | ||
const bool use_spsr = instruction & (1 << 22); | ||
const bool to_status = instruction & (1 << 21); | ||
|
||
return &InterpreterCPU::ARM_StatusTransfer<immediate, use_spsr, to_status>; | ||
} | ||
case ARMInstrType::BranchAndExchange: return &InterpreterCPU::ARM_BranchAndExchangeMaybeLink<false>; | ||
case ARMInstrType::CountLeadingZeros: return &InterpreterCPU::ARM_CountLeadingZeros; | ||
case ARMInstrType::BranchLinkExchange: return &InterpreterCPU::ARM_BranchAndExchangeMaybeLink<true>; | ||
case ARMInstrType::SaturatingAddSubtract: { | ||
const int opcode = (instruction >> 20) & 0xF; | ||
|
||
return &InterpreterCPU::ARM_SaturatingAddSubtract<opcode>; | ||
} | ||
case ARMInstrType::SignedHalfwordMultiply: { | ||
const bool x = instruction & (1 << 5); | ||
const bool y = instruction & (1 << 6); | ||
|
||
switch(static_cast<SignedMultiplyOpcode>((instruction >> 21) & 0xF)) { | ||
case SignedMultiplyOpcode::SMLAxy: return &InterpreterCPU::ARM_SignedHalfwordMultiply<true, x, y>; | ||
case SignedMultiplyOpcode::SM__Wy: return &InterpreterCPU::ARM_SignedWordHalfwordMultiply<!x, y>; | ||
case SignedMultiplyOpcode::SMLALxy: return &InterpreterCPU::ARM_SignedHalfwordMultiplyLongAccumulate<x, y>; | ||
case SignedMultiplyOpcode::SMULxy: return &InterpreterCPU::ARM_SignedHalfwordMultiply<false, x, y>; | ||
} | ||
|
||
break; | ||
} | ||
case ARMInstrType::DataProcessing: { | ||
const bool immediate = instruction & (1 << 25); | ||
const bool set_flags = instruction & (1 << 20); | ||
const auto opcode = static_cast<InterpreterCPU::ARMDataOp>((instruction >> 21) & 0xF); | ||
const auto field4 = (instruction >> 4) & 0xF; | ||
|
||
return &InterpreterCPU::ARM_DataProcessing<immediate, opcode, set_flags, field4>; | ||
} | ||
case ARMInstrType::SingleDataTransfer: { | ||
const bool immediate = ~instruction & (1 << 25); | ||
const bool byte = instruction & (1 << 22); | ||
|
||
return &InterpreterCPU::ARM_SingleDataTransfer<immediate, pre, add, byte, wb, load>; | ||
} | ||
case ARMInstrType::BlockDataTransfer: { | ||
const bool user_mode = instruction & (1 << 22); | ||
|
||
return &InterpreterCPU::ARM_BlockDataTransfer<pre, add, user_mode, wb, load>; | ||
} | ||
case ARMInstrType::BranchAndLink: return &InterpreterCPU::ARM_BranchAndLink<(instruction >> 24) & 1>; | ||
case ARMInstrType::CoprocessorRegisterXfer: return &InterpreterCPU::ARM_CoprocessorRegisterTransfer; | ||
case ARMInstrType::SoftwareInterrupt: return &InterpreterCPU::ARM_SWI; | ||
case ARMInstrType::BranchLinkExchangeImm: return &InterpreterCPU::ARM_BranchLinkExchangeImm; | ||
default: break; | ||
} | ||
|
||
return &InterpreterCPU::ARM_Undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.