• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "aarch64_operand.h"
17 
18 namespace maplebe {
Less(const Operand & right) const19 bool StImmOperand::Less(const Operand &right) const
20 {
21     if (&right == this) {
22         return false;
23     }
24 
25     /* For different type. */
26     if (GetKind() != right.GetKind()) {
27         return GetKind() < right.GetKind();
28     }
29 
30     const StImmOperand *rightOpnd = static_cast<const StImmOperand *>(&right);
31     if (symbol != rightOpnd->symbol) {
32         return symbol < rightOpnd->symbol;
33     }
34     if (offset != rightOpnd->offset) {
35         return offset < rightOpnd->offset;
36     }
37     return relocs < rightOpnd->relocs;
38 }
39 
Less(const Operand & right) const40 bool ExtendShiftOperand::Less(const Operand &right) const
41 {
42     if (&right == this) {
43         return false;
44     }
45     /* For different type. */
46     if (GetKind() != right.GetKind()) {
47         return GetKind() < right.GetKind();
48     }
49 
50     const ExtendShiftOperand *rightOpnd = static_cast<const ExtendShiftOperand *>(&right);
51 
52     /* The same type. */
53     if (extendOp != rightOpnd->extendOp) {
54         return extendOp < rightOpnd->extendOp;
55     }
56     return shiftAmount < rightOpnd->shiftAmount;
57 }
58 } /* namespace maplebe */
59