bool-ifying xe::cpu
This commit is contained in:
@@ -86,9 +86,9 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
|
||||
|
||||
PPCTranslator::~PPCTranslator() = default;
|
||||
|
||||
int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
uint32_t debug_info_flags, uint32_t trace_flags,
|
||||
Function** out_function) {
|
||||
bool PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
uint32_t debug_info_flags, uint32_t trace_flags,
|
||||
Function** out_function) {
|
||||
SCOPE_profile_cpu_f("cpu");
|
||||
|
||||
// Reset() all caching when we leave.
|
||||
@@ -97,18 +97,6 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
xe::make_reset_scope(assembler_);
|
||||
xe::make_reset_scope(&string_buffer_);
|
||||
|
||||
// Scan the function to find its extents. We only need to do this if we
|
||||
// haven't already been provided with them from some other source.
|
||||
if (!symbol_info->has_end_address()) {
|
||||
// TODO(benvanik): find a way to remove the need for the scan. A fixup
|
||||
// scheme acting on branches could go back and modify calls to branches
|
||||
// if they are within the extents.
|
||||
int result = scanner_->FindExtents(symbol_info);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: we only want to do this when required, as it's expensive to build.
|
||||
if (FLAGS_always_disasm) {
|
||||
debug_info_flags |= DEBUG_INFO_ALL_DISASM;
|
||||
@@ -118,6 +106,11 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
debug_info.reset(new DebugInfo());
|
||||
}
|
||||
|
||||
// Scan the function to find its extents and gather debug data.
|
||||
if (!scanner_->Scan(symbol_info, debug_info.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stash source.
|
||||
if (debug_info_flags & DEBUG_INFO_SOURCE_DISASM) {
|
||||
DumpSource(symbol_info, &string_buffer_);
|
||||
@@ -134,9 +127,8 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
if (debug_info) {
|
||||
emit_flags |= PPCHIRBuilder::EMIT_DEBUG_COMMENTS;
|
||||
}
|
||||
int result = builder_->Emit(symbol_info, emit_flags);
|
||||
if (result) {
|
||||
return result;
|
||||
if (!builder_->Emit(symbol_info, emit_flags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stash raw HIR.
|
||||
@@ -147,9 +139,8 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
}
|
||||
|
||||
// Compile/optimize/etc.
|
||||
result = compiler_->Compile(builder_.get());
|
||||
if (result) {
|
||||
return result;
|
||||
if (!compiler_->Compile(builder_.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stash optimized HIR.
|
||||
@@ -160,14 +151,12 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
||||
}
|
||||
|
||||
// Assemble to backend machine code.
|
||||
result =
|
||||
assembler_->Assemble(symbol_info, builder_.get(), debug_info_flags,
|
||||
std::move(debug_info), trace_flags, out_function);
|
||||
if (result) {
|
||||
return result;
|
||||
if (!assembler_->Assemble(symbol_info, builder_.get(), debug_info_flags,
|
||||
std::move(debug_info), trace_flags, out_function)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
void PPCTranslator::DumpSource(FunctionInfo* symbol_info,
|
||||
|
||||
Reference in New Issue
Block a user