blob: 9a8e508e411919ff6862b1a9789da99b797fe432 [file] [log] [blame]
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001//==- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
16#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZ_H
Ulrich Weigand5f613df2013-05-06 16:15:19 +000017
18#include "MCTargetDesc/SystemZMCTargetDesc.h"
19#include "llvm/Support/CodeGen.h"
20
21namespace llvm {
Richard Sandifordc2312692014-03-06 10:38:30 +000022class SystemZTargetMachine;
23class FunctionPass;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000024
Richard Sandifordc2312692014-03-06 10:38:30 +000025namespace SystemZ {
26// Condition-code mask values.
27const unsigned CCMASK_0 = 1 << 3;
28const unsigned CCMASK_1 = 1 << 2;
29const unsigned CCMASK_2 = 1 << 1;
30const unsigned CCMASK_3 = 1 << 0;
31const unsigned CCMASK_ANY = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000032
Richard Sandifordc2312692014-03-06 10:38:30 +000033// Condition-code mask assignments for integer and floating-point
34// comparisons.
35const unsigned CCMASK_CMP_EQ = CCMASK_0;
36const unsigned CCMASK_CMP_LT = CCMASK_1;
37const unsigned CCMASK_CMP_GT = CCMASK_2;
38const unsigned CCMASK_CMP_NE = CCMASK_CMP_LT | CCMASK_CMP_GT;
39const unsigned CCMASK_CMP_LE = CCMASK_CMP_EQ | CCMASK_CMP_LT;
40const unsigned CCMASK_CMP_GE = CCMASK_CMP_EQ | CCMASK_CMP_GT;
Richard Sandiford3d768e32013-07-31 12:30:20 +000041
Richard Sandifordc2312692014-03-06 10:38:30 +000042// Condition-code mask assignments for floating-point comparisons only.
43const unsigned CCMASK_CMP_UO = CCMASK_3;
44const unsigned CCMASK_CMP_O = CCMASK_ANY ^ CCMASK_CMP_UO;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000045
Richard Sandifordc2312692014-03-06 10:38:30 +000046// All condition-code values produced by comparisons.
47const unsigned CCMASK_ICMP = CCMASK_0 | CCMASK_1 | CCMASK_2;
48const unsigned CCMASK_FCMP = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
Richard Sandiford3d768e32013-07-31 12:30:20 +000049
Richard Sandifordc2312692014-03-06 10:38:30 +000050// Condition-code mask assignments for CS.
51const unsigned CCMASK_CS_EQ = CCMASK_0;
52const unsigned CCMASK_CS_NE = CCMASK_1;
53const unsigned CCMASK_CS = CCMASK_0 | CCMASK_1;
Richard Sandiford3d768e32013-07-31 12:30:20 +000054
Richard Sandifordc2312692014-03-06 10:38:30 +000055// Condition-code mask assignments for a completed SRST loop.
56const unsigned CCMASK_SRST_FOUND = CCMASK_1;
57const unsigned CCMASK_SRST_NOTFOUND = CCMASK_2;
58const unsigned CCMASK_SRST = CCMASK_1 | CCMASK_2;
Richard Sandiford6f6d5512013-08-20 09:38:48 +000059
Richard Sandifordc2312692014-03-06 10:38:30 +000060// Condition-code mask assignments for TEST UNDER MASK.
61const unsigned CCMASK_TM_ALL_0 = CCMASK_0;
62const unsigned CCMASK_TM_MIXED_MSB_0 = CCMASK_1;
63const unsigned CCMASK_TM_MIXED_MSB_1 = CCMASK_2;
64const unsigned CCMASK_TM_ALL_1 = CCMASK_3;
65const unsigned CCMASK_TM_SOME_0 = CCMASK_TM_ALL_1 ^ CCMASK_ANY;
66const unsigned CCMASK_TM_SOME_1 = CCMASK_TM_ALL_0 ^ CCMASK_ANY;
67const unsigned CCMASK_TM_MSB_0 = CCMASK_0 | CCMASK_1;
68const unsigned CCMASK_TM_MSB_1 = CCMASK_2 | CCMASK_3;
69const unsigned CCMASK_TM = CCMASK_ANY;
Richard Sandiford35b9be22013-08-28 10:31:43 +000070
Ulrich Weigand57c85f52015-04-01 12:51:43 +000071// Condition-code mask assignments for TRANSACTION_BEGIN.
72const unsigned CCMASK_TBEGIN_STARTED = CCMASK_0;
73const unsigned CCMASK_TBEGIN_INDETERMINATE = CCMASK_1;
74const unsigned CCMASK_TBEGIN_TRANSIENT = CCMASK_2;
75const unsigned CCMASK_TBEGIN_PERSISTENT = CCMASK_3;
76const unsigned CCMASK_TBEGIN = CCMASK_ANY;
77
78// Condition-code mask assignments for TRANSACTION_END.
79const unsigned CCMASK_TEND_TX = CCMASK_0;
80const unsigned CCMASK_TEND_NOTX = CCMASK_2;
81const unsigned CCMASK_TEND = CCMASK_TEND_TX | CCMASK_TEND_NOTX;
82
Ulrich Weigandc1708b22015-05-05 19:31:09 +000083// Condition-code mask assignments for vector comparisons (and similar
84// operations).
85const unsigned CCMASK_VCMP_ALL = CCMASK_0;
86const unsigned CCMASK_VCMP_MIXED = CCMASK_1;
87const unsigned CCMASK_VCMP_NONE = CCMASK_3;
88const unsigned CCMASK_VCMP = CCMASK_0 | CCMASK_1 | CCMASK_3;
89
Marcin Koscielnickicf7cc722016-07-10 14:41:22 +000090// Condition-code mask assignments for Test Data Class.
91const unsigned CCMASK_TDC_NOMATCH = CCMASK_0;
92const unsigned CCMASK_TDC_MATCH = CCMASK_1;
93const unsigned CCMASK_TDC = CCMASK_TDC_NOMATCH | CCMASK_TDC_MATCH;
94
Richard Sandifordc2312692014-03-06 10:38:30 +000095// The position of the low CC bit in an IPM result.
96const unsigned IPM_CC = 28;
Richard Sandifordf722a8e302013-10-16 11:10:55 +000097
Richard Sandifordc2312692014-03-06 10:38:30 +000098// Mask assignments for PFD.
99const unsigned PFD_READ = 1;
100const unsigned PFD_WRITE = 2;
Richard Sandiford03481332013-08-23 11:36:42 +0000101
Marcin Koscielnickicf7cc722016-07-10 14:41:22 +0000102// Mask assignments for TDC
103const unsigned TDCMASK_ZERO_PLUS = 0x800;
104const unsigned TDCMASK_ZERO_MINUS = 0x400;
105const unsigned TDCMASK_NORMAL_PLUS = 0x200;
106const unsigned TDCMASK_NORMAL_MINUS = 0x100;
107const unsigned TDCMASK_SUBNORMAL_PLUS = 0x080;
108const unsigned TDCMASK_SUBNORMAL_MINUS = 0x040;
109const unsigned TDCMASK_INFINITY_PLUS = 0x020;
110const unsigned TDCMASK_INFINITY_MINUS = 0x010;
111const unsigned TDCMASK_QNAN_PLUS = 0x008;
112const unsigned TDCMASK_QNAN_MINUS = 0x004;
113const unsigned TDCMASK_SNAN_PLUS = 0x002;
114const unsigned TDCMASK_SNAN_MINUS = 0x001;
115
116const unsigned TDCMASK_ZERO = TDCMASK_ZERO_PLUS | TDCMASK_ZERO_MINUS;
117const unsigned TDCMASK_POSITIVE = TDCMASK_NORMAL_PLUS |
118 TDCMASK_SUBNORMAL_PLUS |
119 TDCMASK_INFINITY_PLUS;
120const unsigned TDCMASK_NEGATIVE = TDCMASK_NORMAL_MINUS |
121 TDCMASK_SUBNORMAL_MINUS |
122 TDCMASK_INFINITY_MINUS;
123const unsigned TDCMASK_NAN = TDCMASK_QNAN_PLUS |
124 TDCMASK_QNAN_MINUS |
125 TDCMASK_SNAN_PLUS |
126 TDCMASK_SNAN_MINUS;
127const unsigned TDCMASK_PLUS = TDCMASK_POSITIVE |
128 TDCMASK_ZERO_PLUS |
129 TDCMASK_QNAN_PLUS |
130 TDCMASK_SNAN_PLUS;
131const unsigned TDCMASK_MINUS = TDCMASK_NEGATIVE |
132 TDCMASK_ZERO_MINUS |
133 TDCMASK_QNAN_MINUS |
134 TDCMASK_SNAN_MINUS;
135const unsigned TDCMASK_ALL = TDCMASK_PLUS | TDCMASK_MINUS;
136
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000137// Number of bits in a vector register.
138const unsigned VectorBits = 128;
139
140// Number of bytes in a vector register (and consequently the number of
141// bytes in a general permute vector).
142const unsigned VectorBytes = VectorBits / 8;
143
Richard Sandifordc2312692014-03-06 10:38:30 +0000144// Return true if Val fits an LLILL operand.
145static inline bool isImmLL(uint64_t Val) {
146 return (Val & ~0x000000000000ffffULL) == 0;
147}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000148
Richard Sandifordc2312692014-03-06 10:38:30 +0000149// Return true if Val fits an LLILH operand.
150static inline bool isImmLH(uint64_t Val) {
151 return (Val & ~0x00000000ffff0000ULL) == 0;
152}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000153
Richard Sandifordc2312692014-03-06 10:38:30 +0000154// Return true if Val fits an LLIHL operand.
155static inline bool isImmHL(uint64_t Val) {
156 return (Val & ~0x00000ffff00000000ULL) == 0;
157}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000158
Richard Sandifordc2312692014-03-06 10:38:30 +0000159// Return true if Val fits an LLIHH operand.
160static inline bool isImmHH(uint64_t Val) {
161 return (Val & ~0xffff000000000000ULL) == 0;
162}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000163
Richard Sandifordc2312692014-03-06 10:38:30 +0000164// Return true if Val fits an LLILF operand.
165static inline bool isImmLF(uint64_t Val) {
166 return (Val & ~0x00000000ffffffffULL) == 0;
167}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000168
Richard Sandifordc2312692014-03-06 10:38:30 +0000169// Return true if Val fits an LLIHF operand.
170static inline bool isImmHF(uint64_t Val) {
171 return (Val & ~0xffffffff00000000ULL) == 0;
172}
173} // end namespace SystemZ
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000174
Richard Sandifordc2312692014-03-06 10:38:30 +0000175FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
176 CodeGenOpt::Level OptLevel);
177FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM);
Ulrich Weigand524f2762016-11-28 13:34:08 +0000178FunctionPass *createSystemZExpandPseudoPass(SystemZTargetMachine &TM);
Richard Sandifordc2312692014-03-06 10:38:30 +0000179FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM);
180FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM);
Ulrich Weigand7db69182015-02-18 09:13:27 +0000181FunctionPass *createSystemZLDCleanupPass(SystemZTargetMachine &TM);
Marcin Koscielnickicf7cc722016-07-10 14:41:22 +0000182FunctionPass *createSystemZTDCPass();
Richard Sandifordc2312692014-03-06 10:38:30 +0000183} // end namespace llvm
184
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000185#endif