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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/locations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/locations.h" 5 #include "vm/locations.h"
6 6
7 #include "vm/il_printer.h"
7 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
8 #include "vm/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 LocationSummary* LocationSummary::Make(intptr_t input_count, 13 LocationSummary* LocationSummary::Make(intptr_t input_count,
13 Location out, 14 Location out,
14 ContainsCall contains_call, 15 ContainsCall contains_call,
15 ContainsBranch contains_branch) { 16 ContainsBranch contains_branch) {
16 LocationSummary* summary = new LocationSummary(input_count, 17 LocationSummary* summary = new LocationSummary(input_count,
17 0, 18 0,
18 contains_call, 19 contains_call,
19 contains_branch); 20 contains_branch);
20 for (intptr_t i = 0; i < input_count; i++) { 21 for (intptr_t i = 0; i < input_count; i++) {
21 summary->set_in(i, Location::RequiresRegister()); 22 summary->set_in(i, Location::RequiresRegister());
22 } 23 }
23 summary->set_out(out); 24 summary->set_out(out);
24 return summary; 25 return summary;
25 } 26 }
26 27
28
29 #if defined(TARGET_ARCH_IA32)
30 static const char* cpu_reg_names[kNumberOfCpuRegisters] = {
31 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
32 };
33 #elif defined(TARGET_ARCH_X64)
34 static const char* cpu_reg_names[kNumberOfCpuRegisters] = {
35 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
36 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
37 };
38 #endif
39
40
41 const char* Location::Name() const {
42 switch (kind()) {
43 case kInvalid: return "?";
44 case kRegister: return cpu_reg_names[reg()];
45 case kUnallocated:
46 switch (policy()) {
47 case kRequiresRegister:
48 return "R";
49 case kSameAsFirstInput:
50 return "0";
51 }
52 default:
53 ASSERT(IsConstant());
54 return "C";
55 }
56 return "?";
57 }
58
59
60 void LocationSummary::PrintTo(BufferFormatter* f) const {
61 if (input_count() > 0) {
62 f->Print(" (");
63 for (intptr_t i = 0; i < input_count(); i++) {
64 if (i != 0) f->Print(", ");
65 f->Print("%s", in(i).Name());
66 }
67 f->Print(")");
68 }
69
70 if (temp_count() > 0) {
71 f->Print(" [");
72 for (intptr_t i = 0; i < temp_count(); i++) {
73 if (i != 0) f->Print(", ");
74 f->Print("%s", temp(i).Name());
75 }
76 f->Print("]");
77 }
78
79 if (!out().IsInvalid()) {
80 f->Print(" => ");
81 f->Print("%s", out().Name());
82 }
83
84 if (is_call()) f->Print(" C");
85 if (is_branch()) f->Print(" B");
86 }
87
27 } // namespace dart 88 } // namespace dart
28 89
OLDNEW
« 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