mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
//===- ARMMacroFusion.cpp - ARM Macro Fusion ----------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file This file contains the ARM implementation of the DAG scheduling
|
|
/// mutation to pair instructions back to back.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "ARMMacroFusion.h"
|
|
#include "ARMSubtarget.h"
|
|
#include "llvm/CodeGen/MacroFusion.h"
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
|
|
|
namespace llvm {
|
|
|
|
// Fuse AES crypto encoding or decoding.
|
|
static bool isAESPair(const MachineInstr *FirstMI,
|
|
const MachineInstr &SecondMI) {
|
|
// Assume the 1st instr to be a wildcard if it is unspecified.
|
|
switch(SecondMI.getOpcode()) {
|
|
// AES encode.
|
|
case ARM::AESMC :
|
|
return FirstMI == nullptr || FirstMI->getOpcode() == ARM::AESE;
|
|
// AES decode.
|
|
case ARM::AESIMC:
|
|
return FirstMI == nullptr || FirstMI->getOpcode() == ARM::AESD;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// Fuse literal generation.
|
|
static bool isLiteralsPair(const MachineInstr *FirstMI,
|
|
const MachineInstr &SecondMI) {
|
|
// Assume the 1st instr to be a wildcard if it is unspecified.
|
|
if ((FirstMI == nullptr || FirstMI->getOpcode() == ARM::MOVi16) &&
|
|
SecondMI.getOpcode() == ARM::MOVTi16)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
/// Check if the instr pair, FirstMI and SecondMI, should be fused
|
|
/// together. Given SecondMI, when FirstMI is unspecified, then check if
|
|
/// SecondMI may be part of a fused pair at all.
|
|
static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
|
|
const TargetSubtargetInfo &TSI,
|
|
const MachineInstr *FirstMI,
|
|
const MachineInstr &SecondMI) {
|
|
const ARMSubtarget &ST = static_cast<const ARMSubtarget&>(TSI);
|
|
|
|
if (ST.hasFuseAES() && isAESPair(FirstMI, SecondMI))
|
|
return true;
|
|
if (ST.hasFuseLiterals() && isLiteralsPair(FirstMI, SecondMI))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
std::unique_ptr<ScheduleDAGMutation> createARMMacroFusionDAGMutation () {
|
|
return createMacroFusionDAGMutation(shouldScheduleAdjacent);
|
|
}
|
|
|
|
} // end namespace llvm
|