xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 //===- HexagonMCShuffler.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This declares the shuffling of insns inside a bundle according to the
10 // packet formation rules of the Hexagon ISA.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCSHUFFLER_H
15 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCSHUFFLER_H
16 
17 #include "MCTargetDesc/HexagonMCInstrInfo.h"
18 #include "MCTargetDesc/HexagonShuffler.h"
19 #include "llvm/ADT/SmallVector.h"
20 
21 namespace llvm {
22 
23 class MCContext;
24 class MCInst;
25 class MCInstrInfo;
26 class MCSubtargetInfo;
27 
28 // Insn bundle shuffler.
29 class HexagonMCShuffler : public HexagonShuffler {
30 public:
31   HexagonMCShuffler(MCContext &Context, bool ReportErrors,
32                     MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
33                     MCInst &MCB)
34       : HexagonShuffler(Context, ReportErrors, MCII, STI) {
35     init(MCB);
36   }
37 
38   HexagonMCShuffler(MCContext &Context, bool ReportErrors,
39                     MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
40                     MCInst &MCB, MCInst const &AddMI, bool InsertAtFront)
41       : HexagonShuffler(Context, ReportErrors, MCII, STI) {
42     init(MCB, AddMI, InsertAtFront);
43   }
44 
45   // Copy reordered bundle to another.
46   void copyTo(MCInst &MCB);
47 
48   // Reorder and copy result to another.
49   bool reshuffleTo(MCInst &MCB);
50 
51 private:
52   void init(MCInst &MCB);
53   void init(MCInst &MCB, MCInst const &AddMI, bool InsertAtFront);
54 };
55 
56 // Invocation of the shuffler.  Returns true if the shuffle succeeded.  If
57 // true, MCB will contain the newly-shuffled packet.
58 bool HexagonMCShuffle(MCContext &Context, bool ReportErrors,
59                       MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
60                       MCInst &MCB);
61 bool HexagonMCShuffle(MCContext &Context, MCInstrInfo const &MCII,
62                       MCSubtargetInfo const &STI, MCInst &MCB,
63                       MCInst const &AddMI, int fixupCount);
64 bool HexagonMCShuffle(MCContext &Context, MCInstrInfo const &MCII,
65                       MCSubtargetInfo const &STI, MCInst &MCB,
66                       SmallVector<DuplexCandidate, 8> possibleDuplexes);
67 
68 } // end namespace llvm
69 
70 #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCSHUFFLER_H
71