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

Side by Side Diff: runtime/vm/locations.cc

Issue 10382234: Introduce locations based code generation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: addressed Srdjan comments Created 8 years, 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/locations.h"
6
7 #include "vm/intermediate_language.h"
8
9 namespace dart {
10
11
12 static Register AllocateFreeRegister(
13 EmbeddedArray<bool, kNumberOfCpuRegisters>* blocked_registers) {
14 for (int regno = 0; regno < kNumberOfCpuRegisters; regno++) {
srdjan 2012/05/21 16:05:22 intptr_t
Vyacheslav Egorov (Google) 2012/05/21 19:53:46 Done.
15 if (!blocked_registers->At(regno)) {
Florian Schneider 2012/05/21 18:33:38 (*blocked_registers)[regno] should also work here.
srdjan 2012/05/21 19:49:43 I like the idea of getting rid of const overloaded
Vyacheslav Egorov (Google) 2012/05/21 19:53:46 I'll go with a method, it looks nicer.
16 blocked_registers->SetAt(regno, true);
Florian Schneider 2012/05/21 18:33:38 (*blocked_registers)[regno] = true; should also w
Vyacheslav Egorov (Google) 2012/05/21 19:53:46 I'll go with a method, it looks nicer.
17 return static_cast<Register>(regno);
18 }
19 }
20 UNREACHABLE();
21 return kNoRegister;
22 }
23
24
25 void LocationSummary::AllocateRegisters() {
26 EmbeddedArray<bool, kNumberOfCpuRegisters> blocked_registers;
27
28 // Mark all registers free.
29 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) {
30 blocked_registers[i] = false;
31 }
32
33 // Mark all fixed registers as used.
34 for (intptr_t i = 0; i < count(); i++) {
35 Location loc = in(i);
36 if (loc.kind() == Location::kRegister) {
37 ASSERT(!blocked_registers[loc.AsRegister()]);
38 blocked_registers[loc.value()] = true;
39 }
40 }
41
42 // Allocate all unallocated input locations.
43 for (intptr_t i = 0; i < count(); i++) {
44 Location loc = in(i);
45 if (loc.kind() == Location::kUnallocated) {
46 ASSERT(UnallocatedLocation::Cast(loc).policy() ==
47 UnallocatedLocation::kRegister);
48 set_in(i, RegisterLocation(
49 AllocateFreeRegister(&blocked_registers)));
50 }
51 }
52
53 Location result_location = out();
54 if (result_location.kind() == Location::kUnallocated) {
55 switch (UnallocatedLocation::Cast(result_location).policy()) {
56 case UnallocatedLocation::kRegister:
57 result_location = RegisterLocation(
58 AllocateFreeRegister(&blocked_registers));
59 break;
60 case UnallocatedLocation::kSameAsFirstInput:
61 result_location = in(0);
62 break;
63 }
64 set_out(result_location);
65 }
66 }
67
68
69 } // namespace dart
70
OLDNEW
« runtime/vm/locations.h ('K') | « runtime/vm/locations.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698