xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
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 Fatal, MCInstrInfo const &MCII,
32                     MCSubtargetInfo const &STI, MCInst &MCB)
33       : HexagonShuffler(Context, Fatal, MCII, STI) {
34     init(MCB);
35   }
36 
37   HexagonMCShuffler(MCContext &Context, bool Fatal, MCInstrInfo const &MCII,
38                     MCSubtargetInfo const &STI, MCInst &MCB,
39                     MCInst const &AddMI, bool InsertAtFront)
40       : HexagonShuffler(Context, Fatal, MCII, STI) {
41     init(MCB, AddMI, InsertAtFront);
42   }
43 
44   // Copy reordered bundle to another.
45   void copyTo(MCInst &MCB);
46 
47   // Reorder and copy result to another.
48   bool reshuffleTo(MCInst &MCB);
49 
50 private:
51   void init(MCInst &MCB);
52   void init(MCInst &MCB, MCInst const &AddMI, bool InsertAtFront);
53 };
54 
55 // Invocation of the shuffler.
56 bool HexagonMCShuffle(MCContext &Context, bool Fatal, MCInstrInfo const &MCII,
57                       MCSubtargetInfo const &STI, MCInst &MCB);
58 bool HexagonMCShuffle(MCContext &Context, MCInstrInfo const &MCII,
59                       MCSubtargetInfo const &STI, MCInst &MCB,
60                       MCInst const &AddMI, int fixupCount);
61 bool HexagonMCShuffle(MCContext &Context, MCInstrInfo const &MCII,
62                       MCSubtargetInfo const &STI, MCInst &MCB,
63                       SmallVector<DuplexCandidate, 8> possibleDuplexes);
64 
65 } // end namespace llvm
66 
67 #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCSHUFFLER_H
68