blob: 442138b282b92b9aaf840ee5e1c69e7f7b43c861 [file] [log] [blame]
Florian Hahnb489e562017-06-22 09:39:36 +00001//===- ARMMacroFusion.cpp - ARM Macro Fusion ----------------------===//
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//
10/// \file This file contains the ARM implementation of the DAG scheduling
11/// mutation to pair instructions back to back.
12//
13//===----------------------------------------------------------------------===//
14
Florian Hahnb489e562017-06-22 09:39:36 +000015#include "ARMSubtarget.h"
16#include "llvm/CodeGen/MacroFusion.h"
David Blaikie3f833ed2017-11-08 01:01:31 +000017#include "llvm/CodeGen/TargetInstrInfo.h"
Florian Hahnb489e562017-06-22 09:39:36 +000018
19namespace llvm {
20
21/// \brief Check if the instr pair, FirstMI and SecondMI, should be fused
22/// together. Given SecondMI, when FirstMI is unspecified, then check if
23/// SecondMI may be part of a fused pair at all.
24static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
25 const TargetSubtargetInfo &TSI,
26 const MachineInstr *FirstMI,
27 const MachineInstr &SecondMI) {
28 const ARMSubtarget &ST = static_cast<const ARMSubtarget&>(TSI);
29
30 // Assume wildcards for unspecified instrs.
31 unsigned FirstOpcode =
32 FirstMI ? FirstMI->getOpcode()
NAKAMURA Takumi6f43bd42017-10-18 13:31:28 +000033 : static_cast<unsigned>(ARM::INSTRUCTION_LIST_END);
Florian Hahnb489e562017-06-22 09:39:36 +000034 unsigned SecondOpcode = SecondMI.getOpcode();
35
36 if (ST.hasFuseAES())
37 // Fuse AES crypto operations.
38 switch(SecondOpcode) {
39 // AES encode.
40 case ARM::AESMC :
41 return FirstOpcode == ARM::AESE ||
42 FirstOpcode == ARM::INSTRUCTION_LIST_END;
43 // AES decode.
44 case ARM::AESIMC:
45 return FirstOpcode == ARM::AESD ||
46 FirstOpcode == ARM::INSTRUCTION_LIST_END;
47 }
48
49 return false;
50}
51
52std::unique_ptr<ScheduleDAGMutation> createARMMacroFusionDAGMutation () {
53 return createMacroFusionDAGMutation(shouldScheduleAdjacent);
54}
55
56} // end namespace llvm