1 //==- SystemZ.h - Top-Level Interface for SystemZ representation -*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the entry points for global functions defined in
11 // the LLVM SystemZ backend.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
16 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
17 
18 #include "MCTargetDesc/SystemZMCTargetDesc.h"
19 #include "llvm/Support/CodeGen.h"
20 
21 namespace llvm {
22 class SystemZTargetMachine;
23 class FunctionPass;
24 
25 namespace SystemZ {
26 // Condition-code mask values.
27 const unsigned CCMASK_0 = 1 << 3;
28 const unsigned CCMASK_1 = 1 << 2;
29 const unsigned CCMASK_2 = 1 << 1;
30 const unsigned CCMASK_3 = 1 << 0;
31 const unsigned CCMASK_ANY = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
32 
33 // Condition-code mask assignments for integer and floating-point
34 // comparisons.
35 const unsigned CCMASK_CMP_EQ = CCMASK_0;
36 const unsigned CCMASK_CMP_LT = CCMASK_1;
37 const unsigned CCMASK_CMP_GT = CCMASK_2;
38 const unsigned CCMASK_CMP_NE = CCMASK_CMP_LT | CCMASK_CMP_GT;
39 const unsigned CCMASK_CMP_LE = CCMASK_CMP_EQ | CCMASK_CMP_LT;
40 const unsigned CCMASK_CMP_GE = CCMASK_CMP_EQ | CCMASK_CMP_GT;
41 
42 // Condition-code mask assignments for floating-point comparisons only.
43 const unsigned CCMASK_CMP_UO = CCMASK_3;
44 const unsigned CCMASK_CMP_O  = CCMASK_ANY ^ CCMASK_CMP_UO;
45 
46 // All condition-code values produced by comparisons.
47 const unsigned CCMASK_ICMP = CCMASK_0 | CCMASK_1 | CCMASK_2;
48 const unsigned CCMASK_FCMP = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
49 
50 // Condition-code mask assignments for CS.
51 const unsigned CCMASK_CS_EQ = CCMASK_0;
52 const unsigned CCMASK_CS_NE = CCMASK_1;
53 const unsigned CCMASK_CS    = CCMASK_0 | CCMASK_1;
54 
55 // Condition-code mask assignments for a completed SRST loop.
56 const unsigned CCMASK_SRST_FOUND    = CCMASK_1;
57 const unsigned CCMASK_SRST_NOTFOUND = CCMASK_2;
58 const unsigned CCMASK_SRST          = CCMASK_1 | CCMASK_2;
59 
60 // Condition-code mask assignments for TEST UNDER MASK.
61 const unsigned CCMASK_TM_ALL_0       = CCMASK_0;
62 const unsigned CCMASK_TM_MIXED_MSB_0 = CCMASK_1;
63 const unsigned CCMASK_TM_MIXED_MSB_1 = CCMASK_2;
64 const unsigned CCMASK_TM_ALL_1       = CCMASK_3;
65 const unsigned CCMASK_TM_SOME_0      = CCMASK_TM_ALL_1 ^ CCMASK_ANY;
66 const unsigned CCMASK_TM_SOME_1      = CCMASK_TM_ALL_0 ^ CCMASK_ANY;
67 const unsigned CCMASK_TM_MSB_0       = CCMASK_0 | CCMASK_1;
68 const unsigned CCMASK_TM_MSB_1       = CCMASK_2 | CCMASK_3;
69 const unsigned CCMASK_TM             = CCMASK_ANY;
70 
71 // Condition-code mask assignments for TRANSACTION_BEGIN.
72 const unsigned CCMASK_TBEGIN_STARTED       = CCMASK_0;
73 const unsigned CCMASK_TBEGIN_INDETERMINATE = CCMASK_1;
74 const unsigned CCMASK_TBEGIN_TRANSIENT     = CCMASK_2;
75 const unsigned CCMASK_TBEGIN_PERSISTENT    = CCMASK_3;
76 const unsigned CCMASK_TBEGIN               = CCMASK_ANY;
77 
78 // Condition-code mask assignments for TRANSACTION_END.
79 const unsigned CCMASK_TEND_TX   = CCMASK_0;
80 const unsigned CCMASK_TEND_NOTX = CCMASK_2;
81 const unsigned CCMASK_TEND      = CCMASK_TEND_TX | CCMASK_TEND_NOTX;
82 
83 // The position of the low CC bit in an IPM result.
84 const unsigned IPM_CC = 28;
85 
86 // Mask assignments for PFD.
87 const unsigned PFD_READ  = 1;
88 const unsigned PFD_WRITE = 2;
89 
90 // Return true if Val fits an LLILL operand.
isImmLL(uint64_t Val)91 static inline bool isImmLL(uint64_t Val) {
92   return (Val & ~0x000000000000ffffULL) == 0;
93 }
94 
95 // Return true if Val fits an LLILH operand.
isImmLH(uint64_t Val)96 static inline bool isImmLH(uint64_t Val) {
97   return (Val & ~0x00000000ffff0000ULL) == 0;
98 }
99 
100 // Return true if Val fits an LLIHL operand.
isImmHL(uint64_t Val)101 static inline bool isImmHL(uint64_t Val) {
102   return (Val & ~0x00000ffff00000000ULL) == 0;
103 }
104 
105 // Return true if Val fits an LLIHH operand.
isImmHH(uint64_t Val)106 static inline bool isImmHH(uint64_t Val) {
107   return (Val & ~0xffff000000000000ULL) == 0;
108 }
109 
110 // Return true if Val fits an LLILF operand.
isImmLF(uint64_t Val)111 static inline bool isImmLF(uint64_t Val) {
112   return (Val & ~0x00000000ffffffffULL) == 0;
113 }
114 
115 // Return true if Val fits an LLIHF operand.
isImmHF(uint64_t Val)116 static inline bool isImmHF(uint64_t Val) {
117   return (Val & ~0xffffffff00000000ULL) == 0;
118 }
119 } // end namespace SystemZ
120 
121 FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
122                                    CodeGenOpt::Level OptLevel);
123 FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM);
124 FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM);
125 FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM);
126 FunctionPass *createSystemZLDCleanupPass(SystemZTargetMachine &TM);
127 } // end namespace llvm
128 
129 #endif
130