From 0f2af15c1b00a08b84b780143001e04a25994628 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 9 Jun 2020 16:57:53 -0400 Subject: [PATCH] GlobalISel: Make default implementation of legalizeCustom unreachable If the target explicitly requested custom legalization, it should be required to implement this. Also move default legalizeIntrinsic implementation into the header so it's next to the related legalizeCustom. --- llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h | 13 +++++++++---- llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp | 12 ------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h index cc549c4..8185cd5 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h @@ -1210,14 +1210,19 @@ public: bool isLegalOrCustom(const MachineInstr &MI, const MachineRegisterInfo &MRI) const; + /// Called for instructions with the Custom LegalizationAction. virtual bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder, - GISelChangeObserver &Observer) const; + GISelChangeObserver &Observer) const { + llvm_unreachable("must implement this if custom action is used"); + } - /// Return true if MI is either legal or has been legalized and false - /// if not legal. + /// \returns true if MI is either legal or has been legalized and false if not + /// legal. virtual bool legalizeIntrinsic(MachineInstr &MI, MachineIRBuilder &MIRBuilder, - GISelChangeObserver &Observer) const; + GISelChangeObserver &Observer) const { + return true; + } /// Return the opcode (SEXT/ZEXT/ANYEXT) that should be performed while /// widening a constant of type SmallTy which targets can override. diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp index 5a8f8fd..4abd0c4 100644 --- a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp @@ -524,12 +524,6 @@ bool LegalizerInfo::isLegalOrCustom(const MachineInstr &MI, return Action == Legal || Action == Custom; } -bool LegalizerInfo::legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, - MachineIRBuilder &MIRBuilder, - GISelChangeObserver &Observer) const { - return false; -} - LegalizerInfo::SizeAndActionsVec LegalizerInfo::increaseToLargerTypesAndDecreaseToLargest( const SizeAndActionsVec &v, LegalizeAction IncreaseAction, @@ -687,12 +681,6 @@ LegalizerInfo::findVectorLegalAction(const InstrAspect &Aspect) const { IntermediateType.getScalarSizeInBits())}; } -bool LegalizerInfo::legalizeIntrinsic(MachineInstr &MI, - MachineIRBuilder &MIRBuilder, - GISelChangeObserver &Observer) const { - return true; -} - unsigned LegalizerInfo::getExtOpcodeForWideningConstant(LLT SmallTy) const { return SmallTy.isByteSized() ? TargetOpcode::G_SEXT : TargetOpcode::G_ZEXT; } -- 2.7.4