1 //===-- LanaiBaseInfo.h - Top level definitions for Lanai MC ----*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains small standalone helper functions and enum definitions for 10 // the Lanai target useful for the compiler back-end and the MC libraries. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIBASEINFO_H 15 #define LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIBASEINFO_H 16 17 #include "LanaiMCTargetDesc.h" 18 #include "llvm/MC/MCExpr.h" 19 #include "llvm/Support/DataTypes.h" 20 #include "llvm/Support/ErrorHandling.h" 21 22 namespace llvm { 23 24 // LanaiII - This namespace holds all of the target specific flags that 25 // instruction info tracks. 26 namespace LanaiII { 27 // Target Operand Flag enum. 28 enum TOF { 29 //===------------------------------------------------------------------===// 30 // Lanai Specific MachineOperand flags. 31 MO_NO_FLAG, 32 33 // MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol 34 // address. 35 MO_ABS_HI, 36 MO_ABS_LO, 37 }; 38 } // namespace LanaiII 39 getLanaiRegisterNumbering(unsigned Reg)40static inline unsigned getLanaiRegisterNumbering(unsigned Reg) { 41 switch (Reg) { 42 case Lanai::R0: 43 return 0; 44 case Lanai::R1: 45 return 1; 46 case Lanai::R2: 47 case Lanai::PC: 48 return 2; 49 case Lanai::R3: 50 return 3; 51 case Lanai::R4: 52 case Lanai::SP: 53 return 4; 54 case Lanai::R5: 55 case Lanai::FP: 56 return 5; 57 case Lanai::R6: 58 return 6; 59 case Lanai::R7: 60 return 7; 61 case Lanai::R8: 62 case Lanai::RV: 63 return 8; 64 case Lanai::R9: 65 return 9; 66 case Lanai::R10: 67 case Lanai::RR1: 68 return 10; 69 case Lanai::R11: 70 case Lanai::RR2: 71 return 11; 72 case Lanai::R12: 73 return 12; 74 case Lanai::R13: 75 return 13; 76 case Lanai::R14: 77 return 14; 78 case Lanai::R15: 79 case Lanai::RCA: 80 return 15; 81 case Lanai::R16: 82 return 16; 83 case Lanai::R17: 84 return 17; 85 case Lanai::R18: 86 return 18; 87 case Lanai::R19: 88 return 19; 89 case Lanai::R20: 90 return 20; 91 case Lanai::R21: 92 return 21; 93 case Lanai::R22: 94 return 22; 95 case Lanai::R23: 96 return 23; 97 case Lanai::R24: 98 return 24; 99 case Lanai::R25: 100 return 25; 101 case Lanai::R26: 102 return 26; 103 case Lanai::R27: 104 return 27; 105 case Lanai::R28: 106 return 28; 107 case Lanai::R29: 108 return 29; 109 case Lanai::R30: 110 return 30; 111 case Lanai::R31: 112 return 31; 113 default: 114 llvm_unreachable("Unknown register number!"); 115 } 116 } 117 } // namespace llvm 118 #endif // LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIBASEINFO_H 119