Centralize instruction-set pointer-size, alignment, 64b-width code
in instruction_set.h/cc
This allows to clean up some places that currently make explicit
comparisons.
Change-Id: I0dcc924c52fa53306f706aceea93a2d4a655c5df
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index eff2425..dc66e9c 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -345,36 +345,6 @@
return offset;
}
-static void DCheckCodeAlignment(size_t offset, InstructionSet isa) {
- switch (isa) {
- case kArm:
- // Fall-through.
- case kThumb2:
- DCHECK_ALIGNED(offset, kArmAlignment);
- break;
-
- case kArm64:
- DCHECK_ALIGNED(offset, kArm64Alignment);
- break;
-
- case kMips:
- DCHECK_ALIGNED(offset, kMipsAlignment);
- break;
-
- case kX86_64:
- // Fall-through.
- case kX86:
- DCHECK_ALIGNED(offset, kX86Alignment);
- break;
-
- case kNone:
- // Use a DCHECK instead of FATAL so that in the non-debug case the whole switch can
- // be optimized away.
- DCHECK(false);
- break;
- }
-}
-
size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index,
size_t __attribute__((unused)) class_def_index,
size_t class_def_method_index,
@@ -406,7 +376,8 @@
} else {
CHECK(quick_code != nullptr);
offset = compiled_method->AlignCode(offset);
- DCheckCodeAlignment(offset, compiled_method->GetInstructionSet());
+ DCHECK_ALIGNED_PARAM(offset,
+ GetInstructionSetAlignment(compiled_method->GetInstructionSet()));
uint32_t code_size = quick_code->size() * sizeof(uint8_t);
CHECK_NE(code_size, 0U);
@@ -539,11 +510,7 @@
refs++;
}
}
- InstructionSet trg_isa = compiler_driver_->GetInstructionSet();
- size_t pointer_size = 4;
- if (trg_isa == kArm64 || trg_isa == kX86_64) {
- pointer_size = 8;
- }
+ size_t pointer_size = GetInstructionSetPointerSize(compiler_driver_->GetInstructionSet());
size_t sirt_size = StackIndirectReferenceTable::GetAlignedSirtSizeTarget(pointer_size, refs);
// Get the generic spill masks and base frame size.
@@ -857,7 +824,8 @@
relative_offset += aligned_code_delta;
DCHECK_OFFSET();
}
- DCheckCodeAlignment(relative_offset, compiled_method->GetInstructionSet());
+ DCHECK_ALIGNED_PARAM(relative_offset,
+ GetInstructionSetAlignment(compiled_method->GetInstructionSet()));
uint32_t code_size = quick_code->size() * sizeof(uint8_t);
CHECK_NE(code_size, 0U);