From a7062e05e6048c7f817d784a5b94e3122e25b1ec Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 22 May 2014 12:50:17 +0100 Subject: 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 --- compiler/optimizing/optimizing_unit_test.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'compiler/optimizing/optimizing_unit_test.h') diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index 67c4850ca5..36a6a21d01 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -17,6 +17,10 @@ #ifndef ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ #define ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ +#include "ssa_liveness_analysis.h" + +namespace art { + #define NUM_INSTRUCTIONS(...) \ (sizeof((uint16_t[]) {__VA_ARGS__}) /sizeof(uint16_t)) @@ -29,4 +33,21 @@ #define TWO_REGISTERS_CODE_ITEM(...) \ { 2, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } +#define THREE_REGISTERS_CODE_ITEM(...) \ + { 3, 0, 0, 0, 0, 0, NUM_INSTRUCTIONS(__VA_ARGS__), 0, __VA_ARGS__ } + +LiveInterval* BuildInterval(const size_t ranges[][2], + size_t number_of_ranges, + ArenaAllocator* allocator, + int reg = -1) { + LiveInterval* interval = new (allocator) LiveInterval(allocator, Primitive::kPrimInt); + for (size_t i = number_of_ranges; i > 0; --i) { + interval->AddRange(ranges[i - 1][0], ranges[i - 1][1]); + } + interval->SetRegister(reg); + return interval; +} + +} // namespace art + #endif // ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_ -- cgit v1.2.3-59-g8ed1b