1251607Sdim//==- SystemZ.h - Top-Level Interface for SystemZ representation -*- C++ -*-==//
2251607Sdim//
3251607Sdim//                     The LLVM Compiler Infrastructure
4251607Sdim//
5251607Sdim// This file is distributed under the University of Illinois Open Source
6251607Sdim// License. See LICENSE.TXT for details.
7251607Sdim//
8251607Sdim//===----------------------------------------------------------------------===//
9251607Sdim//
10251607Sdim// This file contains the entry points for global functions defined in
11251607Sdim// the LLVM SystemZ backend.
12251607Sdim//
13251607Sdim//===----------------------------------------------------------------------===//
14251607Sdim
15251607Sdim#ifndef SYSTEMZ_H
16251607Sdim#define SYSTEMZ_H
17251607Sdim
18251607Sdim#include "MCTargetDesc/SystemZMCTargetDesc.h"
19251607Sdim#include "llvm/Support/CodeGen.h"
20251607Sdim
21251607Sdimnamespace llvm {
22251607Sdim  class SystemZTargetMachine;
23251607Sdim  class FunctionPass;
24251607Sdim
25251607Sdim  namespace SystemZ {
26251607Sdim    // Condition-code mask values.
27251607Sdim    const unsigned CCMASK_0 = 1 << 3;
28251607Sdim    const unsigned CCMASK_1 = 1 << 2;
29251607Sdim    const unsigned CCMASK_2 = 1 << 1;
30251607Sdim    const unsigned CCMASK_3 = 1 << 0;
31251607Sdim    const unsigned CCMASK_ANY = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
32251607Sdim
33263508Sdim    // Condition-code mask assignments for integer and floating-point
34263508Sdim    // comparisons.
35251607Sdim    const unsigned CCMASK_CMP_EQ = CCMASK_0;
36251607Sdim    const unsigned CCMASK_CMP_LT = CCMASK_1;
37251607Sdim    const unsigned CCMASK_CMP_GT = CCMASK_2;
38251607Sdim    const unsigned CCMASK_CMP_NE = CCMASK_CMP_LT | CCMASK_CMP_GT;
39251607Sdim    const unsigned CCMASK_CMP_LE = CCMASK_CMP_EQ | CCMASK_CMP_LT;
40251607Sdim    const unsigned CCMASK_CMP_GE = CCMASK_CMP_EQ | CCMASK_CMP_GT;
41263508Sdim
42263508Sdim    // Condition-code mask assignments for floating-point comparisons only.
43263508Sdim    const unsigned CCMASK_CMP_UO = CCMASK_3;
44251607Sdim    const unsigned CCMASK_CMP_O  = CCMASK_ANY ^ CCMASK_CMP_UO;
45251607Sdim
46263508Sdim    // All condition-code values produced by comparisons.
47263508Sdim    const unsigned CCMASK_ICMP = CCMASK_0 | CCMASK_1 | CCMASK_2;
48263508Sdim    const unsigned CCMASK_FCMP = CCMASK_0 | CCMASK_1 | CCMASK_2 | CCMASK_3;
49263508Sdim
50263508Sdim    // Condition-code mask assignments for CS.
51263508Sdim    const unsigned CCMASK_CS_EQ = CCMASK_0;
52263508Sdim    const unsigned CCMASK_CS_NE = CCMASK_1;
53263508Sdim    const unsigned CCMASK_CS    = CCMASK_0 | CCMASK_1;
54263508Sdim
55263508Sdim    // Condition-code mask assignments for a completed SRST loop.
56263508Sdim    const unsigned CCMASK_SRST_FOUND    = CCMASK_1;
57263508Sdim    const unsigned CCMASK_SRST_NOTFOUND = CCMASK_2;
58263508Sdim    const unsigned CCMASK_SRST          = CCMASK_1 | CCMASK_2;
59263508Sdim
60263508Sdim    // Condition-code mask assignments for TEST UNDER MASK.
61263508Sdim    const unsigned CCMASK_TM_ALL_0       = CCMASK_0;
62263508Sdim    const unsigned CCMASK_TM_MIXED_MSB_0 = CCMASK_1;
63263508Sdim    const unsigned CCMASK_TM_MIXED_MSB_1 = CCMASK_2;
64263508Sdim    const unsigned CCMASK_TM_ALL_1       = CCMASK_3;
65263508Sdim    const unsigned CCMASK_TM_SOME_0      = CCMASK_TM_ALL_1 ^ CCMASK_ANY;
66263508Sdim    const unsigned CCMASK_TM_SOME_1      = CCMASK_TM_ALL_0 ^ CCMASK_ANY;
67263508Sdim    const unsigned CCMASK_TM_MSB_0       = CCMASK_0 | CCMASK_1;
68263508Sdim    const unsigned CCMASK_TM_MSB_1       = CCMASK_2 | CCMASK_3;
69263508Sdim    const unsigned CCMASK_TM             = CCMASK_ANY;
70263508Sdim
71263508Sdim    // The position of the low CC bit in an IPM result.
72263508Sdim    const unsigned IPM_CC = 28;
73263508Sdim
74263508Sdim    // Mask assignments for PFD.
75263508Sdim    const unsigned PFD_READ  = 1;
76263508Sdim    const unsigned PFD_WRITE = 2;
77263508Sdim
78251607Sdim    // Return true if Val fits an LLILL operand.
79251607Sdim    static inline bool isImmLL(uint64_t Val) {
80251607Sdim      return (Val & ~0x000000000000ffffULL) == 0;
81251607Sdim    }
82251607Sdim
83251607Sdim    // Return true if Val fits an LLILH operand.
84251607Sdim    static inline bool isImmLH(uint64_t Val) {
85251607Sdim      return (Val & ~0x00000000ffff0000ULL) == 0;
86251607Sdim    }
87251607Sdim
88251607Sdim    // Return true if Val fits an LLIHL operand.
89251607Sdim    static inline bool isImmHL(uint64_t Val) {
90251607Sdim      return (Val & ~0x00000ffff00000000ULL) == 0;
91251607Sdim    }
92251607Sdim
93251607Sdim    // Return true if Val fits an LLIHH operand.
94251607Sdim    static inline bool isImmHH(uint64_t Val) {
95251607Sdim      return (Val & ~0xffff000000000000ULL) == 0;
96251607Sdim    }
97251607Sdim
98251607Sdim    // Return true if Val fits an LLILF operand.
99251607Sdim    static inline bool isImmLF(uint64_t Val) {
100251607Sdim      return (Val & ~0x00000000ffffffffULL) == 0;
101251607Sdim    }
102251607Sdim
103251607Sdim    // Return true if Val fits an LLIHF operand.
104251607Sdim    static inline bool isImmHF(uint64_t Val) {
105251607Sdim      return (Val & ~0xffffffff00000000ULL) == 0;
106251607Sdim    }
107251607Sdim  }
108251607Sdim
109251607Sdim  FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
110251607Sdim                                     CodeGenOpt::Level OptLevel);
111263508Sdim  FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM);
112263508Sdim  FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM);
113263508Sdim  FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM);
114251607Sdim} // end namespace llvm;
115251607Sdim#endif
116