1 /*
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
21 namespace art {
22 namespace arm64 {
23
24 static 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",
28 "lr", "sp", "xzr"
29 };
30
31 static 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",
35 "w30", "wsp", "wzr"
36 };
37
operator <<(std::ostream & os,const XRegister & rhs)38 std::ostream& operator<<(std::ostream& os, const XRegister& rhs) {
39 if (rhs >= X0 && rhs < kNumberOfXRegisters) {
40 os << kRegisterNames[rhs];
41 } else {
42 os << "XRegister[" << static_cast<int>(rhs) << "]";
43 }
44 return os;
45 }
46
operator <<(std::ostream & os,const WRegister & rhs)47 std::ostream& operator<<(std::ostream& os, const WRegister& rhs) {
48 if (rhs >= W0 && rhs < kNumberOfWRegisters) {
49 os << kWRegisterNames[rhs];
50 } else {
51 os << "WRegister[" << static_cast<int>(rhs) << "]";
52 }
53 return os;
54 }
55
operator <<(std::ostream & os,const DRegister & rhs)56 std::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
operator <<(std::ostream & os,const SRegister & rhs)65 std::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
76