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 #include <fstream> 18 #include <string> 19 #include "aarch64_abi.h" 20 #include "aarch64_cgfunc.h" 21 #include "aarch64_cg.h" 22 23 namespace maplebe { Less(const Operand & right) const24bool StImmOperand::Less(const Operand &right) const 25 { 26 if (&right == this) { 27 return false; 28 } 29 30 /* For different type. */ 31 if (GetKind() != right.GetKind()) { 32 return GetKind() < right.GetKind(); 33 } 34 35 const StImmOperand *rightOpnd = static_cast<const StImmOperand *>(&right); 36 if (symbol != rightOpnd->symbol) { 37 return symbol < rightOpnd->symbol; 38 } 39 if (offset != rightOpnd->offset) { 40 return offset < rightOpnd->offset; 41 } 42 return relocs < rightOpnd->relocs; 43 } 44 Less(const Operand & right) const45bool ExtendShiftOperand::Less(const Operand &right) const 46 { 47 if (&right == this) { 48 return false; 49 } 50 /* For different type. */ 51 if (GetKind() != right.GetKind()) { 52 return GetKind() < right.GetKind(); 53 } 54 55 const ExtendShiftOperand *rightOpnd = static_cast<const ExtendShiftOperand *>(&right); 56 57 /* The same type. */ 58 if (extendOp != rightOpnd->extendOp) { 59 return extendOp < rightOpnd->extendOp; 60 } 61 return shiftAmount < rightOpnd->shiftAmount; 62 } 63 } /* namespace maplebe */ 64