GlobalISel: Make default implementation of legalizeCustom unreachable
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 9 Jun 2020 20:57:53 +0000 (16:57 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 10 Jun 2020 15:05:59 +0000 (11:05 -0400)
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
llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp

index cc549c4..8185cd5 100644 (file)
@@ -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.
index 5a8f8fd..4abd0c4 100644 (file)
@@ -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;
 }