[PATCH] D23067: TargetInstrInfo: add two new target hooks to analyse branch offsets

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 13:23:11 PDT 2016


arsenm added inline comments.

================
Comment at: include/llvm/Target/TargetInstrInfo.h:495-506
@@ -483,1 +494,14 @@
+
+  /// Return the upperbound value of the supported branch range, or -1 if
+  /// it is not implemented.
+  virtual int64_t getBranchRangeUpperbound(unsigned Opcode) const {
+    return -1;
+  }
+
+  /// Return the lowerbound value of the supported branch range, or 1 if
+  /// it is not implemented.
+  virtual int64_t getBranchRangeLowerbound(unsigned Opcode) const {
+    return 1;
+  }
+
   /// Represents a predicate at the MachineFunction level.  The control flow a
----------------
SjoerdMeijer wrote:
> arsenm wrote:
> > Why do you need these? I don't think these are the right API, and the isBranchOffsetInRange is better
> I think I need both the isBranchOffsetInRange and the getBranchRange (or similar) functions. A check to see if a branch is in range is one thing, but for moving a block in range actual values are needed. Looking at BranchRelaxation and AArch64InstrInfo.cpp, I now see I probably want to have this in the base class: 
> 
> static unsigned getBranchDisplacementBits(unsigned Opc)
> 
> because that's what I am trying to do.
In my patches I avoid this, because in AMDGPU I need to add an additional offset to the branch distance, because the distance is computed from the address of the next instruction which I think is more awkward to express this way


https://reviews.llvm.org/D23067





More information about the llvm-commits mailing list