Commit b415bf98 authored by Chandler Carruth's avatar Chandler Carruth
Browse files

This reverts a long string of commits to the Hexagon backend. These

commits have had several major issues pointed out in review, and those
issues are not being addressed in a timely fashion. Furthermore, this
was all committed leading up to the v3.1 branch, and we don't need piles
of code with outstanding issues in the branch.

It is possible that not all of these commits were necessary to revert to
get us back to a green state, but I'm going to let the Hexagon
maintainer sort that out. They can recommit, in order, after addressing
the feedback.

Reverted commits, with some notes:

Primary commit r154616: HexagonPacketizer
  - There are lots of review comments here. This is the primary reason
    for reverting. In particular, it introduced large amount of warnings
    due to a bad construct in tablegen.
  - Follow-up commits that should be folded back into this when
    reposting:
    - r154622: CMake fixes
    - r154660: Fix numerous build warnings in release builds.
  - Please don't resubmit this until the three commits above are
    included, and the issues in review addressed.

Primary commit r154695: Pass to replace transfer/copy ...
  - Reverted to minimize merge conflicts. I'm not aware of specific
    issues with this patch.

Primary commit r154703: New Value Jump.
  - Primarily reverted due to merge conflicts.
  - Follow-up commits that should be folded back into this when
    reposting:
    - r154703: Remove iostream usage
    - r154758: Fix CMake builds
    - r154759: Fix build warnings in release builds
  - Please incorporate these fixes and and review feedback before
    resubmitting.

Primary commit r154829: Hexagon V5 (floating point) support.
  - Primarily reverted due to merge conflicts.
  - Follow-up commits that should be folded back into this when
    reposting:
    - r154841: Remove unused variable (fixing build warnings)

There are also accompanying Clang commits that will be reverted for
consistency.

llvm-svn: 155047
parent af54653c
Loading
Loading
Loading
Loading
+12 −32
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@

#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/ADT/DenseMap.h"
#include <map>

namespace llvm {

@@ -37,7 +36,7 @@ class MachineInstr;
class MachineLoopInfo;
class MachineDominatorTree;
class InstrItineraryData;
class DefaultVLIWScheduler;
class ScheduleDAGInstrs;
class SUnit;

class DFAPacketizer {
@@ -78,8 +77,6 @@ public:
  // reserveResources - Reserve the resources occupied by a machine
  // instruction and change the current state to reflect that change.
  void reserveResources(llvm::MachineInstr *MI);

  const InstrItineraryData *getInstrItins() const { return InstrItins; }
};

// VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The
@@ -90,21 +87,20 @@ public:
// and machine resource is marked as taken. If any dependency is found, a target
// API call is made to prune the dependence.
class VLIWPacketizerList {
protected:
  const TargetMachine &TM;
  const MachineFunction &MF;
  const TargetInstrInfo *TII;

  // The VLIW Scheduler.
  DefaultVLIWScheduler *VLIWScheduler;
  // Encapsulate data types not exposed to the target interface.
  ScheduleDAGInstrs *SchedulerImpl;

protected:
  // Vector of instructions assigned to the current packet.
  std::vector<MachineInstr*> CurrentPacketMIs;
  // DFA resource tracker.
  DFAPacketizer *ResourceTracker;

  // Generate MI -> SU map.
  std::map<MachineInstr*, SUnit*> MIToSUnit;
  // Scheduling units.
  std::vector<SUnit> SUnits;

public:
  VLIWPacketizerList(
@@ -122,32 +118,17 @@ public:
  DFAPacketizer *getResourceTracker() {return ResourceTracker;}

  // addToPacket - Add MI to the current packet.
  virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) {
    MachineBasicBlock::iterator MII = MI;
    CurrentPacketMIs.push_back(MI);
    ResourceTracker->reserveResources(MI);
    return MII;
  }
  void addToPacket(MachineInstr *MI);

  // endPacket - End the current packet.
  void endPacket(MachineBasicBlock *MBB, MachineInstr *MI);

  // initPacketizerState - perform initialization before packetizing
  // an instruction. This function is supposed to be overrided by
  // the target dependent packetizer.
  virtual void initPacketizerState(void) { return; }
  void endPacket(MachineBasicBlock *MBB, MachineInstr *I);

  // ignorePseudoInstruction - Ignore bundling of pseudo instructions.
  virtual bool ignorePseudoInstruction(MachineInstr *I,
                                       MachineBasicBlock *MBB) {
    return false;
  }
  bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB);

