mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 04:31:08 +00:00
Expose InsertPreheaderForLoop from LoopSimplify to other passes
Other passes, PPC counter-loop formation for example, also need to add loop preheaders outside of the regular loop simplification pass. This makes InsertPreheaderForLoop a global function so that it can be used by other passes. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9b39c726a0
commit
fc32605ff3
26
include/llvm/Transforms/Utils/LoopSimplify.h
Normal file
26
include/llvm/Transforms/Utils/LoopSimplify.h
Normal file
@ -0,0 +1,26 @@
|
||||
//===- llvm/Transforms/Utils/LoopSimplify.h - Loop utilities -*- C++ -*-======//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines some loop transformation utilities.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
|
||||
#define LLVM_TRANSFORMS_UTILS_LOOPSIMPLIFY_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Loop;
|
||||
class Pass;
|
||||
|
||||
BasicBlock *InsertPreheaderForLoop(Loop *L, Pass *P);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -59,6 +59,7 @@
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
#include "llvm/Transforms/Utils/LoopSimplify.h"
|
||||
using namespace llvm;
|
||||
|
||||
STATISTIC(NumInserted, "Number of pre-header or exit blocks inserted");
|
||||
@ -100,16 +101,16 @@ namespace {
|
||||
private:
|
||||
bool ProcessLoop(Loop *L, LPPassManager &LPM);
|
||||
BasicBlock *RewriteLoopExitBlock(Loop *L, BasicBlock *Exit);
|
||||
BasicBlock *InsertPreheaderForLoop(Loop *L);
|
||||
Loop *SeparateNestedLoop(Loop *L, LPPassManager &LPM,
|
||||
BasicBlock *Preheader);
|
||||
BasicBlock *InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader);
|
||||
void PlaceSplitBlockCarefully(BasicBlock *NewBB,
|
||||
SmallVectorImpl<BasicBlock*> &SplitPreds,
|
||||
Loop *L);
|
||||
};
|
||||
}
|
||||
|
||||
static void PlaceSplitBlockCarefully(BasicBlock *NewBB,
|
||||
SmallVectorImpl<BasicBlock*> &SplitPreds,
|
||||
Loop *L);
|
||||
|
||||
char LoopSimplify::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(LoopSimplify, "loop-simplify",
|
||||
"Canonicalize natural loops", true, false)
|
||||
@ -208,7 +209,7 @@ ReprocessLoop:
|
||||
// Does the loop already have a preheader? If so, don't insert one.
|
||||
BasicBlock *Preheader = L->getLoopPreheader();
|
||||
if (!Preheader) {
|
||||
Preheader = InsertPreheaderForLoop(L);
|
||||
Preheader = InsertPreheaderForLoop(L, this);
|
||||
if (Preheader) {
|
||||
++NumInserted;
|
||||
Changed = true;
|
||||
@ -367,7 +368,7 @@ ReprocessLoop:
|
||||
/// preheader, this method is called to insert one. This method has two phases:
|
||||
/// preheader insertion and analysis updating.
|
||||
///
|
||||
BasicBlock *LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
BasicBlock *llvm::InsertPreheaderForLoop(Loop *L, Pass *PP) {
|
||||
BasicBlock *Header = L->getHeader();
|
||||
|
||||
// Compute the set of predecessors of the loop that are not in the loop.
|
||||
@ -390,11 +391,11 @@ BasicBlock *LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
BasicBlock *PreheaderBB;
|
||||
if (!Header->isLandingPad()) {
|
||||
PreheaderBB = SplitBlockPredecessors(Header, OutsideBlocks, ".preheader",
|
||||
this);
|
||||
PP);
|
||||
} else {
|
||||
SmallVector<BasicBlock*, 2> NewBBs;
|
||||
SplitLandingPadPredecessors(Header, OutsideBlocks, ".preheader",
|
||||
".split-lp", this, NewBBs);
|
||||
".split-lp", PP, NewBBs);
|
||||
PreheaderBB = NewBBs[0];
|
||||
}
|
||||
|
||||
@ -491,9 +492,9 @@ static PHINode *FindPHIToPartitionLoops(Loop *L, DominatorTree *DT,
|
||||
// PlaceSplitBlockCarefully - If the block isn't already, move the new block to
|
||||
// right after some 'outside block' block. This prevents the preheader from
|
||||
// being placed inside the loop body, e.g. when the loop hasn't been rotated.
|
||||
void LoopSimplify::PlaceSplitBlockCarefully(BasicBlock *NewBB,
|
||||
SmallVectorImpl<BasicBlock*> &SplitPreds,
|
||||
Loop *L) {
|
||||
void PlaceSplitBlockCarefully(BasicBlock *NewBB,
|
||||
SmallVectorImpl<BasicBlock*> &SplitPreds,
|
||||
Loop *L) {
|
||||
// Check to see if NewBB is already well placed.
|
||||
Function::iterator BBI = NewBB; --BBI;
|
||||
for (unsigned i = 0, e = SplitPreds.size(); i != e; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user