summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_unit_test.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2014-05-22 12:50:17 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2014-05-26 11:31:38 +0100
commita7062e05e6048c7f817d784a5b94e3122e25b1ec (patch)
treea5d6b64ae6d5352f761fc2547bda863281adbe40 /compiler/optimizing/optimizing_unit_test.h
parent8b5b1e5593ffa77c393e4172b71a3d5a821d2ed8 (diff)
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
Diffstat (limited to 'compiler/optimizing/optimizing_unit_test.h')
-rw-r--r--compiler/optimizing/optimizing_unit_test.h21
1 files changed, 21 insertions, 0 deletions
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_