Hexagon V60/HVX DFA scheduler support
[oota-llvm.git] / include / llvm / CodeGen / DFAPacketizerDefs.h
1 //=- llvm/CodeGen/DFAPacketizerDefs.h - DFA Packetizer for VLIW ---*- 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 // Common definitions used by TableGen and the DFAPacketizer in CodeGen.
10 //===----------------------------------------------------------------------===//
11
12 #ifndef LLVM_CODEGEN_DFAPACKETIZERDEFS_H
13 #define LLVM_CODEGEN_DFAPACKETIZERDEFS_H
14
15 #include <vector>
16
17 namespace llvm {
18
19 // DFA_MAX_RESTERMS * DFA_MAX_RESOURCES must fit within sizeof DFAInput.
20 // This is verified in DFAPacketizer.cpp:DFAPacketizer::DFAPacketizer.
21 //
22 // e.g. terms x resource bit combinations that fit in uint32_t:
23 //      4 terms x 8  bits = 32 bits
24 //      3 terms x 10 bits = 30 bits
25 //      2 terms x 16 bits = 32 bits
26 //
27 // e.g. terms x resource bit combinations that fit in uint64_t:
28 //      8 terms x 8  bits = 64 bits
29 //      7 terms x 9  bits = 63 bits
30 //      6 terms x 10 bits = 60 bits
31 //      5 terms x 12 bits = 60 bits
32 //      4 terms x 16 bits = 64 bits <--- current
33 //      3 terms x 21 bits = 63 bits
34 //      2 terms x 32 bits = 64 bits
35 //
36 #define DFA_MAX_RESTERMS        4   // The max # of AND'ed resource terms.
37 #define DFA_MAX_RESOURCES       16  // The max # of resource bits in one term.
38
39 typedef uint64_t                DFAInput;
40 typedef int64_t                 DFAStateInput;
41 #define DFA_TBLTYPE             "int64_t" // For generating DFAStateInputTable.
42
43 namespace {
44   DFAInput addDFAFuncUnits(DFAInput Inp, unsigned FuncUnits) {
45     return (Inp << DFA_MAX_RESOURCES) | FuncUnits;
46   }
47
48   /// Return the DFAInput for an instruction class input vector.
49   /// This function is used in both DFAPacketizer.cpp and in
50   /// DFAPacketizerEmitter.cpp.
51   DFAInput getDFAInsnInput(const std::vector<unsigned> &InsnClass) {
52     DFAInput InsnInput = 0;
53     assert ((InsnClass.size() <= DFA_MAX_RESTERMS) &&
54             "Exceeded maximum number of DFA terms");
55     for (auto U : InsnClass)
56       InsnInput = addDFAFuncUnits(InsnInput, U);
57     return InsnInput;
58   }
59 }
60
61 }
62
63 #endif