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 "managed_register_riscv64.h"
18 
19 #include "base/globals.h"
20 
21 namespace art HIDDEN {
22 namespace riscv64 {
23 
Overlaps(const Riscv64ManagedRegister & other) const24 bool Riscv64ManagedRegister::Overlaps(const Riscv64ManagedRegister& other) const {
25   if (IsNoRegister() || other.IsNoRegister()) {
26     return false;
27   }
28   CHECK(IsValidManagedRegister());
29   CHECK(other.IsValidManagedRegister());
30 
31   return Equals(other);
32 }
33 
Print(std::ostream & os) const34 void Riscv64ManagedRegister::Print(std::ostream& os) const {
35   if (!IsValidManagedRegister()) {
36     os << "No Register";
37   } else if (IsXRegister()) {
38     os << "XRegister: " << static_cast<int>(AsXRegister());
39   } else if (IsFRegister()) {
40     os << "FRegister: " << static_cast<int>(AsFRegister());
41   } else {
42     os << "??: " << RegId();
43   }
44 }
45 
operator <<(std::ostream & os,const Riscv64ManagedRegister & reg)46 std::ostream& operator<<(std::ostream& os, const Riscv64ManagedRegister& reg) {
47   reg.Print(os);
48   return os;
49 }
50 
51 }  // namespace riscv64
52 }  // namespace art
53