  // isSoloInstruction - return true if instruction MI can not be packetized
  // with any other instruction, which means that MI itself is a packet.
  virtual bool isSoloInstruction(MachineInstr *MI) {
    return true;
  }
  // isSoloInstruction - return true if instruction I must end previous
  // packet.
  bool isSoloInstruction(MachineInstr *I);

  // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ
  // together.
@@ -160,7 +141,6 @@ public:
  virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) {
    return false;
  }

};
}

+347 −1553

File changed.

Preview size limit exceeded, changes collapsed.

+55 −34
Original line number Diff line number Diff line
@@ -23,10 +23,10 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/ScheduleDAGInstrs.h"
#include "llvm/CodeGen/DFAPacketizer.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/MC/MCInstrItineraries.h"
using namespace llvm;
@@ -100,7 +100,7 @@ void DFAPacketizer::reserveResources(llvm::MachineInstr *MI) {
  reserveResources(&MID);
}

namespace llvm {
namespace {
// DefaultVLIWScheduler - This class extends ScheduleDAGInstrs and overrides
// Schedule method to build the dependence graph.
class DefaultVLIWScheduler : public ScheduleDAGInstrs {
@@ -110,7 +110,7 @@ public:
  // Schedule - Actual scheduling work.
  void schedule();
};
}
} // end anonymous namespace

