blob: 051ba1dcfb661e62cfabcdcbf82e15aa690dc623 [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
15#ifndef SYSTEMZ_H
16#define SYSTEMZ_H
17
18#include "MCTargetDesc/SystemZMCTargetDesc.h"
19#include "llvm/Support/CodeGen.h"
20
21namespace 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
Richard Sandiford3d768e32013-07-31 12:30:20 +000033 // Condition-code mask assignments for integer and floating-point
34 // comparisons.
Ulrich Weigand5f613df2013-05-06 16:15:19 +000035 const unsigned CCMASK_CMP_EQ = CCMASK_0;
36 const unsigned CCMASK_CMP_LT = CCMASK_1;
37 const unsigned CCMASK_CMP_GT = CCMASK_2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000038 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;
Richard Sandiford3d768e32013-07-31 12:30:20 +000041
42 // Condition-code mask assignments for floating-point comparisons only.
43 const unsigned CCMASK_CMP_UO = CCMASK_3;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000044 const unsigned CCMASK_CMP_O = CCMASK_ANY ^ CCMASK_CMP_UO;
45
Richard Sandiford3d768e32013-07-31 12:30:20 +000046 // 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
Richard Sandiford6f6d5512013-08-20 09:38:48 +000055 // 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
Richard Sandiford35b9be22013-08-28 10:31:43 +000060 // 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 = CCMASK_ANY;
66
Richard Sandiford03481332013-08-23 11:36:42 +000067 // Mask assignments for PFD.
68 const unsigned PFD_READ = 1;
69 const unsigned PFD_WRITE = 2;
70
Ulrich Weigand5f613df2013-05-06 16:15:19 +000071 // Return true if Val fits an LLILL operand.
72 static inline bool isImmLL(uint64_t Val) {
73 return (Val & ~0x000000000000ffffULL) == 0;
74 }
75
76 // Return true if Val fits an LLILH operand.
77 static inline bool isImmLH(uint64_t Val) {
78 return (Val & ~0x00000000ffff0000ULL) == 0;
79 }
80
81 // Return true if Val fits an LLIHL operand.
82 static inline bool isImmHL(uint64_t Val) {
83 return (Val & ~0x00000ffff00000000ULL) == 0;
84 }
85
86 // Return true if Val fits an LLIHH operand.
87 static inline bool isImmHH(uint64_t Val) {
88 return (Val & ~0xffff000000000000ULL) == 0;
89 }
90
91 // Return true if Val fits an LLILF operand.
92 static inline bool isImmLF(uint64_t Val) {
93 return (Val & ~0x00000000ffffffffULL) == 0;
94 }
95
96 // Return true if Val fits an LLIHF operand.
97 static inline bool isImmHF(uint64_t Val) {
98 return (Val & ~0xffffffff00000000ULL) == 0;
99 }
100 }
101
102 FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
103 CodeGenOpt::Level OptLevel);
Richard Sandifordbdbb8af2013-08-05 10:58:53 +0000104 FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM);
Richard Sandiford312425f2013-05-20 14:23:08 +0000105 FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM);
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000106} // end namespace llvm;
107#endif