1 /*
2 * Copyright (C) 2023 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_riscv64.h"
18
19 #include <ostream>
20
21 namespace art HIDDEN {
22 namespace riscv64 {
23
24 static const char* kXRegisterNames[] = {"zero", "ra", "sp", "gp", "tp", "t0", "t1", "t2",
25 "fp", "s1", "a0", "a1", "a2", "a3", "a4", "a5",
26 "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7",
27 "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6"};
28
29 static const char* kFRegisterNames[] = {"ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7",
30 "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5",
31 "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7",
32 "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"};
33
34 static const char* kVRegisterNames[] = {"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
35 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
36 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
37 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
38
operator <<(std::ostream & os,const XRegister & rhs)39 std::ostream& operator<<(std::ostream& os, const XRegister& rhs) {
40 if (rhs >= Zero && rhs < kNumberOfXRegisters) {
41 os << kXRegisterNames[rhs];
42 } else {
43 os << "XRegister[" << static_cast<int>(rhs) << "]";
44 }
45 return os;
46 }
47
operator <<(std::ostream & os,const FRegister & rhs)48 std::ostream& operator<<(std::ostream& os, const FRegister& rhs) {
49 if (rhs >= FT0 && rhs < kNumberOfFRegisters) {
50 os << kFRegisterNames[rhs];
51 } else {
52 os << "FRegister[" << static_cast<int>(rhs) << "]";
53 }
54 return os;
55 }
56
operator <<(std::ostream & os,const VRegister & rhs)57 std::ostream& operator<<(std::ostream& os, const VRegister& rhs) {
58 if (rhs >= V0 && rhs < kNumberOfVRegisters) {
59 os << kVRegisterNames[rhs];
60 } else {
61 os << "VRegister[" << static_cast<int>(rhs) << "]";
62 }
63 return os;
64 }
65
66 } // namespace riscv64
67 } // namespace art
68