1 //===-- VE.h - Top-level interface for VE representation --------*- 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 the entry points for global functions defined in the LLVM 10 // VE back-end. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_VE_VE_H 15 #define LLVM_LIB_TARGET_VE_VE_H 16 17 #include "MCTargetDesc/VEMCTargetDesc.h" 18 #include "llvm/Support/ErrorHandling.h" 19 #include "llvm/Target/TargetMachine.h" 20 21 namespace llvm { 22 class FunctionPass; 23 class VETargetMachine; 24 class formatted_raw_ostream; 25 class AsmPrinter; 26 class MCInst; 27 class MachineInstr; 28 29 FunctionPass *createVEISelDag(VETargetMachine &TM); 30 FunctionPass *createVEPromoteToI1Pass(); 31 32 void LowerVEMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, 33 AsmPrinter &AP); 34 } // namespace llvm 35 36 namespace llvm { 37 // Enums corresponding to VE condition codes, both icc's and fcc's. These 38 // values must be kept in sync with the ones in the .td file. 39 namespace VECC { 40 enum CondCode { 41 // Integer comparison 42 CC_IG = 0, // Greater 43 CC_IL = 1, // Less 44 CC_INE = 2, // Not Equal 45 CC_IEQ = 3, // Equal 46 CC_IGE = 4, // Greater or Equal 47 CC_ILE = 5, // Less or Equal 48 49 // Floating point comparison 50 CC_AF = 0 + 6, // Never 51 CC_G = 1 + 6, // Greater 52 CC_L = 2 + 6, // Less 53 CC_NE = 3 + 6, // Not Equal 54 CC_EQ = 4 + 6, // Equal 55 CC_GE = 5 + 6, // Greater or Equal 56 CC_LE = 6 + 6, // Less or Equal 57 CC_NUM = 7 + 6, // Number 58 CC_NAN = 8 + 6, // NaN 59 CC_GNAN = 9 + 6, // Greater or NaN 60 CC_LNAN = 10 + 6, // Less or NaN 61 CC_NENAN = 11 + 6, // Not Equal or NaN 62 CC_EQNAN = 12 + 6, // Equal or NaN 63 CC_GENAN = 13 + 6, // Greater or Equal or NaN 64 CC_LENAN = 14 + 6, // Less or Equal or NaN 65 CC_AT = 15 + 6, // Always 66 }; 67 } 68 // Enums corresponding to VE Rounding Mode. These values must be kept in 69 // sync with the ones in the .td file. 70 namespace VERD { 71 enum RoundingMode { 72 RD_NONE = 0, // According to PSW 73 RD_RZ = 8, // Round toward Zero 74 RD_RP = 9, // Round toward Plus infinity 75 RD_RM = 10, // Round toward Minus infinity 76 RD_RN = 11, // Round to Nearest (ties to Even) 77 RD_RA = 12, // Round to Nearest (ties to Away) 78 UNKNOWN 79 }; 80 } 81 82 inline static const char *VECondCodeToString(VECC::CondCode CC) { 83 switch (CC) { 84 case VECC::CC_IG: return "gt"; 85 case VECC::CC_IL: return "lt"; 86 case VECC::CC_INE: return "ne"; 87 case VECC::CC_IEQ: return "eq"; 88 case VECC::CC_IGE: return "ge"; 89 case VECC::CC_ILE: return "le"; 90 case VECC::CC_AF: return "af"; 91 case VECC::CC_G: return "gt"; 92 case VECC::CC_L: return "lt"; 93 case VECC::CC_NE: return "ne"; 94 case VECC::CC_EQ: return "eq"; 95 case VECC::CC_GE: return "ge"; 96 case VECC::CC_LE: return "le"; 97 case VECC::CC_NUM: return "num"; 98 case VECC::CC_NAN: return "nan"; 99 case VECC::CC_GNAN: return "gtnan"; 100 case VECC::CC_LNAN: return "ltnan"; 101 case VECC::CC_NENAN: return "nenan"; 102 case VECC::CC_EQNAN: return "eqnan"; 103 case VECC::CC_GENAN: return "genan"; 104 case VECC::CC_LENAN: return "lenan"; 105 case VECC::CC_AT: return "at"; 106 } 107 llvm_unreachable("Invalid cond code"); 108 } 109 110 inline static const char *VERDToString(VERD::RoundingMode R) { 111 switch (R) { 112 case VERD::RD_NONE: 113 return ""; 114 case VERD::RD_RZ: 115 return ".rz"; 116 case VERD::RD_RP: 117 return ".rp"; 118 case VERD::RD_RM: 119 return ".rm"; 120 case VERD::RD_RN: 121 return ".rn"; 122 case VERD::RD_RA: 123 return ".ra"; 124 default: 125 llvm_unreachable("Invalid branch predicate"); 126 } 127 } 128 129 inline unsigned M0(unsigned Val) { return Val + 64; } 130 inline unsigned M1(unsigned Val) { return Val; } 131 132 } // namespace llvm 133 #endif 134