Commit ff1f3cc1 authored by Quentin Colombet's avatar Quentin Colombet
Browse files

[GISelKnownBits] Make the max depth a parameter of the analysis

Allow users of that analysis to define the cut off depth of the
analysis instead of hardcoding 6.

NFC as the default parameter is 6.
parent 28857d14
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -31,9 +31,10 @@ class GISelKnownBits : public GISelChangeObserver {
  MachineRegisterInfo &MRI;
  const TargetLowering &TL;
  const DataLayout &DL;
  unsigned MaxDepth;

public:
  GISelKnownBits(MachineFunction &MF);
  GISelKnownBits(MachineFunction &MF, unsigned MaxDepth = 6);
  virtual ~GISelKnownBits() = default;
  void setMF(MachineFunction &MF);
  virtual void computeKnownBitsImpl(Register R, KnownBits &Known,
@@ -82,7 +83,7 @@ public:
  void changedInstr(MachineInstr &MI) override{};

protected:
  unsigned getMaxDepth() const { return 6; }
  unsigned getMaxDepth() const { return MaxDepth; }
};

/// To use KnownBitsInfo analysis in a pass,
+4 −6
Original line number Diff line number Diff line
@@ -24,14 +24,12 @@ using namespace llvm;

char llvm::GISelKnownBitsAnalysis::ID = 0;

INITIALIZE_PASS_BEGIN(GISelKnownBitsAnalysis, DEBUG_TYPE,
                      "Analysis for ComputingKnownBits", false, true)
INITIALIZE_PASS_END(GISelKnownBitsAnalysis, DEBUG_TYPE,
INITIALIZE_PASS(GISelKnownBitsAnalysis, DEBUG_TYPE,
                "Analysis for ComputingKnownBits", false, true)

GISelKnownBits::GISelKnownBits(MachineFunction &MF)
GISelKnownBits::GISelKnownBits(MachineFunction &MF, unsigned MaxDepth)
    : MF(MF), MRI(MF.getRegInfo()), TL(*MF.getSubtarget().getTargetLowering()),
      DL(MF.getFunction().getParent()->getDataLayout()) {}
      DL(MF.getFunction().getParent()->getDataLayout()), MaxDepth(MaxDepth) {}

Align GISelKnownBits::inferAlignmentForFrameIdx(int FrameIdx, int Offset,
                                                const MachineFunction &MF) {