mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
GlobalISel: rename legalizer components to match others.
The previous names were both misleading (the MachineLegalizer actually contained the info tables) and inconsistent with the selector & translator (in having a "Machine") prefix. This should make everything sensible again. The only functional change is the name of a couple of command-line options. llvm-svn: 284287
This commit is contained in:
parent
c292d8927c
commit
dc91ae935f
@ -18,7 +18,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class CallLowering;
|
class CallLowering;
|
||||||
class InstructionSelector;
|
class InstructionSelector;
|
||||||
class MachineLegalizer;
|
class LegalizerInfo;
|
||||||
class RegisterBankInfo;
|
class RegisterBankInfo;
|
||||||
|
|
||||||
/// The goal of this helper class is to gather the accessor to all
|
/// The goal of this helper class is to gather the accessor to all
|
||||||
@ -32,9 +32,7 @@ struct GISelAccessor {
|
|||||||
virtual const InstructionSelector *getInstructionSelector() const {
|
virtual const InstructionSelector *getInstructionSelector() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
virtual const MachineLegalizer *getMachineLegalizer() const {
|
virtual const LegalizerInfo *getLegalizerInfo() const { return nullptr; }
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
virtual const RegisterBankInfo *getRegBankInfo() const { return nullptr;}
|
virtual const RegisterBankInfo *getRegBankInfo() const { return nullptr;}
|
||||||
};
|
};
|
||||||
} // End namespace llvm;
|
} // End namespace llvm;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//== llvm/CodeGen/GlobalISel/MachineLegalizePass.h ------------- -*- C++ -*-==//
|
//== llvm/CodeGen/GlobalISel/LegalizePass.h ------------- -*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -28,7 +28,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class MachineRegisterInfo;
|
class MachineRegisterInfo;
|
||||||
|
|
||||||
class MachineLegalizePass : public MachineFunctionPass {
|
class Legalizer : public MachineFunctionPass {
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Ctor, nothing fancy.
|
// Ctor, nothing fancy.
|
||||||
MachineLegalizePass();
|
Legalizer();
|
||||||
|
|
||||||
StringRef getPassName() const override { return "MachineLegalizePass"; }
|
StringRef getPassName() const override { return "Legalizer"; }
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
//== llvm/CodeGen/GlobalISel/MachineLegalizeHelper.h ----------- -*- C++ -*-==//
|
//== llvm/CodeGen/GlobalISel/LegalizerHelper.h ---------------- -*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -12,7 +12,7 @@
|
|||||||
/// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
|
/// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
|
||||||
/// G_ADD <4 x i16>.
|
/// G_ADD <4 x i16>.
|
||||||
///
|
///
|
||||||
/// The MachineLegalizeHelper class is where most of the work happens, and is
|
/// The LegalizerHelper class is where most of the work happens, and is
|
||||||
/// designed to be callable from other passes that find themselves with an
|
/// designed to be callable from other passes that find themselves with an
|
||||||
/// illegal instruction.
|
/// illegal instruction.
|
||||||
//
|
//
|
||||||
@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class MachineLegalizeInfo;
|
class LegalizerInfo;
|
||||||
class MachineLegalizer;
|
class Legalizer;
|
||||||
class MachineRegisterInfo;
|
class MachineRegisterInfo;
|
||||||
|
|
||||||
class MachineLegalizeHelper {
|
class LegalizerHelper {
|
||||||
public:
|
public:
|
||||||
enum LegalizeResult {
|
enum LegalizeResult {
|
||||||
/// Instruction was already legal and no change was made to the
|
/// Instruction was already legal and no change was made to the
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
UnableToLegalize,
|
UnableToLegalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
MachineLegalizeHelper(MachineFunction &MF);
|
LegalizerHelper(MachineFunction &MF);
|
||||||
|
|
||||||
/// Replace \p MI by a sequence of legal instructions that can implement the
|
/// Replace \p MI by a sequence of legal instructions that can implement the
|
||||||
/// same operation. Note that this means \p MI may be deleted, so any iterator
|
/// same operation. Note that this means \p MI may be deleted, so any iterator
|
||||||
@ -56,10 +56,10 @@ public:
|
|||||||
/// Considered as an opaque blob, the legal code will use and define the same
|
/// Considered as an opaque blob, the legal code will use and define the same
|
||||||
/// registers as \p MI.
|
/// registers as \p MI.
|
||||||
LegalizeResult legalizeInstrStep(MachineInstr &MI,
|
LegalizeResult legalizeInstrStep(MachineInstr &MI,
|
||||||
const MachineLegalizer &Legalizer);
|
const LegalizerInfo &LegalizerInfo);
|
||||||
|
|
||||||
LegalizeResult legalizeInstr(MachineInstr &MI,
|
LegalizeResult legalizeInstr(MachineInstr &MI,
|
||||||
const MachineLegalizer &Legalizer);
|
const LegalizerInfo &LegalizerInfo);
|
||||||
|
|
||||||
/// Legalize an instruction by emiting a runtime library call instead.
|
/// Legalize an instruction by emiting a runtime library call instead.
|
||||||
LegalizeResult libcall(MachineInstr &MI);
|
LegalizeResult libcall(MachineInstr &MI);
|
@ -1,4 +1,4 @@
|
|||||||
//==-- llvm/CodeGen/GlobalISel/MachineLegalizer.h ----------------*- C++ -*-==//
|
//==-- llvm/CodeGen/GlobalISel/LegalizerInfo.h -------------------*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -46,7 +46,7 @@ struct InstrAspect {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MachineLegalizer {
|
class LegalizerInfo {
|
||||||
public:
|
public:
|
||||||
enum LegalizeAction : std::uint8_t {
|
enum LegalizeAction : std::uint8_t {
|
||||||
/// The operation is expected to be selectable directly by the target, and
|
/// The operation is expected to be selectable directly by the target, and
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
NotFound,
|
NotFound,
|
||||||
};
|
};
|
||||||
|
|
||||||
MachineLegalizer();
|
LegalizerInfo();
|
||||||
|
|
||||||
/// Compute any ancillary tables needed to quickly decide how an operation
|
/// Compute any ancillary tables needed to quickly decide how an operation
|
||||||
/// should be handled. This must be called after all "set*Action"methods but
|
/// should be handled. This must be called after all "set*Action"methods but
|
@ -171,6 +171,7 @@ void initializeLegacyLICMPassPass(PassRegistry&);
|
|||||||
void initializeLazyBranchProbabilityInfoPassPass(PassRegistry&);
|
void initializeLazyBranchProbabilityInfoPassPass(PassRegistry&);
|
||||||
void initializeLazyBlockFrequencyInfoPassPass(PassRegistry&);
|
void initializeLazyBlockFrequencyInfoPassPass(PassRegistry&);
|
||||||
void initializeLazyValueInfoWrapperPassPass(PassRegistry&);
|
void initializeLazyValueInfoWrapperPassPass(PassRegistry&);
|
||||||
|
void initializeLegalizerPass(PassRegistry&);
|
||||||
void initializeLintPass(PassRegistry&);
|
void initializeLintPass(PassRegistry&);
|
||||||
void initializeLiveDebugValuesPass(PassRegistry&);
|
void initializeLiveDebugValuesPass(PassRegistry&);
|
||||||
void initializeLiveDebugVariablesPass(PassRegistry&);
|
void initializeLiveDebugVariablesPass(PassRegistry&);
|
||||||
@ -222,7 +223,6 @@ void initializeMachineCopyPropagationPass(PassRegistry&);
|
|||||||
void initializeMachineDominanceFrontierPass(PassRegistry&);
|
void initializeMachineDominanceFrontierPass(PassRegistry&);
|
||||||
void initializeMachineDominatorTreePass(PassRegistry&);
|
void initializeMachineDominatorTreePass(PassRegistry&);
|
||||||
void initializeMachineFunctionPrinterPassPass(PassRegistry&);
|
void initializeMachineFunctionPrinterPassPass(PassRegistry&);
|
||||||
void initializeMachineLegalizePassPass(PassRegistry&);
|
|
||||||
void initializeMachineLICMPass(PassRegistry&);
|
void initializeMachineLICMPass(PassRegistry&);
|
||||||
void initializeMachineLoopInfoPass(PassRegistry&);
|
void initializeMachineLoopInfoPass(PassRegistry&);
|
||||||
void initializeMachineModuleInfoPass(PassRegistry&);
|
void initializeMachineModuleInfoPass(PassRegistry&);
|
||||||
|
@ -26,9 +26,9 @@ namespace llvm {
|
|||||||
class CallLowering;
|
class CallLowering;
|
||||||
class DataLayout;
|
class DataLayout;
|
||||||
class InstructionSelector;
|
class InstructionSelector;
|
||||||
|
class LegalizerInfo;
|
||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class MachineLegalizer;
|
|
||||||
class RegisterBankInfo;
|
class RegisterBankInfo;
|
||||||
class SDep;
|
class SDep;
|
||||||
class SUnit;
|
class SUnit;
|
||||||
@ -107,9 +107,7 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const MachineLegalizer *getMachineLegalizer() const {
|
virtual const LegalizerInfo *getLegalizerInfo() const { return nullptr; }
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getRegisterInfo - If register information is available, return it. If
|
/// getRegisterInfo - If register information is available, return it. If
|
||||||
/// not, return null.
|
/// not, return null.
|
||||||
|
@ -5,9 +5,9 @@ set(GLOBAL_ISEL_FILES
|
|||||||
InstructionSelect.cpp
|
InstructionSelect.cpp
|
||||||
InstructionSelector.cpp
|
InstructionSelector.cpp
|
||||||
MachineIRBuilder.cpp
|
MachineIRBuilder.cpp
|
||||||
MachineLegalizeHelper.cpp
|
LegalizerHelper.cpp
|
||||||
MachineLegalizePass.cpp
|
Legalizer.cpp
|
||||||
MachineLegalizer.cpp
|
LegalizerInfo.cpp
|
||||||
RegBankSelect.cpp
|
RegBankSelect.cpp
|
||||||
RegisterBank.cpp
|
RegisterBank.cpp
|
||||||
RegisterBankInfo.cpp
|
RegisterBankInfo.cpp
|
||||||
|
@ -25,7 +25,7 @@ void llvm::initializeGlobalISel(PassRegistry &Registry) {
|
|||||||
|
|
||||||
void llvm::initializeGlobalISel(PassRegistry &Registry) {
|
void llvm::initializeGlobalISel(PassRegistry &Registry) {
|
||||||
initializeIRTranslatorPass(Registry);
|
initializeIRTranslatorPass(Registry);
|
||||||
initializeMachineLegalizePassPass(Registry);
|
initializeLegalizerPass(Registry);
|
||||||
initializeRegBankSelectPass(Registry);
|
initializeRegBankSelectPass(Registry);
|
||||||
initializeInstructionSelectPass(Registry);
|
initializeInstructionSelectPass(Registry);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include "llvm/ADT/PostOrderIterator.h"
|
#include "llvm/ADT/PostOrderIterator.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
|
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
@ -71,12 +71,12 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Check that our input is fully legal: we require the function to have the
|
// Check that our input is fully legal: we require the function to have the
|
||||||
// Legalized property, so it should be.
|
// Legalized property, so it should be.
|
||||||
// FIXME: This should be in the MachineVerifier, but it can't use the
|
// FIXME: This should be in the MachineVerifier, but it can't use the
|
||||||
// MachineLegalizer as it's currently in the separate GlobalISel library.
|
// LegalizerInfo as it's currently in the separate GlobalISel library.
|
||||||
// The RegBankSelected property is already checked in the verifier. Note
|
// The RegBankSelected property is already checked in the verifier. Note
|
||||||
// that it has the same layering problem, but we only use inline methods so
|
// that it has the same layering problem, but we only use inline methods so
|
||||||
// end up not needing to link against the GlobalISel library.
|
// end up not needing to link against the GlobalISel library.
|
||||||
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||||
if (const MachineLegalizer *MLI = MF.getSubtarget().getMachineLegalizer())
|
if (const LegalizerInfo *MLI = MF.getSubtarget().getLegalizerInfo())
|
||||||
for (const MachineBasicBlock &MBB : MF)
|
for (const MachineBasicBlock &MBB : MF)
|
||||||
for (const MachineInstr &MI : MBB)
|
for (const MachineInstr &MI : MBB)
|
||||||
if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI))
|
if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===-- llvm/CodeGen/GlobalISel/MachineLegalizePass.cpp -------------------===//
|
//===-- llvm/CodeGen/GlobalISel/Legalizer.cpp -----------------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -7,49 +7,48 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
/// \file This file implements the LegalizeHelper class to legalize individual
|
/// \file This file implements the LegalizerHelper class to legalize individual
|
||||||
/// instructions and the MachineLegalizePass wrapper pass for the primary
|
/// instructions and the LegalizePass wrapper pass for the primary
|
||||||
/// legalization.
|
/// legalization.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizePass.h"
|
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizeHelper.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||||
|
|
||||||
#define DEBUG_TYPE "legalize-mir"
|
#define DEBUG_TYPE "legalizer"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
char MachineLegalizePass::ID = 0;
|
char Legalizer::ID = 0;
|
||||||
INITIALIZE_PASS_BEGIN(MachineLegalizePass, DEBUG_TYPE,
|
INITIALIZE_PASS_BEGIN(Legalizer, DEBUG_TYPE,
|
||||||
"Legalize the Machine IR a function's Machine IR", false,
|
"Legalize the Machine IR a function's Machine IR", false,
|
||||||
false)
|
false)
|
||||||
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
|
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
|
||||||
INITIALIZE_PASS_END(MachineLegalizePass, DEBUG_TYPE,
|
INITIALIZE_PASS_END(Legalizer, DEBUG_TYPE,
|
||||||
"Legalize the Machine IR a function's Machine IR", false,
|
"Legalize the Machine IR a function's Machine IR", false,
|
||||||
false)
|
false)
|
||||||
|
|
||||||
MachineLegalizePass::MachineLegalizePass() : MachineFunctionPass(ID) {
|
Legalizer::Legalizer() : MachineFunctionPass(ID) {
|
||||||
initializeMachineLegalizePassPass(*PassRegistry::getPassRegistry());
|
initializeLegalizerPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineLegalizePass::getAnalysisUsage(AnalysisUsage &AU) const {
|
void Legalizer::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addRequired<TargetPassConfig>();
|
AU.addRequired<TargetPassConfig>();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineLegalizePass::init(MachineFunction &MF) {
|
void Legalizer::init(MachineFunction &MF) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MachineLegalizePass::combineExtracts(MachineInstr &MI,
|
bool Legalizer::combineExtracts(MachineInstr &MI, MachineRegisterInfo &MRI,
|
||||||
MachineRegisterInfo &MRI,
|
const TargetInstrInfo &TII) {
|
||||||
const TargetInstrInfo &TII) {
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
if (MI.getOpcode() != TargetOpcode::G_EXTRACT)
|
if (MI.getOpcode() != TargetOpcode::G_EXTRACT)
|
||||||
return Changed;
|
return Changed;
|
||||||
@ -115,7 +114,7 @@ bool MachineLegalizePass::combineExtracts(MachineInstr &MI,
|
|||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MachineLegalizePass::runOnMachineFunction(MachineFunction &MF) {
|
bool Legalizer::runOnMachineFunction(MachineFunction &MF) {
|
||||||
// If the ISel pipeline failed, do not bother running that pass.
|
// If the ISel pipeline failed, do not bother running that pass.
|
||||||
if (MF.getProperties().hasProperty(
|
if (MF.getProperties().hasProperty(
|
||||||
MachineFunctionProperties::Property::FailedISel))
|
MachineFunctionProperties::Property::FailedISel))
|
||||||
@ -123,8 +122,8 @@ bool MachineLegalizePass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
|
DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
|
||||||
init(MF);
|
init(MF);
|
||||||
const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
|
const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
|
||||||
const MachineLegalizer &Legalizer = *MF.getSubtarget().getMachineLegalizer();
|
const LegalizerInfo &LegalizerInfo = *MF.getSubtarget().getLegalizerInfo();
|
||||||
MachineLegalizeHelper Helper(MF);
|
LegalizerHelper Helper(MF);
|
||||||
|
|
||||||
// FIXME: an instruction may need more than one pass before it is legal. For
|
// FIXME: an instruction may need more than one pass before it is legal. For
|
||||||
// example on most architectures <3 x i3> is doubly-illegal. It would
|
// example on most architectures <3 x i3> is doubly-illegal. It would
|
||||||
@ -144,11 +143,11 @@ bool MachineLegalizePass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
if (!isPreISelGenericOpcode(MI->getOpcode()))
|
if (!isPreISelGenericOpcode(MI->getOpcode()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto Res = Helper.legalizeInstr(*MI, Legalizer);
|
auto Res = Helper.legalizeInstr(*MI, LegalizerInfo);
|
||||||
|
|
||||||
// Error out if we couldn't legalize this instruction. We may want to fall
|
// Error out if we couldn't legalize this instruction. We may want to fall
|
||||||
// back to DAG ISel instead in the future.
|
// back to DAG ISel instead in the future.
|
||||||
if (Res == MachineLegalizeHelper::UnableToLegalize) {
|
if (Res == LegalizerHelper::UnableToLegalize) {
|
||||||
if (!TPC.isGlobalISelAbortEnabled()) {
|
if (!TPC.isGlobalISelAbortEnabled()) {
|
||||||
MF.getProperties().set(
|
MF.getProperties().set(
|
||||||
MachineFunctionProperties::Property::FailedISel);
|
MachineFunctionProperties::Property::FailedISel);
|
||||||
@ -161,7 +160,7 @@ bool MachineLegalizePass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
report_fatal_error(OS.str());
|
report_fatal_error(OS.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Changed |= Res == MachineLegalizeHelper::Legalized;
|
Changed |= Res == LegalizerHelper::Legalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
//===-- llvm/CodeGen/GlobalISel/MachineLegalizeHelper.cpp -----------------===//
|
//===-- llvm/CodeGen/GlobalISel/LegalizerHelper.cpp -----------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -7,15 +7,15 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
/// \file This file implements the MachineLegalizeHelper class to legalize
|
/// \file This file implements the LegalizerHelper class to legalize
|
||||||
/// individual instructions and the LegalizeMachineIR wrapper pass for the
|
/// individual instructions and the LegalizeMachineIR wrapper pass for the
|
||||||
/// primary legalization.
|
/// primary legalization.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizeHelper.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
|
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -28,36 +28,36 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MachineLegalizeHelper::MachineLegalizeHelper(MachineFunction &MF)
|
LegalizerHelper::LegalizerHelper(MachineFunction &MF)
|
||||||
: MRI(MF.getRegInfo()) {
|
: MRI(MF.getRegInfo()) {
|
||||||
MIRBuilder.setMF(MF);
|
MIRBuilder.setMF(MF);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::legalizeInstrStep(MachineInstr &MI,
|
LegalizerHelper::legalizeInstrStep(MachineInstr &MI,
|
||||||
const MachineLegalizer &Legalizer) {
|
const LegalizerInfo &LegalizerInfo) {
|
||||||
auto Action = Legalizer.getAction(MI, MRI);
|
auto Action = LegalizerInfo.getAction(MI, MRI);
|
||||||
switch (std::get<0>(Action)) {
|
switch (std::get<0>(Action)) {
|
||||||
case MachineLegalizer::Legal:
|
case LegalizerInfo::Legal:
|
||||||
return AlreadyLegal;
|
return AlreadyLegal;
|
||||||
case MachineLegalizer::Libcall:
|
case LegalizerInfo::Libcall:
|
||||||
return libcall(MI);
|
return libcall(MI);
|
||||||
case MachineLegalizer::NarrowScalar:
|
case LegalizerInfo::NarrowScalar:
|
||||||
return narrowScalar(MI, std::get<1>(Action), std::get<2>(Action));
|
return narrowScalar(MI, std::get<1>(Action), std::get<2>(Action));
|
||||||
case MachineLegalizer::WidenScalar:
|
case LegalizerInfo::WidenScalar:
|
||||||
return widenScalar(MI, std::get<1>(Action), std::get<2>(Action));
|
return widenScalar(MI, std::get<1>(Action), std::get<2>(Action));
|
||||||
case MachineLegalizer::Lower:
|
case LegalizerInfo::Lower:
|
||||||
return lower(MI, std::get<1>(Action), std::get<2>(Action));
|
return lower(MI, std::get<1>(Action), std::get<2>(Action));
|
||||||
case MachineLegalizer::FewerElements:
|
case LegalizerInfo::FewerElements:
|
||||||
return fewerElementsVector(MI, std::get<1>(Action), std::get<2>(Action));
|
return fewerElementsVector(MI, std::get<1>(Action), std::get<2>(Action));
|
||||||
default:
|
default:
|
||||||
return UnableToLegalize;
|
return UnableToLegalize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::legalizeInstr(MachineInstr &MI,
|
LegalizerHelper::legalizeInstr(MachineInstr &MI,
|
||||||
const MachineLegalizer &Legalizer) {
|
const LegalizerInfo &LegalizerInfo) {
|
||||||
SmallVector<MachineInstr *, 4> WorkList;
|
SmallVector<MachineInstr *, 4> WorkList;
|
||||||
MIRBuilder.recordInsertions(
|
MIRBuilder.recordInsertions(
|
||||||
[&](MachineInstr *MI) { WorkList.push_back(MI); });
|
[&](MachineInstr *MI) { WorkList.push_back(MI); });
|
||||||
@ -67,7 +67,7 @@ MachineLegalizeHelper::legalizeInstr(MachineInstr &MI,
|
|||||||
LegalizeResult Res;
|
LegalizeResult Res;
|
||||||
unsigned Idx = 0;
|
unsigned Idx = 0;
|
||||||
do {
|
do {
|
||||||
Res = legalizeInstrStep(*WorkList[Idx], Legalizer);
|
Res = legalizeInstrStep(*WorkList[Idx], LegalizerInfo);
|
||||||
if (Res == UnableToLegalize) {
|
if (Res == UnableToLegalize) {
|
||||||
MIRBuilder.stopRecordingInsertions();
|
MIRBuilder.stopRecordingInsertions();
|
||||||
return UnableToLegalize;
|
return UnableToLegalize;
|
||||||
@ -81,8 +81,8 @@ MachineLegalizeHelper::legalizeInstr(MachineInstr &MI,
|
|||||||
return Changed ? Legalized : AlreadyLegal;
|
return Changed ? Legalized : AlreadyLegal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineLegalizeHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
|
void LegalizerHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
|
||||||
SmallVectorImpl<unsigned> &VRegs) {
|
SmallVectorImpl<unsigned> &VRegs) {
|
||||||
unsigned Size = Ty.getSizeInBits();
|
unsigned Size = Ty.getSizeInBits();
|
||||||
SmallVector<uint64_t, 4> Indexes;
|
SmallVector<uint64_t, 4> Indexes;
|
||||||
for (int i = 0; i < NumParts; ++i) {
|
for (int i = 0; i < NumParts; ++i) {
|
||||||
@ -92,8 +92,8 @@ void MachineLegalizeHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
|
|||||||
MIRBuilder.buildExtract(VRegs, Indexes, Reg);
|
MIRBuilder.buildExtract(VRegs, Indexes, Reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::libcall(MachineInstr &MI) {
|
LegalizerHelper::libcall(MachineInstr &MI) {
|
||||||
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
|
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
|
||||||
unsigned Size = Ty.getSizeInBits();
|
unsigned Size = Ty.getSizeInBits();
|
||||||
MIRBuilder.setInstr(MI);
|
MIRBuilder.setInstr(MI);
|
||||||
@ -119,9 +119,9 @@ MachineLegalizeHelper::libcall(MachineInstr &MI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
|
||||||
MachineLegalizeHelper::narrowScalar(MachineInstr &MI, unsigned TypeIdx,
|
unsigned TypeIdx,
|
||||||
LLT NarrowTy) {
|
LLT NarrowTy) {
|
||||||
// FIXME: Don't know how to handle secondary types yet.
|
// FIXME: Don't know how to handle secondary types yet.
|
||||||
if (TypeIdx != 0)
|
if (TypeIdx != 0)
|
||||||
return UnableToLegalize;
|
return UnableToLegalize;
|
||||||
@ -163,9 +163,8 @@ MachineLegalizeHelper::narrowScalar(MachineInstr &MI, unsigned TypeIdx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx,
|
LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
|
||||||
LLT WideTy) {
|
|
||||||
MIRBuilder.setInstr(MI);
|
MIRBuilder.setInstr(MI);
|
||||||
|
|
||||||
switch (MI.getOpcode()) {
|
switch (MI.getOpcode()) {
|
||||||
@ -293,8 +292,8 @@ MachineLegalizeHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
|
LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
|
||||||
using namespace TargetOpcode;
|
using namespace TargetOpcode;
|
||||||
MIRBuilder.setInstr(MI);
|
MIRBuilder.setInstr(MI);
|
||||||
|
|
||||||
@ -319,9 +318,9 @@ MachineLegalizeHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLegalizeHelper::LegalizeResult
|
LegalizerHelper::LegalizeResult
|
||||||
MachineLegalizeHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
|
LegalizerHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
|
||||||
LLT NarrowTy) {
|
LLT NarrowTy) {
|
||||||
// FIXME: Don't know how to handle secondary types yet.
|
// FIXME: Don't know how to handle secondary types yet.
|
||||||
if (TypeIdx != 0)
|
if (TypeIdx != 0)
|
||||||
return UnableToLegalize;
|
return UnableToLegalize;
|
@ -1,4 +1,4 @@
|
|||||||
//===---- lib/CodeGen/GlobalISel/MachineLegalizer.cpp - IRTranslator -------==//
|
//===---- lib/CodeGen/GlobalISel/LegalizerInfo.cpp - Legalizer -------==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -17,7 +17,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
|
|
||||||
#include "llvm/ADT/SmallBitVector.h"
|
#include "llvm/ADT/SmallBitVector.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include "llvm/Target/TargetOpcodes.h"
|
#include "llvm/Target/TargetOpcodes.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MachineLegalizer::MachineLegalizer() : TablesInitialized(false) {
|
LegalizerInfo::LegalizerInfo() : TablesInitialized(false) {
|
||||||
// FIXME: these two can be legalized to the fundamental load/store Jakob
|
// FIXME: these two can be legalized to the fundamental load/store Jakob
|
||||||
// proposed. Once loads & stores are supported.
|
// proposed. Once loads & stores are supported.
|
||||||
DefaultActions[TargetOpcode::G_ANYEXT] = Legal;
|
DefaultActions[TargetOpcode::G_ANYEXT] = Legal;
|
||||||
@ -41,7 +41,7 @@ MachineLegalizer::MachineLegalizer() : TablesInitialized(false) {
|
|||||||
DefaultActions[TargetOpcode::G_BRCOND] = WidenScalar;
|
DefaultActions[TargetOpcode::G_BRCOND] = WidenScalar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineLegalizer::computeTables() {
|
void LegalizerInfo::computeTables() {
|
||||||
for (unsigned Opcode = 0; Opcode <= LastOp - FirstOp; ++Opcode) {
|
for (unsigned Opcode = 0; Opcode <= LastOp - FirstOp; ++Opcode) {
|
||||||
for (unsigned Idx = 0; Idx != Actions[Opcode].size(); ++Idx) {
|
for (unsigned Idx = 0; Idx != Actions[Opcode].size(); ++Idx) {
|
||||||
for (auto &Action : Actions[Opcode][Idx]) {
|
for (auto &Action : Actions[Opcode][Idx]) {
|
||||||
@ -63,8 +63,8 @@ void MachineLegalizer::computeTables() {
|
|||||||
// probably going to need specialized lookup structures for various types before
|
// probably going to need specialized lookup structures for various types before
|
||||||
// we have any hope of doing well with something like <13 x i3>. Even the common
|
// we have any hope of doing well with something like <13 x i3>. Even the common
|
||||||
// cases should do better than what we have now.
|
// cases should do better than what we have now.
|
||||||
std::pair<MachineLegalizer::LegalizeAction, LLT>
|
std::pair<LegalizerInfo::LegalizeAction, LLT>
|
||||||
MachineLegalizer::getAction(const InstrAspect &Aspect) const {
|
LegalizerInfo::getAction(const InstrAspect &Aspect) const {
|
||||||
assert(TablesInitialized && "backend forgot to call computeTables");
|
assert(TablesInitialized && "backend forgot to call computeTables");
|
||||||
// These *have* to be implemented for now, they're the fundamental basis of
|
// These *have* to be implemented for now, they're the fundamental basis of
|
||||||
// how everything else is transformed.
|
// how everything else is transformed.
|
||||||
@ -113,9 +113,9 @@ MachineLegalizer::getAction(const InstrAspect &Aspect) const {
|
|||||||
return findLegalAction(Aspect, FewerElements);
|
return findLegalAction(Aspect, FewerElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<MachineLegalizer::LegalizeAction, unsigned, LLT>
|
std::tuple<LegalizerInfo::LegalizeAction, unsigned, LLT>
|
||||||
MachineLegalizer::getAction(const MachineInstr &MI,
|
LegalizerInfo::getAction(const MachineInstr &MI,
|
||||||
const MachineRegisterInfo &MRI) const {
|
const MachineRegisterInfo &MRI) const {
|
||||||
SmallBitVector SeenTypes(8);
|
SmallBitVector SeenTypes(8);
|
||||||
const MCOperandInfo *OpInfo = MI.getDesc().OpInfo;
|
const MCOperandInfo *OpInfo = MI.getDesc().OpInfo;
|
||||||
for (unsigned i = 0; i < MI.getDesc().getNumOperands(); ++i) {
|
for (unsigned i = 0; i < MI.getDesc().getNumOperands(); ++i) {
|
||||||
@ -138,13 +138,13 @@ MachineLegalizer::getAction(const MachineInstr &MI,
|
|||||||
return std::make_tuple(Legal, 0, LLT{});
|
return std::make_tuple(Legal, 0, LLT{});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MachineLegalizer::isLegal(const MachineInstr &MI,
|
bool LegalizerInfo::isLegal(const MachineInstr &MI,
|
||||||
const MachineRegisterInfo &MRI) const {
|
const MachineRegisterInfo &MRI) const {
|
||||||
return std::get<0>(getAction(MI, MRI)) == Legal;
|
return std::get<0>(getAction(MI, MRI)) == Legal;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLT MachineLegalizer::findLegalType(const InstrAspect &Aspect,
|
LLT LegalizerInfo::findLegalType(const InstrAspect &Aspect,
|
||||||
LegalizeAction Action) const {
|
LegalizeAction Action) const {
|
||||||
switch(Action) {
|
switch(Action) {
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Cannot find legal type");
|
llvm_unreachable("Cannot find legal type");
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
||||||
#include "llvm/ADT/PostOrderIterator.h"
|
#include "llvm/ADT/PostOrderIterator.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/RegisterBank.h"
|
#include "llvm/CodeGen/GlobalISel/RegisterBank.h"
|
||||||
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
|
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
|
||||||
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
||||||
@ -571,9 +571,9 @@ bool RegBankSelect::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Check that our input is fully legal: we require the function to have the
|
// Check that our input is fully legal: we require the function to have the
|
||||||
// Legalized property, so it should be.
|
// Legalized property, so it should be.
|
||||||
// FIXME: This should be in the MachineVerifier, but it can't use the
|
// FIXME: This should be in the MachineVerifier, but it can't use the
|
||||||
// MachineLegalizer as it's currently in the separate GlobalISel library.
|
// LegalizerInfo as it's currently in the separate GlobalISel library.
|
||||||
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||||
if (const MachineLegalizer *MLI = MF.getSubtarget().getMachineLegalizer()) {
|
if (const LegalizerInfo *MLI = MF.getSubtarget().getLegalizerInfo()) {
|
||||||
for (const MachineBasicBlock &MBB : MF) {
|
for (const MachineBasicBlock &MBB : MF) {
|
||||||
for (const MachineInstr &MI : MBB) {
|
for (const MachineInstr &MI : MBB) {
|
||||||
if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI)) {
|
if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI)) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- AArch64MachineLegalizer.cpp -------------------------------*- C++ -*-==//
|
//===- AArch64LegalizerInfo.cpp ----------------------------------*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -12,7 +12,7 @@
|
|||||||
/// \todo This should be generated by TableGen.
|
/// \todo This should be generated by TableGen.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "AArch64MachineLegalizer.h"
|
#include "AArch64LegalizerInfo.h"
|
||||||
#include "llvm/CodeGen/ValueTypes.h"
|
#include "llvm/CodeGen/ValueTypes.h"
|
||||||
#include "llvm/IR/Type.h"
|
#include "llvm/IR/Type.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
@ -24,7 +24,7 @@ using namespace llvm;
|
|||||||
#error "You shouldn't build this"
|
#error "You shouldn't build this"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AArch64MachineLegalizer::AArch64MachineLegalizer() {
|
AArch64LegalizerInfo::AArch64LegalizerInfo() {
|
||||||
using namespace TargetOpcode;
|
using namespace TargetOpcode;
|
||||||
const LLT p0 = LLT::pointer(0, 64);
|
const LLT p0 = LLT::pointer(0, 64);
|
||||||
const LLT s1 = LLT::scalar(1);
|
const LLT s1 = LLT::scalar(1);
|
@ -1,4 +1,4 @@
|
|||||||
//===- AArch64Machinelegalizer --------------------------------*- C++ -*-==//
|
//===- AArch64LegalizerInfo --------------------------------------*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -15,16 +15,16 @@
|
|||||||
#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINELEGALIZER_H
|
#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINELEGALIZER_H
|
||||||
#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINELEGALIZER_H
|
#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINELEGALIZER_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class LLVMContext;
|
class LLVMContext;
|
||||||
|
|
||||||
/// This class provides the information for the target register banks.
|
/// This class provides the information for the target register banks.
|
||||||
class AArch64MachineLegalizer : public MachineLegalizer {
|
class AArch64LegalizerInfo : public LegalizerInfo {
|
||||||
public:
|
public:
|
||||||
AArch64MachineLegalizer();
|
AArch64LegalizerInfo();
|
||||||
};
|
};
|
||||||
} // End llvm namespace.
|
} // End llvm namespace.
|
||||||
#endif
|
#endif
|
@ -105,9 +105,9 @@ const InstructionSelector *AArch64Subtarget::getInstructionSelector() const {
|
|||||||
return GISel->getInstructionSelector();
|
return GISel->getInstructionSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MachineLegalizer *AArch64Subtarget::getMachineLegalizer() const {
|
const LegalizerInfo *AArch64Subtarget::getLegalizerInfo() const {
|
||||||
assert(GISel && "Access to GlobalISel APIs not set");
|
assert(GISel && "Access to GlobalISel APIs not set");
|
||||||
return GISel->getMachineLegalizer();
|
return GISel->getLegalizerInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {
|
const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
}
|
}
|
||||||
const CallLowering *getCallLowering() const override;
|
const CallLowering *getCallLowering() const override;
|
||||||
const InstructionSelector *getInstructionSelector() const override;
|
const InstructionSelector *getInstructionSelector() const override;
|
||||||
const MachineLegalizer *getMachineLegalizer() const override;
|
const LegalizerInfo *getLegalizerInfo() const override;
|
||||||
const RegisterBankInfo *getRegBankInfo() const override;
|
const RegisterBankInfo *getRegBankInfo() const override;
|
||||||
const Triple &getTargetTriple() const { return TargetTriple; }
|
const Triple &getTargetTriple() const { return TargetTriple; }
|
||||||
bool enableMachineScheduler() const override { return true; }
|
bool enableMachineScheduler() const override { return true; }
|
||||||
|
@ -13,14 +13,14 @@
|
|||||||
#include "AArch64.h"
|
#include "AArch64.h"
|
||||||
#include "AArch64CallLowering.h"
|
#include "AArch64CallLowering.h"
|
||||||
#include "AArch64InstructionSelector.h"
|
#include "AArch64InstructionSelector.h"
|
||||||
#include "AArch64MachineLegalizer.h"
|
#include "AArch64LegalizerInfo.h"
|
||||||
#include "AArch64RegisterBankInfo.h"
|
#include "AArch64RegisterBankInfo.h"
|
||||||
#include "AArch64TargetMachine.h"
|
#include "AArch64TargetMachine.h"
|
||||||
#include "AArch64TargetObjectFile.h"
|
#include "AArch64TargetObjectFile.h"
|
||||||
#include "AArch64TargetTransformInfo.h"
|
#include "AArch64TargetTransformInfo.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
|
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
|
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizePass.h"
|
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
|
||||||
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/RegAllocRegistry.h"
|
#include "llvm/CodeGen/RegAllocRegistry.h"
|
||||||
@ -202,7 +202,7 @@ namespace {
|
|||||||
struct AArch64GISelActualAccessor : public GISelAccessor {
|
struct AArch64GISelActualAccessor : public GISelAccessor {
|
||||||
std::unique_ptr<CallLowering> CallLoweringInfo;
|
std::unique_ptr<CallLowering> CallLoweringInfo;
|
||||||
std::unique_ptr<InstructionSelector> InstSelector;
|
std::unique_ptr<InstructionSelector> InstSelector;
|
||||||
std::unique_ptr<MachineLegalizer> Legalizer;
|
std::unique_ptr<LegalizerInfo> Legalizer;
|
||||||
std::unique_ptr<RegisterBankInfo> RegBankInfo;
|
std::unique_ptr<RegisterBankInfo> RegBankInfo;
|
||||||
const CallLowering *getCallLowering() const override {
|
const CallLowering *getCallLowering() const override {
|
||||||
return CallLoweringInfo.get();
|
return CallLoweringInfo.get();
|
||||||
@ -210,7 +210,7 @@ struct AArch64GISelActualAccessor : public GISelAccessor {
|
|||||||
const InstructionSelector *getInstructionSelector() const override {
|
const InstructionSelector *getInstructionSelector() const override {
|
||||||
return InstSelector.get();
|
return InstSelector.get();
|
||||||
}
|
}
|
||||||
const class MachineLegalizer *getMachineLegalizer() const override {
|
const class LegalizerInfo *getLegalizerInfo() const override {
|
||||||
return Legalizer.get();
|
return Legalizer.get();
|
||||||
}
|
}
|
||||||
const RegisterBankInfo *getRegBankInfo() const override {
|
const RegisterBankInfo *getRegBankInfo() const override {
|
||||||
@ -247,7 +247,7 @@ AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
|
|||||||
new AArch64GISelActualAccessor();
|
new AArch64GISelActualAccessor();
|
||||||
GISel->CallLoweringInfo.reset(
|
GISel->CallLoweringInfo.reset(
|
||||||
new AArch64CallLowering(*I->getTargetLowering()));
|
new AArch64CallLowering(*I->getTargetLowering()));
|
||||||
GISel->Legalizer.reset(new AArch64MachineLegalizer());
|
GISel->Legalizer.reset(new AArch64LegalizerInfo());
|
||||||
|
|
||||||
auto *RBI = new AArch64RegisterBankInfo(*I->getRegisterInfo());
|
auto *RBI = new AArch64RegisterBankInfo(*I->getRegisterInfo());
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ bool AArch64PassConfig::addIRTranslator() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool AArch64PassConfig::addLegalizeMachineIR() {
|
bool AArch64PassConfig::addLegalizeMachineIR() {
|
||||||
addPass(new MachineLegalizePass());
|
addPass(new Legalizer());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool AArch64PassConfig::addRegBankSelect() {
|
bool AArch64PassConfig::addRegBankSelect() {
|
||||||
|
@ -20,7 +20,7 @@ add_public_tablegen_target(AArch64CommonTableGen)
|
|||||||
set(GLOBAL_ISEL_FILES
|
set(GLOBAL_ISEL_FILES
|
||||||
AArch64CallLowering.cpp
|
AArch64CallLowering.cpp
|
||||||
AArch64InstructionSelector.cpp
|
AArch64InstructionSelector.cpp
|
||||||
AArch64MachineLegalizer.cpp
|
AArch64LegalizerInfo.cpp
|
||||||
AArch64RegisterBankInfo.cpp
|
AArch64RegisterBankInfo.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llc -O0 -run-pass=legalize-mir -global-isel %s -o - 2>&1 | FileCheck %s
|
# RUN: llc -O0 -run-pass=legalizer -global-isel %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
--- |
|
--- |
|
||||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
|
@ -20,4 +20,4 @@ entry:
|
|||||||
%sext = shl <4 x i32> %mul.i, <i32 16, i32 16, i32 16, i32 16>
|
%sext = shl <4 x i32> %mul.i, <i32 16, i32 16, i32 16, i32 16>
|
||||||
%vmovl.i.i = ashr <4 x i32> %sext, <i32 16, i32 16, i32 16, i32 16>
|
%vmovl.i.i = ashr <4 x i32> %sext, <i32 16, i32 16, i32 16, i32 16>
|
||||||
ret <4 x i32> %vmovl.i.i
|
ret <4 x i32> %vmovl.i.i
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,4 @@ define double @test_fms_fold(double %a, double %b) {
|
|||||||
%mul1 = fmul double %b, 0.000000e+00
|
%mul1 = fmul double %b, 0.000000e+00
|
||||||
%sub = fsub double %mul, %mul1
|
%sub = fsub double %mul, %mul1
|
||||||
ret double %sub
|
ret double %sub
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
; RUN: llc -mtriple=arm64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK-ELF
|
; RUN: llc -mtriple=arm64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK-ELF
|
||||||
|
|
||||||
; CHECK-MACHO: .subsections_via_symbols
|
; CHECK-MACHO: .subsections_via_symbols
|
||||||
; CHECK-ELF-NOT: .subsections_via_symbols
|
; CHECK-ELF-NOT: .subsections_via_symbols
|
||||||
|
@ -26,4 +26,4 @@ bb1:
|
|||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes #0 = { nounwind }
|
attributes #0 = { nounwind }
|
||||||
|
@ -9,4 +9,4 @@ define void @foo() {
|
|||||||
; CHECK-OBJ: 0: c0 03 5f d6 ret
|
; CHECK-OBJ: 0: c0 03 5f d6 ret
|
||||||
|
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ set(LLVM_LINK_COMPONENTS
|
|||||||
|
|
||||||
if(LLVM_BUILD_GLOBAL_ISEL)
|
if(LLVM_BUILD_GLOBAL_ISEL)
|
||||||
add_llvm_unittest(GlobalISelTests
|
add_llvm_unittest(GlobalISelTests
|
||||||
MachineLegalizerTest.cpp
|
LegalizerInfoTest.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
120
unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
Normal file
120
unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
//===- llvm/unittest/CodeGen/GlobalISel/LegalizerInfoTest.cpp -------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
||||||
|
#include "llvm/Target/TargetOpcodes.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
// Define a couple of pretty printers to help debugging when things go wrong.
|
||||||
|
namespace llvm {
|
||||||
|
std::ostream &
|
||||||
|
operator<<(std::ostream &OS, const llvm::LegalizerInfo::LegalizeAction Act) {
|
||||||
|
switch (Act) {
|
||||||
|
case LegalizerInfo::Lower: OS << "Lower"; break;
|
||||||
|
case LegalizerInfo::Legal: OS << "Legal"; break;
|
||||||
|
case LegalizerInfo::NarrowScalar: OS << "NarrowScalar"; break;
|
||||||
|
case LegalizerInfo::WidenScalar: OS << "WidenScalar"; break;
|
||||||
|
case LegalizerInfo::FewerElements: OS << "FewerElements"; break;
|
||||||
|
case LegalizerInfo::MoreElements: OS << "MoreElements"; break;
|
||||||
|
case LegalizerInfo::Libcall: OS << "Libcall"; break;
|
||||||
|
case LegalizerInfo::Custom: OS << "Custom"; break;
|
||||||
|
case LegalizerInfo::Unsupported: OS << "Unsupported"; break;
|
||||||
|
case LegalizerInfo::NotFound: OS << "NotFound";
|
||||||
|
}
|
||||||
|
return OS;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &
|
||||||
|
operator<<(std::ostream &OS, const llvm::LLT Ty) {
|
||||||
|
std::string Repr;
|
||||||
|
raw_string_ostream SS{Repr};
|
||||||
|
Ty.print(SS);
|
||||||
|
OS << SS.str();
|
||||||
|
return OS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
|
TEST(LegalizerInfoTest, ScalarRISC) {
|
||||||
|
using namespace TargetOpcode;
|
||||||
|
LegalizerInfo L;
|
||||||
|
// Typical RISCy set of operations based on AArch64.
|
||||||
|
L.setAction({G_ADD, LLT::scalar(8)}, LegalizerInfo::WidenScalar);
|
||||||
|
L.setAction({G_ADD, LLT::scalar(16)}, LegalizerInfo::WidenScalar);
|
||||||
|
L.setAction({G_ADD, LLT::scalar(32)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::scalar(64)}, LegalizerInfo::Legal);
|
||||||
|
L.computeTables();
|
||||||
|
|
||||||
|
// Check we infer the correct types and actually do what we're told.
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(8)}),
|
||||||
|
std::make_pair(LegalizerInfo::WidenScalar, LLT::scalar(32)));
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(16)}),
|
||||||
|
std::make_pair(LegalizerInfo::WidenScalar, LLT::scalar(32)));
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(32)}),
|
||||||
|
std::make_pair(LegalizerInfo::Legal, LLT::scalar(32)));
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(64)}),
|
||||||
|
std::make_pair(LegalizerInfo::Legal, LLT::scalar(64)));
|
||||||
|
|
||||||
|
// Make sure the default for over-sized types applies.
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(128)}),
|
||||||
|
std::make_pair(LegalizerInfo::NarrowScalar, LLT::scalar(64)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(LegalizerInfoTest, VectorRISC) {
|
||||||
|
using namespace TargetOpcode;
|
||||||
|
LegalizerInfo L;
|
||||||
|
// Typical RISCy set of operations based on ARM.
|
||||||
|
L.setScalarInVectorAction(G_ADD, LLT::scalar(8), LegalizerInfo::Legal);
|
||||||
|
L.setScalarInVectorAction(G_ADD, LLT::scalar(16), LegalizerInfo::Legal);
|
||||||
|
L.setScalarInVectorAction(G_ADD, LLT::scalar(32), LegalizerInfo::Legal);
|
||||||
|
|
||||||
|
L.setAction({G_ADD, LLT::vector(8, 8)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::vector(16, 8)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::vector(4, 16)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::vector(8, 16)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::vector(2, 32)}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_ADD, LLT::vector(4, 32)}, LegalizerInfo::Legal);
|
||||||
|
L.computeTables();
|
||||||
|
|
||||||
|
// Check we infer the correct types and actually do what we're told for some
|
||||||
|
// simple cases.
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(2, 8)}),
|
||||||
|
std::make_pair(LegalizerInfo::MoreElements, LLT::vector(8, 8)));
|
||||||
|
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(8, 8)}),
|
||||||
|
std::make_pair(LegalizerInfo::Legal, LLT::vector(8, 8)));
|
||||||
|
ASSERT_EQ(
|
||||||
|
L.getAction({G_ADD, LLT::vector(8, 32)}),
|
||||||
|
std::make_pair(LegalizerInfo::FewerElements, LLT::vector(4, 32)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(LegalizerInfoTest, MultipleTypes) {
|
||||||
|
using namespace TargetOpcode;
|
||||||
|
LegalizerInfo L;
|
||||||
|
LLT p0 = LLT::pointer(0, 64);
|
||||||
|
LLT s32 = LLT::scalar(32);
|
||||||
|
LLT s64 = LLT::scalar(64);
|
||||||
|
|
||||||
|
// Typical RISCy set of operations based on AArch64.
|
||||||
|
L.setAction({G_PTRTOINT, 0, s64}, LegalizerInfo::Legal);
|
||||||
|
L.setAction({G_PTRTOINT, 1, p0}, LegalizerInfo::Legal);
|
||||||
|
|
||||||
|
L.setAction({G_PTRTOINT, 0, s32}, LegalizerInfo::WidenScalar);
|
||||||
|
L.computeTables();
|
||||||
|
|
||||||
|
// Check we infer the correct types and actually do what we're told.
|
||||||
|
ASSERT_EQ(L.getAction({G_PTRTOINT, 0, s64}),
|
||||||
|
std::make_pair(LegalizerInfo::Legal, s64));
|
||||||
|
ASSERT_EQ(L.getAction({G_PTRTOINT, 1, p0}),
|
||||||
|
std::make_pair(LegalizerInfo::Legal, p0));
|
||||||
|
}
|
||||||
|
}
|
@ -1,120 +0,0 @@
|
|||||||
//===- llvm/unittest/CodeGen/GlobalISel/MachineLegalizerTest.cpp ----------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is distributed under the University of Illinois Open Source
|
|
||||||
// License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
|
|
||||||
#include "llvm/Target/TargetOpcodes.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
using namespace llvm;
|
|
||||||
|
|
||||||
// Define a couple of pretty printers to help debugging when things go wrong.
|
|
||||||
namespace llvm {
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &OS, const llvm::MachineLegalizer::LegalizeAction Act) {
|
|
||||||
switch (Act) {
|
|
||||||
case MachineLegalizer::Lower: OS << "Lower"; break;
|
|
||||||
case MachineLegalizer::Legal: OS << "Legal"; break;
|
|
||||||
case MachineLegalizer::NarrowScalar: OS << "NarrowScalar"; break;
|
|
||||||
case MachineLegalizer::WidenScalar: OS << "WidenScalar"; break;
|
|
||||||
case MachineLegalizer::FewerElements: OS << "FewerElements"; break;
|
|
||||||
case MachineLegalizer::MoreElements: OS << "MoreElements"; break;
|
|
||||||
case MachineLegalizer::Libcall: OS << "Libcall"; break;
|
|
||||||
case MachineLegalizer::Custom: OS << "Custom"; break;
|
|
||||||
case MachineLegalizer::Unsupported: OS << "Unsupported"; break;
|
|
||||||
case MachineLegalizer::NotFound: OS << "NotFound";
|
|
||||||
}
|
|
||||||
return OS;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &OS, const llvm::LLT Ty) {
|
|
||||||
std::string Repr;
|
|
||||||
raw_string_ostream SS{Repr};
|
|
||||||
Ty.print(SS);
|
|
||||||
OS << SS.str();
|
|
||||||
return OS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
|
|
||||||
TEST(MachineLegalizerTest, ScalarRISC) {
|
|
||||||
using namespace TargetOpcode;
|
|
||||||
MachineLegalizer L;
|
|
||||||
// Typical RISCy set of operations based on AArch64.
|
|
||||||
L.setAction({G_ADD, LLT::scalar(8)}, MachineLegalizer::WidenScalar);
|
|
||||||
L.setAction({G_ADD, LLT::scalar(16)}, MachineLegalizer::WidenScalar);
|
|
||||||
L.setAction({G_ADD, LLT::scalar(32)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::scalar(64)}, MachineLegalizer::Legal);
|
|
||||||
L.computeTables();
|
|
||||||
|
|
||||||
// Check we infer the correct types and actually do what we're told.
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(8)}),
|
|
||||||
std::make_pair(MachineLegalizer::WidenScalar, LLT::scalar(32)));
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(16)}),
|
|
||||||
std::make_pair(MachineLegalizer::WidenScalar, LLT::scalar(32)));
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(32)}),
|
|
||||||
std::make_pair(MachineLegalizer::Legal, LLT::scalar(32)));
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(64)}),
|
|
||||||
std::make_pair(MachineLegalizer::Legal, LLT::scalar(64)));
|
|
||||||
|
|
||||||
// Make sure the default for over-sized types applies.
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::scalar(128)}),
|
|
||||||
std::make_pair(MachineLegalizer::NarrowScalar, LLT::scalar(64)));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(MachineLegalizerTest, VectorRISC) {
|
|
||||||
using namespace TargetOpcode;
|
|
||||||
MachineLegalizer L;
|
|
||||||
// Typical RISCy set of operations based on ARM.
|
|
||||||
L.setScalarInVectorAction(G_ADD, LLT::scalar(8), MachineLegalizer::Legal);
|
|
||||||
L.setScalarInVectorAction(G_ADD, LLT::scalar(16), MachineLegalizer::Legal);
|
|
||||||
L.setScalarInVectorAction(G_ADD, LLT::scalar(32), MachineLegalizer::Legal);
|
|
||||||
|
|
||||||
L.setAction({G_ADD, LLT::vector(8, 8)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::vector(16, 8)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::vector(4, 16)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::vector(8, 16)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::vector(2, 32)}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_ADD, LLT::vector(4, 32)}, MachineLegalizer::Legal);
|
|
||||||
L.computeTables();
|
|
||||||
|
|
||||||
// Check we infer the correct types and actually do what we're told for some
|
|
||||||
// simple cases.
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(2, 8)}),
|
|
||||||
std::make_pair(MachineLegalizer::MoreElements, LLT::vector(8, 8)));
|
|
||||||
ASSERT_EQ(L.getAction({G_ADD, LLT::vector(8, 8)}),
|
|
||||||
std::make_pair(MachineLegalizer::Legal, LLT::vector(8, 8)));
|
|
||||||
ASSERT_EQ(
|
|
||||||
L.getAction({G_ADD, LLT::vector(8, 32)}),
|
|
||||||
std::make_pair(MachineLegalizer::FewerElements, LLT::vector(4, 32)));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(MachineLegalizerTest, MultipleTypes) {
|
|
||||||
using namespace TargetOpcode;
|
|
||||||
MachineLegalizer L;
|
|
||||||
LLT p0 = LLT::pointer(0, 64);
|
|
||||||
LLT s32 = LLT::scalar(32);
|
|
||||||
LLT s64 = LLT::scalar(64);
|
|
||||||
|
|
||||||
// Typical RISCy set of operations based on AArch64.
|
|
||||||
L.setAction({G_PTRTOINT, 0, s64}, MachineLegalizer::Legal);
|
|
||||||
L.setAction({G_PTRTOINT, 1, p0}, MachineLegalizer::Legal);
|
|
||||||
|
|
||||||
L.setAction({G_PTRTOINT, 0, s32}, MachineLegalizer::WidenScalar);
|
|
||||||
L.computeTables();
|
|
||||||
|
|
||||||
// Check we infer the correct types and actually do what we're told.
|
|
||||||
ASSERT_EQ(L.getAction({G_PTRTOINT, 0, s64}),
|
|
||||||
std::make_pair(MachineLegalizer::Legal, s64));
|
|
||||||
ASSERT_EQ(L.getAction({G_PTRTOINT, 1, p0}),
|
|
||||||
std::make_pair(MachineLegalizer::Legal, p0));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user