1 //=- llvm/CodeGen/DFAPacketizerDefs.h - DFA Packetizer for VLIW ---*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // Common definitions used by TableGen and the DFAPacketizer in CodeGen.
10 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CODEGEN_DFAPACKETIZERDEFS_H
13 #define LLVM_CODEGEN_DFAPACKETIZERDEFS_H
19 // DFA_MAX_RESTERMS * DFA_MAX_RESOURCES must fit within sizeof DFAInput.
20 // This is verified in DFAPacketizer.cpp:DFAPacketizer::DFAPacketizer.
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
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
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.
39 typedef uint64_t DFAInput;
40 typedef int64_t DFAStateInput;
41 #define DFA_TBLTYPE "int64_t" // For generating DFAStateInputTable.
44 DFAInput addDFAFuncUnits(DFAInput Inp, unsigned FuncUnits) {
45 return (Inp << DFA_MAX_RESOURCES) | FuncUnits;
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);