xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZ.h (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
10b57cec5SDimitry Andric //==- SystemZ.h - Top-Level Interface for SystemZ representation -*- C++ -*-==//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file contains the entry points for global functions defined in
100b57cec5SDimitry Andric // the LLVM SystemZ backend.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "MCTargetDesc/SystemZMCTargetDesc.h"
180b57cec5SDimitry Andric #include "llvm/Support/CodeGen.h"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric namespace llvm {
210b57cec5SDimitry Andric class SystemZTargetMachine;
220b57cec5SDimitry Andric class FunctionPass;
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric namespace SystemZ {
250b57cec5SDimitry Andric // Condition-code mask values.
260b57cec5SDimitry Andric const unsigned CCMASK_0 = 1 << 3;
270b57cec5SDimitry Andric const unsigned CCMASK_1 = 1 << 2;
280b57cec5SDimitry Andric const unsigned CCMASK_2 = 1 << 1;
290b57cec5SDimitry Andric const unsigned CCMASK_3 = 1 << 0;
300b57cec5SDimitry Andric const unsigned CCMASK_ANY = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric // Condition-code mask assignments for integer and floating-point
330b57cec5SDimitry Andric // comparisons.
340b57cec5SDimitry Andric const unsigned CCMASK_CMP_EQ = CCMASK_0;
350b57cec5SDimitry Andric const unsigned CCMASK_CMP_LT = CCMASK_1;
360b57cec5SDimitry Andric const unsigned CCMASK_CMP_GT = CCMASK_2;
370b57cec5SDimitry Andric const unsigned CCMASK_CMP_NE = CCMASK_CMP_LT | CCMASK_CMP_GT;
380b57cec5SDimitry Andric const unsigned CCMASK_CMP_LE = CCMASK_CMP_EQ | CCMASK_CMP_LT;
390b57cec5SDimitry Andric const unsigned CCMASK_CMP_GE = CCMASK_CMP_EQ | CCMASK_CMP_GT;
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric // Condition-code mask assignments for floating-point comparisons only.
420b57cec5SDimitry Andric const unsigned CCMASK_CMP_UO = CCMASK_3;
430b57cec5SDimitry Andric const unsigned CCMASK_CMP_O  = CCMASK_ANY ^ CCMASK_CMP_UO;
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric // All condition-code values produced by comparisons.
460b57cec5SDimitry Andric const unsigned CCMASK_ICMP = CCMASK_0 | CCMASK_1 | CCMASK_2;
470b57cec5SDimitry Andric const unsigned CCMASK_FCMP = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric // Condition-code mask assignments for arithmetical operations.
500b57cec5SDimitry Andric const unsigned CCMASK_ARITH_EQ       = CCMASK_0;
510b57cec5SDimitry Andric const unsigned CCMASK_ARITH_LT       = CCMASK_1;
520b57cec5SDimitry Andric const unsigned CCMASK_ARITH_GT       = CCMASK_2;
530b57cec5SDimitry Andric const unsigned CCMASK_ARITH_OVERFLOW = CCMASK_3;
540b57cec5SDimitry Andric const unsigned CCMASK_ARITH          = CCMASK_ANY;
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric // Condition-code mask assignments for logical operations.
570b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_ZERO     = CCMASK_0 | CCMASK_2;
58480093f4SDimitry Andric const unsigned CCMASK_LOGICAL_NONZERO  = CCMASK_1 | CCMASK_3;
590b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_CARRY    = CCMASK_2 | CCMASK_3;
600b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_NOCARRY  = CCMASK_0 | CCMASK_1;
610b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_BORROW   = CCMASK_LOGICAL_NOCARRY;
620b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL_NOBORROW = CCMASK_LOGICAL_CARRY;
630b57cec5SDimitry Andric const unsigned CCMASK_LOGICAL          = CCMASK_ANY;
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric // Condition-code mask assignments for CS.
660b57cec5SDimitry Andric const unsigned CCMASK_CS_EQ = CCMASK_0;
670b57cec5SDimitry Andric const unsigned CCMASK_CS_NE = CCMASK_1;
680b57cec5SDimitry Andric const unsigned CCMASK_CS    = CCMASK_0 | CCMASK_1;
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric // Condition-code mask assignments for a completed SRST loop.
710b57cec5SDimitry Andric const unsigned CCMASK_SRST_FOUND    = CCMASK_1;
720b57cec5SDimitry Andric const unsigned CCMASK_SRST_NOTFOUND = CCMASK_2;
730b57cec5SDimitry Andric const unsigned CCMASK_SRST          = CCMASK_1 | CCMASK_2;
740b57cec5SDimitry Andric 
750b57cec5SDimitry Andric // Condition-code mask assignments for TEST UNDER MASK.
760b57cec5SDimitry Andric const unsigned CCMASK_TM_ALL_0       = CCMASK_0;
770b57cec5SDimitry Andric const unsigned CCMASK_TM_MIXED_MSB_0 = CCMASK_1;
780b57cec5SDimitry Andric const unsigned CCMASK_TM_MIXED_MSB_1 = CCMASK_2;
790b57cec5SDimitry Andric const unsigned CCMASK_TM_ALL_1       = CCMASK_3;
800b57cec5SDimitry Andric const unsigned CCMASK_TM_SOME_0      = CCMASK_TM_ALL_1 ^ CCMASK_ANY;
810b57cec5SDimitry Andric const unsigned CCMASK_TM_SOME_1      = CCMASK_TM_ALL_0 ^ CCMASK_ANY;
820b57cec5SDimitry Andric const unsigned CCMASK_TM_MSB_0       = CCMASK_0 | CCMASK_1;
830b57cec5SDimitry Andric const unsigned CCMASK_TM_MSB_1       = CCMASK_2 | CCMASK_3;
840b57cec5SDimitry Andric const unsigned CCMASK_TM             = CCMASK_ANY;
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric // Condition-code mask assignments for TRANSACTION_BEGIN.
870b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_STARTED       = CCMASK_0;
880b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_INDETERMINATE = CCMASK_1;
890b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_TRANSIENT     = CCMASK_2;
900b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN_PERSISTENT    = CCMASK_3;
910b57cec5SDimitry Andric const unsigned CCMASK_TBEGIN               = CCMASK_ANY;
920b57cec5SDimitry Andric 
930b57cec5SDimitry Andric // Condition-code mask assignments for TRANSACTION_END.
940b57cec5SDimitry Andric const unsigned CCMASK_TEND_TX   = CCMASK_0;
950b57cec5SDimitry Andric const unsigned CCMASK_TEND_NOTX = CCMASK_2;
960b57cec5SDimitry Andric const unsigned CCMASK_TEND      = CCMASK_TEND_TX | CCMASK_TEND_NOTX;
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric // Condition-code mask assignments for vector comparisons (and similar
990b57cec5SDimitry Andric // operations).
1000b57cec5SDimitry Andric const unsigned CCMASK_VCMP_ALL       = CCMASK_0;
1010b57cec5SDimitry Andric const unsigned CCMASK_VCMP_MIXED     = CCMASK_1;
1020b57cec5SDimitry Andric const unsigned CCMASK_VCMP_NONE      = CCMASK_3;
1030b57cec5SDimitry Andric const unsigned CCMASK_VCMP           = CCMASK_0 | CCMASK_1 | CCMASK_3;
1040b57cec5SDimitry Andric 
1050b57cec5SDimitry Andric // Condition-code mask assignments for Test Data Class.
1060b57cec5SDimitry Andric const unsigned CCMASK_TDC_NOMATCH   = CCMASK_0;
1070b57cec5SDimitry Andric const unsigned CCMASK_TDC_MATCH     = CCMASK_1;
1080b57cec5SDimitry Andric const unsigned CCMASK_TDC           = CCMASK_TDC_NOMATCH | CCMASK_TDC_MATCH;
1090b57cec5SDimitry Andric 
1100b57cec5SDimitry Andric // The position of the low CC bit in an IPM result.
1110b57cec5SDimitry Andric const unsigned IPM_CC = 28;
1120b57cec5SDimitry Andric 
1130b57cec5SDimitry Andric // Mask assignments for PFD.
1140b57cec5SDimitry Andric const unsigned PFD_READ  = 1;
1150b57cec5SDimitry Andric const unsigned PFD_WRITE = 2;
1160b57cec5SDimitry Andric 
1170b57cec5SDimitry Andric // Mask assignments for TDC
1180b57cec5SDimitry Andric const unsigned TDCMASK_ZERO_PLUS       = 0x800;
1190b57cec5SDimitry Andric const unsigned TDCMASK_ZERO_MINUS      = 0x400;
1200b57cec5SDimitry Andric const unsigned TDCMASK_NORMAL_PLUS     = 0x200;
1210b57cec5SDimitry Andric const unsigned TDCMASK_NORMAL_MINUS    = 0x100;
1220b57cec5SDimitry Andric const unsigned TDCMASK_SUBNORMAL_PLUS  = 0x080;
1230b57cec5SDimitry Andric const unsigned TDCMASK_SUBNORMAL_MINUS = 0x040;
1240b57cec5SDimitry Andric const unsigned TDCMASK_INFINITY_PLUS   = 0x020;
1250b57cec5SDimitry Andric const unsigned TDCMASK_INFINITY_MINUS  = 0x010;
1260b57cec5SDimitry Andric const unsigned TDCMASK_QNAN_PLUS       = 0x008;
1270b57cec5SDimitry Andric const unsigned TDCMASK_QNAN_MINUS      = 0x004;
1280b57cec5SDimitry Andric const unsigned TDCMASK_SNAN_PLUS       = 0x002;
1290b57cec5SDimitry Andric const unsigned TDCMASK_SNAN_MINUS      = 0x001;
1300b57cec5SDimitry Andric 
1310b57cec5SDimitry Andric const unsigned TDCMASK_ZERO            = TDCMASK_ZERO_PLUS | TDCMASK_ZERO_MINUS;
1320b57cec5SDimitry Andric const unsigned TDCMASK_POSITIVE        = TDCMASK_NORMAL_PLUS |
1330b57cec5SDimitry Andric                                          TDCMASK_SUBNORMAL_PLUS |
1340b57cec5SDimitry Andric                                          TDCMASK_INFINITY_PLUS;
1350b57cec5SDimitry Andric const unsigned TDCMASK_NEGATIVE        = TDCMASK_NORMAL_MINUS |
1360b57cec5SDimitry Andric                                          TDCMASK_SUBNORMAL_MINUS |
1370b57cec5SDimitry Andric                                          TDCMASK_INFINITY_MINUS;
1380b57cec5SDimitry Andric const unsigned TDCMASK_NAN             = TDCMASK_QNAN_PLUS |
1390b57cec5SDimitry Andric                                          TDCMASK_QNAN_MINUS |
1400b57cec5SDimitry Andric                                          TDCMASK_SNAN_PLUS |
1410b57cec5SDimitry Andric                                          TDCMASK_SNAN_MINUS;
1420b57cec5SDimitry Andric const unsigned TDCMASK_PLUS            = TDCMASK_POSITIVE |
1430b57cec5SDimitry Andric                                          TDCMASK_ZERO_PLUS |
1440b57cec5SDimitry Andric                                          TDCMASK_QNAN_PLUS |
1450b57cec5SDimitry Andric                                          TDCMASK_SNAN_PLUS;
1460b57cec5SDimitry Andric const unsigned TDCMASK_MINUS           = TDCMASK_NEGATIVE |
1470b57cec5SDimitry Andric                                          TDCMASK_ZERO_MINUS |
1480b57cec5SDimitry Andric                                          TDCMASK_QNAN_MINUS |
1490b57cec5SDimitry Andric                                          TDCMASK_SNAN_MINUS;
1500b57cec5SDimitry Andric const unsigned TDCMASK_ALL             = TDCMASK_PLUS | TDCMASK_MINUS;
1510b57cec5SDimitry Andric 
1520b57cec5SDimitry Andric // Number of bits in a vector register.
1530b57cec5SDimitry Andric const unsigned VectorBits = 128;
1540b57cec5SDimitry Andric 
1550b57cec5SDimitry Andric // Number of bytes in a vector register (and consequently the number of
1560b57cec5SDimitry Andric // bytes in a general permute vector).
1570b57cec5SDimitry Andric const unsigned VectorBytes = VectorBits / 8;
1580b57cec5SDimitry Andric 
1590b57cec5SDimitry Andric // Return true if Val fits an LLILL operand.
1600b57cec5SDimitry Andric static inline bool isImmLL(uint64_t Val) {
1610b57cec5SDimitry Andric   return (Val & ~0x000000000000ffffULL) == 0;
1620b57cec5SDimitry Andric }
1630b57cec5SDimitry Andric 
1640b57cec5SDimitry Andric // Return true if Val fits an LLILH operand.
1650b57cec5SDimitry Andric static inline bool isImmLH(uint64_t Val) {
1660b57cec5SDimitry Andric   return (Val & ~0x00000000ffff0000ULL) == 0;
1670b57cec5SDimitry Andric }
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric // Return true if Val fits an LLIHL operand.
1700b57cec5SDimitry Andric static inline bool isImmHL(uint64_t Val) {
1710b57cec5SDimitry Andric   return (Val & ~0x00000ffff00000000ULL) == 0;
1720b57cec5SDimitry Andric }
1730b57cec5SDimitry Andric 
1740b57cec5SDimitry Andric // Return true if Val fits an LLIHH operand.
1750b57cec5SDimitry Andric static inline bool isImmHH(uint64_t Val) {
1760b57cec5SDimitry Andric   return (Val & ~0xffff000000000000ULL) == 0;
1770b57cec5SDimitry Andric }
1780b57cec5SDimitry Andric 
1790b57cec5SDimitry Andric // Return true if Val fits an LLILF operand.
1800b57cec5SDimitry Andric static inline bool isImmLF(uint64_t Val) {
1810b57cec5SDimitry Andric   return (Val & ~0x00000000ffffffffULL) == 0;
1820b57cec5SDimitry Andric }
1830b57cec5SDimitry Andric 
1840b57cec5SDimitry Andric // Return true if Val fits an LLIHF operand.
1850b57cec5SDimitry Andric static inline bool isImmHF(uint64_t Val) {
1860b57cec5SDimitry Andric   return (Val & ~0xffffffff00000000ULL) == 0;
1870b57cec5SDimitry Andric }
1880b57cec5SDimitry Andric } // end namespace SystemZ
1890b57cec5SDimitry Andric 
1900b57cec5SDimitry Andric FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
1910b57cec5SDimitry Andric                                    CodeGenOpt::Level OptLevel);
1920b57cec5SDimitry Andric FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM);
1930b57cec5SDimitry Andric FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM);
1940b57cec5SDimitry Andric FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM);
1950b57cec5SDimitry Andric FunctionPass *createSystemZLDCleanupPass(SystemZTargetMachine &TM);
196*5ffd83dbSDimitry Andric FunctionPass *createSystemZCopyPhysRegsPass(SystemZTargetMachine &TM);
1970b57cec5SDimitry Andric FunctionPass *createSystemZPostRewritePass(SystemZTargetMachine &TM);
1980b57cec5SDimitry Andric FunctionPass *createSystemZTDCPass();
1990b57cec5SDimitry Andric } // end namespace llvm
2000b57cec5SDimitry Andric 
2010b57cec5SDimitry Andric #endif
202