Add a linear scan register allocator to the optimizing compiler.
This is a "by-the-book" implementation. It currently only deals
with allocating registers, with no hint optimizations.
The changes remaining to make it functional are:
- Allocate spill slots.
- Resolution and placements of Move instructions.
- Connect it to the code generator.
Change-Id: Ie0b2f6ba1b98da85425be721ce4afecd6b4012a4
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index e18902f..e197ccd 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -74,6 +74,13 @@
void SetFrameSize(uint32_t size) { frame_size_ = size; }
uint32_t GetCoreSpillMask() const { return core_spill_mask_; }
+ virtual size_t GetNumberOfCoreRegisters() const = 0;
+ virtual size_t GetNumberOfFloatingPointRegisters() const = 0;
+ virtual size_t GetNumberOfRegisters() const = 0;
+ virtual void SetupBlockedRegisters(bool* blocked_registers) const = 0;
+ virtual void DumpCoreRegister(std::ostream& stream, int reg) const = 0;
+ virtual void DumpFloatingPointRegister(std::ostream& stream, int reg) const = 0;
+
void RecordPcInfo(uint32_t dex_pc) {
struct PcInfo pc_info;
pc_info.dex_pc = dex_pc;
@@ -92,8 +99,7 @@
graph_(graph),
block_labels_(graph->GetArena(), 0),
pc_infos_(graph->GetArena(), 32),
- blocked_registers_(static_cast<bool*>(
- graph->GetArena()->Alloc(number_of_registers * sizeof(bool), kArenaAllocData))) {
+ blocked_registers_(graph->GetArena()->AllocArray<bool>(number_of_registers)) {
block_labels_.SetSize(graph->GetBlocks().Size());
}
~CodeGenerator() { }
@@ -109,9 +115,6 @@
// the first available register.
size_t AllocateFreeRegisterInternal(bool* blocked_registers, size_t number_of_registers) const;
- virtual void SetupBlockedRegisters(bool* blocked_registers) const = 0;
- virtual size_t GetNumberOfRegisters() const = 0;
-
virtual Location GetStackLocation(HLoadLocal* load) const = 0;
// Frame size required for this method.