Merge pull request #1364 from TomHarte/SomeWarnings

Resolve various warnings.
This commit is contained in:
Thomas Harte 2024-04-23 19:40:43 -07:00 committed by GitHub
commit 0bff2089c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 14 deletions

View File

@ -38,6 +38,7 @@ constexpr size_t memory_size(Personality p) {
case TI::TMS::V9938: return 128 * 1024; case TI::TMS::V9938: return 128 * 1024;
case TI::TMS::V9958: return 192 * 1024; case TI::TMS::V9958: return 192 * 1024;
} }
return 0;
} }
constexpr size_t memory_mask(Personality p) { constexpr size_t memory_mask(Personality p) {

View File

@ -337,9 +337,11 @@ struct Executor {
uint32_t value = 0; uint32_t value = 0;
if constexpr (flags.transfer_byte()) { if constexpr (flags.transfer_byte()) {
uint8_t target; uint8_t target = 0; // Value should never be used; this avoids a spurious GCC warning.
did_read = bus.template read<uint8_t>(address, target, registers_.mode(), trans); did_read = bus.template read<uint8_t>(address, target, registers_.mode(), trans);
value = target; if(did_read) {
value = target;
}
} else { } else {
did_read = bus.template read<uint32_t>(address, value, registers_.mode(), trans); did_read = bus.template read<uint32_t>(address, value, registers_.mode(), trans);

View File

@ -185,6 +185,7 @@ struct Registers {
// Unspecified; a guess. // Unspecified; a guess.
case Exception::Reset: return 0; case Exception::Reset: return 0;
} }
return 4;
} }
/// Updates the program counter, interupt flags and link register if applicable to begin @c exception. /// Updates the program counter, interupt flags and link register if applicable to begin @c exception.
@ -270,10 +271,11 @@ struct Registers {
case Condition::GT: return !le(); case Condition::GT: return !le();
case Condition::LE: return le(); case Condition::LE: return le();
default:
case Condition::AL: return true; case Condition::AL: return true;
case Condition::NV: return false; case Condition::NV: return false;
} }
return false;
} }
/// Sets current execution mode. /// Sets current execution mode.
@ -345,23 +347,19 @@ struct Registers {
/// this will the the user-mode register. Otherwise it'll be that for the current mode. These references /// this will the the user-mode register. Otherwise it'll be that for the current mode. These references
/// are guaranteed to remain valid only until the next mode change. /// are guaranteed to remain valid only until the next mode change.
uint32_t &reg(bool force_user_mode, uint32_t offset) { uint32_t &reg(bool force_user_mode, uint32_t offset) {
if(!force_user_mode) {
return active_[offset];
}
switch(mode_) { switch(mode_) {
default: default:
case Mode::User: return active_[offset]; case Mode::User: return active_[offset];
case Mode::Supervisor: case Mode::Supervisor:
case Mode::IRQ: case Mode::IRQ:
if(offset == 13 || offset == 14) { if(force_user_mode && (offset == 13 || offset == 14)) {
return user_registers_[offset - 8]; return user_registers_[offset - 8];
} }
return active_[offset]; return active_[offset];
case Mode::FIQ: case Mode::FIQ:
if(offset >= 8 && offset < 15) { if(force_user_mode && (offset >= 8 && offset < 15)) {
return user_registers_[offset - 8]; return user_registers_[offset - 8];
} }
return active_[offset]; return active_[offset];

View File

@ -548,10 +548,10 @@ class ConcreteMachine:
} }
uint32_t advance_pipeline(uint32_t pc) { uint32_t advance_pipeline(uint32_t pc) {
uint32_t instruction; uint32_t instruction = 0; // Value should never be used; this avoids a spurious GCC warning.
const bool did_read = executor_.bus.read(pc, instruction, executor_.registers().mode(), false); const bool did_read = executor_.bus.read(pc, instruction, executor_.registers().mode(), false);
return pipeline_.exchange( return pipeline_.exchange(
instruction, did_read ? instruction : Pipeline::SWI,
did_read ? Pipeline::SWISubversion::None : Pipeline::SWISubversion::DataAbort); did_read ? Pipeline::SWISubversion::None : Pipeline::SWISubversion::DataAbort);
} }
@ -563,6 +563,8 @@ class ConcreteMachine:
FIQ, FIQ,
}; };
static constexpr uint32_t SWI = 0xef'000000;
uint32_t exchange(uint32_t next, SWISubversion subversion) { uint32_t exchange(uint32_t next, SWISubversion subversion) {
const uint32_t result = upcoming_[active_].opcode; const uint32_t result = upcoming_[active_].opcode;
latched_subversion_ = upcoming_[active_].subversion; latched_subversion_ = upcoming_[active_].subversion;
@ -586,7 +588,7 @@ class ConcreteMachine:
// In practice I got into a bit of a race condition between interrupt scheduling and // In practice I got into a bit of a race condition between interrupt scheduling and
// flags changes, so have backed off for now. // flags changes, so have backed off for now.
void reschedule(SWISubversion subversion) { void reschedule(SWISubversion subversion) {
upcoming_[active_].opcode = 0xef'000000; upcoming_[active_].opcode = SWI;
upcoming_[active_].subversion = subversion; upcoming_[active_].subversion = subversion;
} }

View File

@ -77,8 +77,8 @@ class MemoryMap {
} }
const auto physical = physical_address(region, address); const auto physical = physical_address(region, address);
assert(physical >= 0 && physical <= 0xff'ffff); assert(physical <= 0xff'ffff);
return shadow_pages_[(physical >> 10) & 127] & shadow_banks_[physical >> 17]; return shadow_pages_[(physical >> 10) & 127] && shadow_banks_[physical >> 17];
} }
void write(const Region &region, uint32_t address, uint8_t value) { void write(const Region &region, uint32_t address, uint8_t value) {
if(!region.write) { if(!region.write) {

View File

@ -1869,6 +1869,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
SetupDataAccess(0, Operation::SelectWord); SetupDataAccess(0, Operation::SelectWord);
MoveToStateSpecific(StoreOperand_l); MoveToStateSpecific(StoreOperand_l);
default: // Convince GCC that nothing here is amiss.
case InstructionSet::M68k::DataSize::Word: case InstructionSet::M68k::DataSize::Word:
SetupDataAccess(0, Operation::SelectWord); SetupDataAccess(0, Operation::SelectWord);
MoveToStateSpecific(StoreOperand_bw); MoveToStateSpecific(StoreOperand_bw);