|
|
@ -193,8 +193,7 @@ u32 RegAlloc::RealizeReadImpl(const IR::Value& value) { |
|
|
|
|
|
|
|
|
switch (current_location->kind) { |
|
|
switch (current_location->kind) { |
|
|
case HostLoc::Kind::Gpr: |
|
|
case HostLoc::Kind::Gpr: |
|
|
ASSERT(false && "Logic error"); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
UNREACHABLE(); //logic error
|
|
|
case HostLoc::Kind::Fpr: |
|
|
case HostLoc::Kind::Fpr: |
|
|
as.FMV_X_D(biscuit::GPR(new_location_index), biscuit::FPR{current_location->index}); |
|
|
as.FMV_X_D(biscuit::GPR(new_location_index), biscuit::FPR{current_location->index}); |
|
|
// ASSERT size fits
|
|
|
// ASSERT size fits
|
|
|
@ -216,8 +215,7 @@ u32 RegAlloc::RealizeReadImpl(const IR::Value& value) { |
|
|
as.FMV_D_X(biscuit::FPR{new_location_index}, biscuit::GPR(current_location->index)); |
|
|
as.FMV_D_X(biscuit::FPR{new_location_index}, biscuit::GPR(current_location->index)); |
|
|
break; |
|
|
break; |
|
|
case HostLoc::Kind::Fpr: |
|
|
case HostLoc::Kind::Fpr: |
|
|
ASSERT(false && "Logic error"); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
UNREACHABLE(); //logic error
|
|
|
case HostLoc::Kind::Spill: |
|
|
case HostLoc::Kind::Spill: |
|
|
as.FLD(biscuit::FPR{new_location_index}, spill_offset + current_location->index * spill_slot_size, biscuit::sp); |
|
|
as.FLD(biscuit::FPR{new_location_index}, spill_offset + current_location->index * spill_slot_size, biscuit::sp); |
|
|
break; |
|
|
break; |
|
|
@ -307,14 +305,11 @@ std::optional<HostLoc> RegAlloc::ValueLocation(const IR::Inst* value) const { |
|
|
const auto contains_value = [value](const HostLocInfo& info) { |
|
|
const auto contains_value = [value](const HostLocInfo& info) { |
|
|
return info.Contains(value); |
|
|
return info.Contains(value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (const auto iter = std::find_if(gprs.begin(), gprs.end(), contains_value); iter != gprs.end()) { |
|
|
if (const auto iter = std::find_if(gprs.begin(), gprs.end(), contains_value); iter != gprs.end()) { |
|
|
return HostLoc{HostLoc::Kind::Gpr, static_cast<u32>(iter - gprs.begin())}; |
|
|
return HostLoc{HostLoc::Kind::Gpr, static_cast<u32>(iter - gprs.begin())}; |
|
|
} |
|
|
|
|
|
if (const auto iter = std::find_if(fprs.begin(), fprs.end(), contains_value); iter != fprs.end()) { |
|
|
|
|
|
|
|
|
} else if (const auto iter = std::find_if(fprs.begin(), fprs.end(), contains_value); iter != fprs.end()) { |
|
|
return HostLoc{HostLoc::Kind::Fpr, static_cast<u32>(iter - fprs.begin())}; |
|
|
return HostLoc{HostLoc::Kind::Fpr, static_cast<u32>(iter - fprs.begin())}; |
|
|
} |
|
|
|
|
|
if (const auto iter = std::find_if(spills.begin(), spills.end(), contains_value); iter != spills.end()) { |
|
|
|
|
|
|
|
|
} else if (const auto iter = std::find_if(spills.begin(), spills.end(), contains_value); iter != spills.end()) { |
|
|
return HostLoc{HostLoc::Kind::Spill, static_cast<u32>(iter - spills.begin())}; |
|
|
return HostLoc{HostLoc::Kind::Spill, static_cast<u32>(iter - spills.begin())}; |
|
|
} |
|
|
} |
|
|
return std::nullopt; |
|
|
return std::nullopt; |
|
|
@ -323,30 +318,27 @@ std::optional<HostLoc> RegAlloc::ValueLocation(const IR::Inst* value) const { |
|
|
HostLocInfo& RegAlloc::ValueInfo(HostLoc host_loc) { |
|
|
HostLocInfo& RegAlloc::ValueInfo(HostLoc host_loc) { |
|
|
switch (host_loc.kind) { |
|
|
switch (host_loc.kind) { |
|
|
case HostLoc::Kind::Gpr: |
|
|
case HostLoc::Kind::Gpr: |
|
|
return gprs[static_cast<size_t>(host_loc.index)]; |
|
|
|
|
|
|
|
|
return gprs[size_t(host_loc.index)]; |
|
|
case HostLoc::Kind::Fpr: |
|
|
case HostLoc::Kind::Fpr: |
|
|
return fprs[static_cast<size_t>(host_loc.index)]; |
|
|
|
|
|
|
|
|
return fprs[size_t(host_loc.index)]; |
|
|
case HostLoc::Kind::Spill: |
|
|
case HostLoc::Kind::Spill: |
|
|
return spills[static_cast<size_t>(host_loc.index)]; |
|
|
|
|
|
|
|
|
return spills[size_t(host_loc.index)]; |
|
|
} |
|
|
} |
|
|
ASSERT(false && "RegAlloc::ValueInfo: Invalid HostLoc::Kind"); |
|
|
|
|
|
|
|
|
UNREACHABLE(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
HostLocInfo& RegAlloc::ValueInfo(const IR::Inst* value) { |
|
|
HostLocInfo& RegAlloc::ValueInfo(const IR::Inst* value) { |
|
|
const auto contains_value = [value](const HostLocInfo& info) { |
|
|
const auto contains_value = [value](const HostLocInfo& info) { |
|
|
return info.Contains(value); |
|
|
return info.Contains(value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (const auto iter = std::find_if(gprs.begin(), gprs.end(), contains_value); iter != gprs.end()) { |
|
|
if (const auto iter = std::find_if(gprs.begin(), gprs.end(), contains_value); iter != gprs.end()) { |
|
|
return *iter; |
|
|
return *iter; |
|
|
} |
|
|
|
|
|
if (const auto iter = std::find_if(fprs.begin(), fprs.end(), contains_value); iter != gprs.end()) { |
|
|
|
|
|
|
|
|
} else if (const auto iter = std::find_if(fprs.begin(), fprs.end(), contains_value); iter != gprs.end()) { |
|
|
return *iter; |
|
|
return *iter; |
|
|
} |
|
|
|
|
|
if (const auto iter = std::find_if(spills.begin(), spills.end(), contains_value); iter != gprs.end()) { |
|
|
|
|
|
|
|
|
} else if (const auto iter = std::find_if(spills.begin(), spills.end(), contains_value); iter != gprs.end()) { |
|
|
return *iter; |
|
|
return *iter; |
|
|
} |
|
|
} |
|
|
ASSERT(false && "RegAlloc::ValueInfo: Value not found"); |
|
|
|
|
|
|
|
|
UNREACHABLE(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} // namespace Dynarmic::Backend::RV64
|
|
|
} // namespace Dynarmic::Backend::RV64
|