Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: runtime/vm/locations.cc

Issue 10696151: Skeleton of a linear scan register allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/locations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/locations.cc
diff --git a/runtime/vm/locations.cc b/runtime/vm/locations.cc
index 7447760c5b180d9c02cd4e3dbc27b961adf6ebf5..c2ba2fedf5efb80ffbf31d8f3ff6ae5a08e7cbbf 100644
--- a/runtime/vm/locations.cc
+++ b/runtime/vm/locations.cc
@@ -4,6 +4,7 @@
#include "vm/locations.h"
+#include "vm/il_printer.h"
#include "vm/intermediate_language.h"
#include "vm/flow_graph_compiler.h"
@@ -24,5 +25,65 @@ LocationSummary* LocationSummary::Make(intptr_t input_count,
return summary;
}
+
+#if defined(TARGET_ARCH_IA32)
+static const char* cpu_reg_names[kNumberOfCpuRegisters] = {
+ "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
+};
+#elif defined(TARGET_ARCH_X64)
+static const char* cpu_reg_names[kNumberOfCpuRegisters] = {
+ "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
+};
+#endif
+
+
+const char* Location::Name() const {
+ switch (kind()) {
+ case kInvalid: return "?";
+ case kRegister: return cpu_reg_names[reg()];
+ case kUnallocated:
+ switch (policy()) {
+ case kRequiresRegister:
+ return "R";
+ case kSameAsFirstInput:
+ return "0";
+ }
+ default:
+ ASSERT(IsConstant());
+ return "C";
+ }
+ return "?";
+}
+
+
+void LocationSummary::PrintTo(BufferFormatter* f) const {
+ if (input_count() > 0) {
+ f->Print(" (");
+ for (intptr_t i = 0; i < input_count(); i++) {
+ if (i != 0) f->Print(", ");
+ f->Print("%s", in(i).Name());
+ }
+ f->Print(")");
+ }
+
+ if (temp_count() > 0) {
+ f->Print(" [");
+ for (intptr_t i = 0; i < temp_count(); i++) {
+ if (i != 0) f->Print(", ");
+ f->Print("%s", temp(i).Name());
+ }
+ f->Print("]");
+ }
+
+ if (!out().IsInvalid()) {
+ f->Print(" => ");
+ f->Print("%s", out().Name());
+ }
+
+ if (is_call()) f->Print(" C");
+ if (is_branch()) f->Print(" B");
+}
+
} // namespace dart
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/locations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698