blob: ea4383a8d0afd5cabf35429a7e6c3fbd930e5acf [file] [log] [blame]
Serban Constantinescued8dd492014-02-11 14:15:10 +00001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "registers_arm64.h"
18
19#include <ostream>
20
21namespace art {
22namespace arm64 {
23
24static const char* kRegisterNames[] = {
25 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9",
26 "x10", "x11", "x12", "x13", "x14", "x15", "ip0", "ip1", "x18", "x19",
27 "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "fp",
Stuart Monteithb95a5342014-03-12 13:32:32 +000028 "lr", "sp", "xzr"
Serban Constantinescued8dd492014-02-11 14:15:10 +000029};
30
31static const char* kWRegisterNames[] = {
32 "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9",
33 "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19",
34 "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29",
Alexandre Ramesa304f972014-10-17 14:35:27 +010035 "w30", "wsp", "wzr"
Serban Constantinescued8dd492014-02-11 14:15:10 +000036};
37
Alexandre Rames37c92df2014-10-17 14:35:27 +010038std::ostream& operator<<(std::ostream& os, const XRegister& rhs) {
39 if (rhs >= X0 && rhs < kNumberOfXRegisters) {
Serban Constantinescued8dd492014-02-11 14:15:10 +000040 os << kRegisterNames[rhs];
41 } else {
42 os << "XRegister[" << static_cast<int>(rhs) << "]";
43 }
44 return os;
45}
46
47std::ostream& operator<<(std::ostream& os, const WRegister& rhs) {
Alexandre Ramesa304f972014-10-17 14:35:27 +010048 if (rhs >= W0 && rhs < kNumberOfWRegisters) {
Serban Constantinescued8dd492014-02-11 14:15:10 +000049 os << kWRegisterNames[rhs];
50 } else {
51 os << "WRegister[" << static_cast<int>(rhs) << "]";
52 }
53 return os;
54}
55
56std::ostream& operator<<(std::ostream& os, const DRegister& rhs) {
57 if (rhs >= D0 && rhs < kNumberOfDRegisters) {
58 os << "d" << static_cast<int>(rhs);
59 } else {
60 os << "DRegister[" << static_cast<int>(rhs) << "]";
61 }
62 return os;
63}
64
65std::ostream& operator<<(std::ostream& os, const SRegister& rhs) {
66 if (rhs >= S0 && rhs < kNumberOfSRegisters) {
67 os << "s" << static_cast<int>(rhs);
68 } else {
69 os << "SRegister[" << static_cast<int>(rhs) << "]";
70 }
71 return os;
72}
73
74} // namespace arm64
75} // namespace art