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 #ifndef MAPLEBE_INCLUDE_TARGET_MACHINE_H 16 #define MAPLEBE_INCLUDE_TARGET_MACHINE_H 17 #include "types_def.h" 18 #include "cg.h" 19 #include "target_registry.h" 20 21 namespace maplebe { 22 using namespace maple; 23 enum TargetKind : uint8 { 24 kAArch64, 25 kX8664, 26 kRiscV, 27 kArm32, 28 kArk 29 }; 30 31 class TargetMachine { 32 public: TargetMachine(TargetKind kind)33 TargetMachine(TargetKind kind) : kind(kind) {} isAArch64()34 bool isAArch64() 35 { 36 return kind == kAArch64; 37 } 38 isX8664()39 bool isX8664() 40 { 41 return kind == kX8664; 42 } 43 isRiscV()44 bool isRiscV() 45 { 46 return kind == kRiscV; 47 } 48 isArm32()49 bool isArm32() 50 { 51 return kind == kArm32; 52 } 53 isArk()54 bool isArk() 55 { 56 return kind == kArk; 57 } 58 59 private: 60 TargetKind kind; 61 }; 62 } /* namespace maplebe */ 63 64 #endif /* MAPLEBE_INCLUDE_TARGET_MACHINE_H */ 65