[PATCH] D81502: GlobalISel: Make default implementation of legalizeCustom unreachable

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 14:21:34 PDT 2020


arsenm created this revision.
arsenm added reviewers: aemerson, aditya_nandakumar, paquette, dsanders, gargaroff.
Herald added subscribers: hiraditya, rovka, wdng.
Herald added a project: LLVM.

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.


https://reviews.llvm.org/D81502

Files:
  llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
  llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp


Index: llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -524,12 +524,6 @@
   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 @@
                       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;
 }
Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -1210,14 +1210,19 @@
   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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81502.269662.patch
Type: text/x-patch
Size: 2557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200609/8d137608/attachment.bin>


More information about the llvm-commits mailing list