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 CondCodes {
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 
69 inline static const char *VECondCodeToString(VECC::CondCodes CC) {
70   switch (CC) {
71   case VECC::CC_IG:    return "gt";
72   case VECC::CC_IL:    return "lt";
73   case VECC::CC_INE:   return "ne";
74   case VECC::CC_IEQ:   return "eq";
75   case VECC::CC_IGE:   return "ge";
76   case VECC::CC_ILE:   return "le";
77   case VECC::CC_AF:    return "af";
78   case VECC::CC_G:     return "gt";
79   case VECC::CC_L:     return "lt";
80   case VECC::CC_NE:    return "ne";
81   case VECC::CC_EQ:    return "eq";
82   case VECC::CC_GE:    return "ge";
83   case VECC::CC_LE:    return "le";
84   case VECC::CC_NUM:   return "num";
85   case VECC::CC_NAN:   return "nan";
86   case VECC::CC_GNAN:  return "gtnan";
87   case VECC::CC_LNAN:  return "ltnan";
88   case VECC::CC_NENAN: return "nenan";
89   case VECC::CC_EQNAN: return "eqnan";
90   case VECC::CC_GENAN: return "genan";
91   case VECC::CC_LENAN: return "lenan";
92   case VECC::CC_AT:    return "at";
93   }
94   llvm_unreachable("Invalid cond code");
95 }
96 
97 // Different to Hi_32/Lo_32 the HI32 and LO32 functions
98 // preserve the correct numerical value
99 // on the LLVM data type for MC immediates (int64_t).
100 inline static int64_t HI32(int64_t imm) {
101   return (int32_t)(imm >> 32);
102 }
103 
104 inline static int64_t LO32(int64_t imm) {
105   return (int32_t)(imm);
106 }
107 
108 } // namespace llvm
109 #endif
110