summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2018-01-24 17:17:46 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2018-01-24 17:17:46 +0000
commit262ed0ecd715afe3e1c0194a80317e3d342ebc5c (patch)
tree0acbdb2adf045acbefd0f2696b78508064f267c3 /llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
parent5803a6744e0623ca72bcb9d0535ef7fd0e3b8163 (diff)
downloadbcm5719-llvm-262ed0ecd715afe3e1c0194a80317e3d342ebc5c.tar.gz
bcm5719-llvm-262ed0ecd715afe3e1c0194a80317e3d342ebc5c.zip
[globalisel] Introduce LegalityQuery to better encapsulate the legalizer decisions. NFC.
Summary: `getAction(const InstrAspect &) const` breaks encapsulation by exposing the smaller components that are used to decide how to legalize an instruction. This is a problem because we need to change the implementation of LegalizerInfo so that it's able to describe particular type combinations rather than just cartesian products of types. For example, declaring the following setAction({..., 0, s32}, Legal) setAction({..., 0, s64}, Legal) setAction({..., 1, s32}, Legal) setAction({..., 1, s64}, Legal) currently declares these type combinations as legal: {s32, s32} {s64, s32} {s32, s64} {s64, s64} but we currently have no means to say that, for example, {s64, s32} is not legal. Some operations such as G_INSERT/G_EXTRACT/G_MERGE_VALUES/ G_UNMERGE_VALUES has relationships between the types that are currently described incorrectly. Additionally, G_LOAD/G_STORE currently have no means to legalize non-atomics differently to atomics. The necessary information is in the MMO but we have no way to use this in the legalizer. Similarly, there is currently no way for the register type and the memory type to differ so there is no way to cleanly represent extending-load/truncating-store in a way that can't be broken by optimizers (resulting in illegal MIR). This patch introduces LegalityQuery which provides all the information needed by the legalizer to make a decision on whether something is legal and how to legalize it. Reviewers: ab, t.p.northover, qcolombet, rovka, aditya_nandakumar, volkan, reames, bogner Reviewed By: bogner Subscribers: bogner, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D42244 llvm-svn: 323342
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index f1cb5c0ad02..d8dc936eef2 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -36,8 +36,8 @@ LegalizerHelper::LegalizeResult
LegalizerHelper::legalizeInstrStep(MachineInstr &MI) {
DEBUG(dbgs() << "Legalizing: "; MI.print(dbgs()));
- auto Action = LI.getAction(MI, MRI);
- switch (std::get<0>(Action)) {
+ auto Step = LI.getAction(MI, MRI);
+ switch (Step.Action) {
case LegalizerInfo::Legal:
DEBUG(dbgs() << ".. Already legal\n");
return AlreadyLegal;
@@ -46,16 +46,16 @@ LegalizerHelper::legalizeInstrStep(MachineInstr &MI) {
return libcall(MI);
case LegalizerInfo::NarrowScalar:
DEBUG(dbgs() << ".. Narrow scalar\n");
- return narrowScalar(MI, std::get<1>(Action), std::get<2>(Action));
+ return narrowScalar(MI, Step.TypeIdx, Step.NewType);
case LegalizerInfo::WidenScalar:
DEBUG(dbgs() << ".. Widen scalar\n");
- return widenScalar(MI, std::get<1>(Action), std::get<2>(Action));
+ return widenScalar(MI, Step.TypeIdx, Step.NewType);
case LegalizerInfo::Lower:
DEBUG(dbgs() << ".. Lower\n");
- return lower(MI, std::get<1>(Action), std::get<2>(Action));
+ return lower(MI, Step.TypeIdx, Step.NewType);
case LegalizerInfo::FewerElements:
DEBUG(dbgs() << ".. Reduce number of elements\n");
- return fewerElementsVector(MI, std::get<1>(Action), std::get<2>(Action));
+ return fewerElementsVector(MI, Step.TypeIdx, Step.NewType);
case LegalizerInfo::Custom:
DEBUG(dbgs() << ".. Custom legalization\n");
return LI.legalizeCustom(MI, MRI, MIRBuilder) ? Legalized
@@ -924,7 +924,7 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
// Lower (G_FSUB LHS, RHS) to (G_FADD LHS, (G_FNEG RHS)).
// First, check if G_FNEG is marked as Lower. If so, we may
// end up with an infinite loop as G_FSUB is used to legalize G_FNEG.
- if (LI.getAction({G_FNEG, Ty}).first == LegalizerInfo::Lower)
+ if (LI.getAction({G_FNEG, {Ty}}).Action == LegalizerInfo::Lower)
return UnableToLegalize;
unsigned Res = MI.getOperand(0).getReg();
unsigned LHS = MI.getOperand(1).getReg();
OpenPOWER on IntegriCloud