blob: 36a4d20e1a4703b3137c6e9760e443710c5493ee [file] [log] [blame]
kasperl@chromium.org7be3c992009-03-12 07:19:55 +00001// Copyright 2009 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
ager@chromium.orgbb29dc92009-03-24 13:25:23 +000030#include "codegen-inl.h"
31#include "register-allocator-inl.h"
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000032
33namespace v8 { namespace internal {
34
35// -------------------------------------------------------------------------
36// Result implementation.
37
38void Result::ToRegister() {
39 UNIMPLEMENTED();
40}
41
42
43void Result::ToRegister(Register target) {
44 UNIMPLEMENTED();
45}
46
47
48// -------------------------------------------------------------------------
49// RegisterAllocator implementation.
50
51RegisterFile RegisterAllocator::Reserved() {
52 RegisterFile reserved;
53 reserved.Use(sp);
54 reserved.Use(fp);
55 reserved.Use(cp);
56 reserved.Use(pc);
57 return reserved;
58}
59
60
61void RegisterAllocator::UnuseReserved(RegisterFile* register_file) {
62 register_file->ref_counts_[sp.code()] = 0;
63 register_file->ref_counts_[fp.code()] = 0;
64 register_file->ref_counts_[cp.code()] = 0;
65 register_file->ref_counts_[pc.code()] = 0;
66}
67
68
69void RegisterAllocator::Initialize() {
70 Reset();
71 // The following registers are live on function entry, saved in the
72 // frame, and available for allocation during execution.
73 Use(r1); // JS function.
74 Use(lr); // Return address.
75}
76
77
78void RegisterAllocator::Reset() {
79 registers_.Reset();
80 // The following registers are live on function entry and reserved
81 // during execution.
82 Use(sp); // Stack pointer.
83 Use(fp); // Frame pointer (caller's frame pointer on entry).
84 Use(cp); // Context context (callee's context on entry).
85 Use(pc); // Program counter.
86}
87
88
89Result RegisterAllocator::AllocateByteRegisterWithoutSpilling() {
90 UNIMPLEMENTED();
91 Result invalid(cgen_);
92 return invalid;
93}
94
95
96} } // namespace v8::internal