DefaultVLIWScheduler::DefaultVLIWScheduler(
  MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT,
@@ -129,25 +129,49 @@ VLIWPacketizerList::VLIWPacketizerList(
  bool IsPostRA) : TM(MF.getTarget()), MF(MF)  {
  TII = TM.getInstrInfo();
  ResourceTracker = TII->CreateTargetScheduleState(&TM, 0);
  VLIWScheduler = new DefaultVLIWScheduler(MF, MLI, MDT, IsPostRA);
  SchedulerImpl = new DefaultVLIWScheduler(MF, MLI, MDT, IsPostRA);
}

// VLIWPacketizerList Dtor
VLIWPacketizerList::~VLIWPacketizerList() {
  if (VLIWScheduler)
    delete VLIWScheduler;

  if (ResourceTracker)
  delete SchedulerImpl;
  delete ResourceTracker;
}

// ignorePseudoInstruction - ignore pseudo instructions.
bool VLIWPacketizerList::ignorePseudoInstruction(MachineInstr *MI,
                                                 MachineBasicBlock *MBB) {
  if (MI->isDebugValue())
    return true;

  if (TII->isSchedulingBoundary(MI, MBB, MF))
    return true;

  return false;
}

// isSoloInstruction - return true if instruction I must end previous
// packet.
bool VLIWPacketizerList::isSoloInstruction(MachineInstr *I) {
  if (I->isInlineAsm())
    return true;

  return false;
}

// addToPacket - Add I to the current packet and reserve resource.
void VLIWPacketizerList::addToPacket(MachineInstr *MI) {
  CurrentPacketMIs.push_back(MI);
  ResourceTracker->reserveResources(MI);
}

// endPacket - End the current packet, bundle packet instructions and reset
// DFA state.
void VLIWPacketizerList::endPacket(MachineBasicBlock *MBB,
                                         MachineInstr *MI) {
                                         MachineInstr *I) {
  if (CurrentPacketMIs.size() > 1) {
    MachineInstr *MIFirst = CurrentPacketMIs.front();
    finalizeBundle(*MBB, MIFirst, MI);
    finalizeBundle(*MBB, MIFirst, I);
  }
  CurrentPacketMIs.clear();
  ResourceTracker->clearResources();
@@ -157,36 +181,31 @@ void VLIWPacketizerList::endPacket(MachineBasicBlock *MBB,
void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
                                      MachineBasicBlock::iterator BeginItr,
                                      MachineBasicBlock::iterator EndItr) {
  assert(VLIWScheduler && "VLIW Scheduler is not initialized!");
  VLIWScheduler->enterRegion(MBB, BeginItr, EndItr, MBB->size());
  VLIWScheduler->schedule();
  VLIWScheduler->exitRegion();
  assert(MBB->end() == EndItr && "Bad EndIndex");

  // Generate MI -> SU map.
  //std::map <MachineInstr*, SUnit*> MIToSUnit;
  MIToSUnit.clear();
  for (unsigned i = 0, e = VLIWScheduler->SUnits.size(); i != e; ++i) {
    SUnit *SU = &VLIWScheduler->SUnits[i];
    MIToSUnit[SU->getInstr()] = SU;
  }
  SchedulerImpl->enterRegion(MBB, BeginItr, EndItr, MBB->size());

  // Build the DAG without reordering instructions.
  SchedulerImpl->schedule();

  // Remember scheduling units.
  SUnits = SchedulerImpl->SUnits;

  // The main packetizer loop.
  for (; BeginItr != EndItr; ++BeginItr) {
    MachineInstr *MI = BeginItr;

    this->initPacketizerState();
    // Ignore pseudo instructions.
    if (ignorePseudoInstruction(MI, MBB))
      continue;

    // End the current packet if needed.
    if (this->isSoloInstruction(MI)) {
    if (isSoloInstruction(MI)) {
      endPacket(MBB, MI);
      continue;
    }

    // Ignore pseudo instructions.
    if (this->ignorePseudoInstruction(MI, MBB))
      continue;

    SUnit *SUI = MIToSUnit[MI];
    SUnit *SUI = SchedulerImpl->getSUnit(MI);
    assert(SUI && "Missing SUnit Info!");

    // Ask DFA if machine resource is available for MI.
@@ -196,13 +215,13 @@ void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
      for (std::vector<MachineInstr*>::iterator VI = CurrentPacketMIs.begin(),
           VE = CurrentPacketMIs.end(); VI != VE; ++VI) {
        MachineInstr *MJ = *VI;
        SUnit *SUJ = MIToSUnit[MJ];
        SUnit *SUJ = SchedulerImpl->getSUnit(MJ);
        assert(SUJ && "Missing SUnit Info!");

        // Is it legal to packetize SUI and SUJ together.
        if (!this->isLegalToPacketizeTogether(SUI, SUJ)) {
        if (!isLegalToPacketizeTogether(SUI, SUJ)) {
          // Allow packetization if dependency can be pruned.
          if (!this->isLegalToPruneDependencies(SUI, SUJ)) {
          if (!isLegalToPruneDependencies(SUI, SUJ)) {
            // End the packet if dependency cannot be pruned.
            endPacket(MBB, MI);
            break;
@@ -215,9 +234,11 @@ void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
    }

    // Add MI to the current packet.
    BeginItr = this->addToPacket(MI);
    addToPacket(MI);
  } // For all instructions in BB.

  // End any packet left behind.
  endPacket(MBB, EndItr);

  SchedulerImpl->exitRegion();
}
+3 −6
Original line number Diff line number Diff line
@@ -11,15 +11,15 @@ add_public_tablegen_target(HexagonCommonTableGen)

add_llvm_target(HexagonCodeGen
  HexagonAsmPrinter.cpp
  HexagonCFGOptimizer.cpp
  HexagonCallingConvLower.cpp
  HexagonCFGOptimizer.cpp
  HexagonExpandPredSpillCode.cpp
  HexagonFrameLowering.cpp
  HexagonHardwareLoops.cpp
  HexagonMCInstLower.cpp
  HexagonInstrInfo.cpp
  HexagonISelDAGToDAG.cpp
  HexagonISelLowering.cpp
  HexagonInstrInfo.cpp
  HexagonMCInstLower.cpp
  HexagonPeephole.cpp
  HexagonRegisterInfo.cpp
  HexagonRemoveSZExtArgs.cpp
@@ -28,9 +28,6 @@ add_llvm_target(HexagonCodeGen
  HexagonSubtarget.cpp
  HexagonTargetMachine.cpp
  HexagonTargetObjectFile.cpp
  HexagonVLIWPacketizer.cpp
  HexagonNewValueJump.cpp
  HexagonCopyToCombine.cpp
)

add_subdirectory(TargetInfo)
+0 −3
Original line number Diff line number Diff line
@@ -40,9 +40,6 @@ namespace llvm {
  FunctionPass *createHexagonHardwareLoops();
  FunctionPass *createHexagonPeephole();
  FunctionPass *createHexagonFixupHwLoops();
  FunctionPass *createHexagonNewValueJump();
  FunctionPass *createHexagonCopyToCombine();
  FunctionPass *createHexagonPacketizer();

/* TODO: object output.
  MCCodeEmitter *createHexagonMCCodeEmitter(const Target &,
Loading