1*0b57cec5SDimitry Andric //==- SystemZ.h - Top-Level Interface for SystemZ representation -*- C++ -*-==// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file contains the entry points for global functions defined in 10*0b57cec5SDimitry Andric // the LLVM SystemZ backend. 11*0b57cec5SDimitry Andric // 12*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 13*0b57cec5SDimitry Andric 14*0b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H 15*0b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H 16*0b57cec5SDimitry Andric 17*0b57cec5SDimitry Andric #include "MCTargetDesc/SystemZMCTargetDesc.h" 18*0b57cec5SDimitry Andric #include "llvm/Support/CodeGen.h" 19*0b57cec5SDimitry Andric 20*0b57cec5SDimitry Andric namespace llvm { 21*0b57cec5SDimitry Andric class SystemZTargetMachine; 22*0b57cec5SDimitry Andric class FunctionPass; 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric namespace SystemZ { 25*0b57cec5SDimitry Andric // Condition-code mask values. 26*0b57cec5SDimitry Andric const unsigned CCMASK_0 = 1 << 3; 27*0b57cec5SDimitry Andric const unsigned CCMASK_1 = 1 << 2; 28*0b57cec5SDimitry Andric const unsigned CCMASK_2 = 1 << 1; 29*0b57cec5SDimitry Andric const unsigned CCMASK_3 = 1 << 0; 30*0b57cec5SDimitry Andric const unsigned CCMASK_ANY = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3; 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric // Condition-code mask assignments for integer and floating-point 33*0b57cec5SDimitry Andric // comparisons. 34*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_EQ = CCMASK_0; 35*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_LT = CCMASK_1; 36*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_GT = CCMASK_2; 37*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_NE = CCMASK_CMP_LT | CCMASK_CMP_GT; 38*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_LE = CCMASK_CMP_EQ | CCMASK_CMP_LT; 39*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_GE = CCMASK_CMP_EQ | CCMASK_CMP_GT; 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andric // Condition-code mask assignments for floating-point comparisons only. 42*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_UO = CCMASK_3; 43*0b57cec5SDimitry Andric const unsigned CCMASK_CMP_O = CCMASK_ANY ^ CCMASK_CMP_UO; 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric // All condition-code values produced by comparisons. 46*0b57cec5SDimitry Andric const unsigned CCMASK_ICMP = CCMASK_0 | CCMASK_1 | CCMASK_2; 47*0b57cec5SDimitry Andric const unsigned CCMASK_FCMP = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3; 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andric // Condition-code mask assignments for arithmetical operations. 50*0b57cec5SDimitry Andric const unsigned CCMASK_ARITH_EQ = CCMASK_0; 51*0b57cec5SDimitry Andric const unsigned CCMASK_ARITH_LT = CCMASK_1; 52*0b57cec5SDimitry Andric const unsigned CCMASK_ARITH_GT = CCMASK_2; 53*0b57cec5SDimitry Andric const unsigned CCMASK_ARITH_OVERFLOW = CCMASK_3; 54*0b57cec5SDimitry Andric const unsigned CCMASK_ARITH = CCMASK_ANY; 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andric // Condition-code mask assignments for logical operations. 57*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_ZERO = CCMASK_0 | CCMASK_2; 58*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_NONZERO = CCMASK_1 | CCMASK_2; 59*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_CARRY = CCMASK_2 | CCMASK_3; 60*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_NOCARRY = CCMASK_0 | CCMASK_1; 61*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_BORROW = CCMASK_LOGICAL_NOCARRY; 62*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_NOBORROW = CCMASK_LOGICAL_CARRY; 63*0b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL = CCMASK_ANY; 64*0b57cec5SDimitry Andric 65*0b57cec5SDimitry Andric // Condition-code mask assignments for CS. 66*0b57cec5SDimitry Andric const unsigned CCMASK_CS_EQ = CCMASK_0; 67*0b57cec5SDimitry Andric const unsigned CCMASK_CS_NE = CCMASK_1; 68*0b57cec5SDimitry Andric const unsigned CCMASK_CS = CCMASK_0 | CCMASK_1; 69*0b57cec5SDimitry Andric 70*0b57cec5SDimitry Andric // Condition-code mask assignments for a completed SRST loop. 71*0b57cec5SDimitry Andric const unsigned CCMASK_SRST_FOUND = CCMASK_1; 72*0b57cec5SDimitry Andric const unsigned CCMASK_SRST_NOTFOUND = CCMASK_2; 73*0b57cec5SDimitry Andric const unsigned CCMASK_SRST = CCMASK_1 | CCMASK_2; 74*0b57cec5SDimitry Andric 75*0b57cec5SDimitry Andric // Condition-code mask assignments for TEST UNDER MASK. 76*0b57cec5SDimitry Andric const unsigned CCMASK_TM_ALL_0 = CCMASK_0; 77*0b57cec5SDimitry Andric const unsigned CCMASK_TM_MIXED_MSB_0 = CCMASK_1; 78*0b57cec5SDimitry Andric const unsigned CCMASK_TM_MIXED_MSB_1 = CCMASK_2; 79*0b57cec5SDimitry Andric const unsigned CCMASK_TM_ALL_1 = CCMASK_3; 80*0b57cec5SDimitry Andric const unsigned CCMASK_TM_SOME_0 = CCMASK_TM_ALL_1 ^ CCMASK_ANY; 81*0b57cec5SDimitry Andric const unsigned CCMASK_TM_SOME_1 = CCMASK_TM_ALL_0 ^ CCMASK_ANY; 82*0b57cec5SDimitry Andric const unsigned CCMASK_TM_MSB_0 = CCMASK_0 | CCMASK_1; 83*0b57cec5SDimitry Andric const unsigned CCMASK_TM_MSB_1 = CCMASK_2 | CCMASK_3; 84*0b57cec5SDimitry Andric const unsigned CCMASK_TM = CCMASK_ANY; 85*0b57cec5SDimitry Andric 86*0b57cec5SDimitry Andric // Condition-code mask assignments for TRANSACTION_BEGIN. 87*0b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_STARTED = CCMASK_0; 88*0b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_INDETERMINATE = CCMASK_1; 89*0b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_TRANSIENT = CCMASK_2; 90*0b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_PERSISTENT = CCMASK_3; 91*0b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN = CCMASK_ANY; 92*0b57cec5SDimitry Andric 93*0b57cec5SDimitry Andric // Condition-code mask assignments for TRANSACTION_END. 94*0b57cec5SDimitry Andric const unsigned CCMASK_TEND_TX = CCMASK_0; 95*0b57cec5SDimitry Andric const unsigned CCMASK_TEND_NOTX = CCMASK_2; 96*0b57cec5SDimitry Andric const unsigned CCMASK_TEND = CCMASK_TEND_TX | CCMASK_TEND_NOTX; 97*0b57cec5SDimitry Andric 98*0b57cec5SDimitry Andric // Condition-code mask assignments for vector comparisons (and similar 99*0b57cec5SDimitry Andric // operations). 100*0b57cec5SDimitry Andric const unsigned CCMASK_VCMP_ALL = CCMASK_0; 101*0b57cec5SDimitry Andric const unsigned CCMASK_VCMP_MIXED = CCMASK_1; 102*0b57cec5SDimitry Andric const unsigned CCMASK_VCMP_NONE = CCMASK_3; 103*0b57cec5SDimitry Andric const unsigned CCMASK_VCMP = CCMASK_0 | CCMASK_1 | CCMASK_3; 104*0b57cec5SDimitry Andric 105*0b57cec5SDimitry Andric // Condition-code mask assignments for Test Data Class. 106*0b57cec5SDimitry Andric const unsigned CCMASK_TDC_NOMATCH = CCMASK_0; 107*0b57cec5SDimitry Andric const unsigned CCMASK_TDC_MATCH = CCMASK_1; 108*0b57cec5SDimitry Andric const unsigned CCMASK_TDC = CCMASK_TDC_NOMATCH | CCMASK_TDC_MATCH; 109*0b57cec5SDimitry Andric 110*0b57cec5SDimitry Andric // The position of the low CC bit in an IPM result. 111*0b57cec5SDimitry Andric const unsigned IPM_CC = 28; 112*0b57cec5SDimitry Andric 113*0b57cec5SDimitry Andric // Mask assignments for PFD. 114*0b57cec5SDimitry Andric const unsigned PFD_READ = 1; 115*0b57cec5SDimitry Andric const unsigned PFD_WRITE = 2; 116*0b57cec5SDimitry Andric 117*0b57cec5SDimitry Andric // Mask assignments for TDC 118*0b57cec5SDimitry Andric const unsigned TDCMASK_ZERO_PLUS = 0x800; 119*0b57cec5SDimitry Andric const unsigned TDCMASK_ZERO_MINUS = 0x400; 120*0b57cec5SDimitry Andric const unsigned TDCMASK_NORMAL_PLUS = 0x200; 121*0b57cec5SDimitry Andric const unsigned TDCMASK_NORMAL_MINUS = 0x100; 122*0b57cec5SDimitry Andric const unsigned TDCMASK_SUBNORMAL_PLUS = 0x080; 123*0b57cec5SDimitry Andric const unsigned TDCMASK_SUBNORMAL_MINUS = 0x040; 124*0b57cec5SDimitry Andric const unsigned TDCMASK_INFINITY_PLUS = 0x020; 125*0b57cec5SDimitry Andric const unsigned TDCMASK_INFINITY_MINUS = 0x010; 126*0b57cec5SDimitry Andric const unsigned TDCMASK_QNAN_PLUS = 0x008; 127*0b57cec5SDimitry Andric const unsigned TDCMASK_QNAN_MINUS = 0x004; 128*0b57cec5SDimitry Andric const unsigned TDCMASK_SNAN_PLUS = 0x002; 129*0b57cec5SDimitry Andric const unsigned TDCMASK_SNAN_MINUS = 0x001; 130*0b57cec5SDimitry Andric 131*0b57cec5SDimitry Andric const unsigned TDCMASK_ZERO = TDCMASK_ZERO_PLUS | TDCMASK_ZERO_MINUS; 132*0b57cec5SDimitry Andric const unsigned TDCMASK_POSITIVE = TDCMASK_NORMAL_PLUS | 133*0b57cec5SDimitry Andric TDCMASK_SUBNORMAL_PLUS | 134*0b57cec5SDimitry Andric TDCMASK_INFINITY_PLUS; 135*0b57cec5SDimitry Andric const unsigned TDCMASK_NEGATIVE = TDCMASK_NORMAL_MINUS | 136*0b57cec5SDimitry Andric TDCMASK_SUBNORMAL_MINUS | 137*0b57cec5SDimitry Andric TDCMASK_INFINITY_MINUS; 138*0b57cec5SDimitry Andric const unsigned TDCMASK_NAN = TDCMASK_QNAN_PLUS | 139*0b57cec5SDimitry Andric TDCMASK_QNAN_MINUS | 140*0b57cec5SDimitry Andric TDCMASK_SNAN_PLUS | 141*0b57cec5SDimitry Andric TDCMASK_SNAN_MINUS; 142*0b57cec5SDimitry Andric const unsigned TDCMASK_PLUS = TDCMASK_POSITIVE | 143*0b57cec5SDimitry Andric TDCMASK_ZERO_PLUS | 144*0b57cec5SDimitry Andric TDCMASK_QNAN_PLUS | 145*0b57cec5SDimitry Andric TDCMASK_SNAN_PLUS; 146*0b57cec5SDimitry Andric const unsigned TDCMASK_MINUS = TDCMASK_NEGATIVE | 147*0b57cec5SDimitry Andric TDCMASK_ZERO_MINUS | 148*0b57cec5SDimitry Andric TDCMASK_QNAN_MINUS | 149*0b57cec5SDimitry Andric TDCMASK_SNAN_MINUS; 150*0b57cec5SDimitry Andric const unsigned TDCMASK_ALL = TDCMASK_PLUS | TDCMASK_MINUS; 151*0b57cec5SDimitry Andric 152*0b57cec5SDimitry Andric // Number of bits in a vector register. 153*0b57cec5SDimitry Andric const unsigned VectorBits = 128; 154*0b57cec5SDimitry Andric 155*0b57cec5SDimitry Andric // Number of bytes in a vector register (and consequently the number of 156*0b57cec5SDimitry Andric // bytes in a general permute vector). 157*0b57cec5SDimitry Andric const unsigned VectorBytes = VectorBits / 8; 158*0b57cec5SDimitry Andric 159*0b57cec5SDimitry Andric // Return true if Val fits an LLILL operand. 160*0b57cec5SDimitry Andric static inline bool isImmLL(uint64_t Val) { 161*0b57cec5SDimitry Andric return (Val & ~0x000000000000ffffULL) == 0; 162*0b57cec5SDimitry Andric } 163*0b57cec5SDimitry Andric 164*0b57cec5SDimitry Andric // Return true if Val fits an LLILH operand. 165*0b57cec5SDimitry Andric static inline bool isImmLH(uint64_t Val) { 166*0b57cec5SDimitry Andric return (Val & ~0x00000000ffff0000ULL) == 0; 167*0b57cec5SDimitry Andric } 168*0b57cec5SDimitry Andric 169*0b57cec5SDimitry Andric // Return true if Val fits an LLIHL operand. 170*0b57cec5SDimitry Andric static inline bool isImmHL(uint64_t Val) { 171*0b57cec5SDimitry Andric return (Val & ~0x00000ffff00000000ULL) == 0; 172*0b57cec5SDimitry Andric } 173*0b57cec5SDimitry Andric 174*0b57cec5SDimitry Andric // Return true if Val fits an LLIHH operand. 175*0b57cec5SDimitry Andric static inline bool isImmHH(uint64_t Val) { 176*0b57cec5SDimitry Andric return (Val & ~0xffff000000000000ULL) == 0; 177*0b57cec5SDimitry Andric } 178*0b57cec5SDimitry Andric 179*0b57cec5SDimitry Andric // Return true if Val fits an LLILF operand. 180*0b57cec5SDimitry Andric static inline bool isImmLF(uint64_t Val) { 181*0b57cec5SDimitry Andric return (Val & ~0x00000000ffffffffULL) == 0; 182*0b57cec5SDimitry Andric } 183*0b57cec5SDimitry Andric 184*0b57cec5SDimitry Andric // Return true if Val fits an LLIHF operand. 185*0b57cec5SDimitry Andric static inline bool isImmHF(uint64_t Val) { 186*0b57cec5SDimitry Andric return (Val & ~0xffffffff00000000ULL) == 0; 187*0b57cec5SDimitry Andric } 188*0b57cec5SDimitry Andric } // end namespace SystemZ 189*0b57cec5SDimitry Andric 190*0b57cec5SDimitry Andric FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM, 191*0b57cec5SDimitry Andric CodeGenOpt::Level OptLevel); 192*0b57cec5SDimitry Andric FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM); 193*0b57cec5SDimitry Andric FunctionPass *createSystemZExpandPseudoPass(SystemZTargetMachine &TM); 194*0b57cec5SDimitry Andric FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM); 195*0b57cec5SDimitry Andric FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM); 196*0b57cec5SDimitry Andric FunctionPass *createSystemZLDCleanupPass(SystemZTargetMachine &TM); 197*0b57cec5SDimitry Andric FunctionPass *createSystemZPostRewritePass(SystemZTargetMachine &TM); 198*0b57cec5SDimitry Andric FunctionPass *createSystemZTDCPass(); 199*0b57cec5SDimitry Andric } // end namespace llvm 200*0b57cec5SDimitry Andric 201*0b57cec5SDimitry Andric #endif 202