LLVM  9.0.0svn
ARMMacroFusion.cpp
Go to the documentation of this file.
1 //===- ARMMacroFusion.cpp - ARM Macro Fusion ----------------------===//
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 /// \file This file contains the ARM implementation of the DAG scheduling
10 /// mutation to pair instructions back to back.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ARMMacroFusion.h"
15 #include "ARMSubtarget.h"
18 
19 namespace llvm {
20 
21 // Fuse AES crypto encoding or decoding.
22 static bool isAESPair(const MachineInstr *FirstMI,
23  const MachineInstr &SecondMI) {
24  // Assume the 1st instr to be a wildcard if it is unspecified.
25  switch(SecondMI.getOpcode()) {
26  // AES encode.
27  case ARM::AESMC :
28  return FirstMI == nullptr || FirstMI->getOpcode() == ARM::AESE;
29  // AES decode.
30  case ARM::AESIMC:
31  return FirstMI == nullptr || FirstMI->getOpcode() == ARM::AESD;
32  }
33 
34  return false;
35 }
36 
37 // Fuse literal generation.
38 static bool isLiteralsPair(const MachineInstr *FirstMI,
39  const MachineInstr &SecondMI) {
40  // Assume the 1st instr to be a wildcard if it is unspecified.
41  if ((FirstMI == nullptr || FirstMI->getOpcode() == ARM::MOVi16) &&
42  SecondMI.getOpcode() == ARM::MOVTi16)
43  return true;
44 
45  return false;
46 }
47 
48 /// Check if the instr pair, FirstMI and SecondMI, should be fused
49 /// together. Given SecondMI, when FirstMI is unspecified, then check if
50 /// SecondMI may be part of a fused pair at all.
52  const TargetSubtargetInfo &TSI,
53  const MachineInstr *FirstMI,
54  const MachineInstr &SecondMI) {
55  const ARMSubtarget &ST = static_cast<const ARMSubtarget&>(TSI);
56 
57  if (ST.hasFuseAES() && isAESPair(FirstMI, SecondMI))
58  return true;
59  if (ST.hasFuseLiterals() && isLiteralsPair(FirstMI, SecondMI))
60  return true;
61 
62  return false;
63 }
64 
65 std::unique_ptr<ScheduleDAGMutation> createARMMacroFusionDAGMutation () {
67 }
68 
69 } // end namespace llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool hasFuseAES() const
Definition: ARMSubtarget.h:645
static bool isAESPair(const MachineInstr *FirstMI, const MachineInstr &SecondMI)
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:408
std::unique_ptr< ScheduleDAGMutation > createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent)
Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit acco...
bool hasFuseLiterals() const
Definition: ARMSubtarget.h:646
std::unique_ptr< ScheduleDAGMutation > createARMMacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createARMMacroFusionDAGMutation()); to ARMPassConfig::crea...
TargetInstrInfo - Interface to description of machine instruction set.
static bool isLiteralsPair(const MachineInstr *FirstMI, const MachineInstr &SecondMI)
static bool shouldScheduleAdjacent(const TargetInstrInfo &TII, const TargetSubtargetInfo &TSI, const MachineInstr *FirstMI, const MachineInstr &SecondMI)
Check if the instr pair, FirstMI and SecondMI, should be fused together.
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
Definition: MachineInstr.h:63