[llvm-commits] [polly] r149240 - in /polly/trunk: include/polly/RegisterPasses.h lib/RegisterPasses.cpp
Tobias Grosser
grosser at fim.uni-passau.de
Mon Jan 30 01:07:51 PST 2012
Author: grosser
Date: Mon Jan 30 03:07:50 2012
New Revision: 149240
URL: http://llvm.org/viewvc/llvm-project?rev=149240&view=rev
Log:
RegisterPass: Expose functions to register Polly passes
Added:
polly/trunk/include/polly/RegisterPasses.h
Modified:
polly/trunk/lib/RegisterPasses.cpp
Added: polly/trunk/include/polly/RegisterPasses.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/RegisterPasses.h?rev=149240&view=auto
==============================================================================
--- polly/trunk/include/polly/RegisterPasses.h (added)
+++ polly/trunk/include/polly/RegisterPasses.h Mon Jan 30 03:07:50 2012
@@ -0,0 +1,27 @@
+//===------ polly/RegisterPasses.h - Register the Polly passes *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Functions to register the Polly passes in a LLVM pass manager.
+//
+//===----------------------------------------------------------------------===//
+
+namespace llvm {
+ class PassManagerBase;
+}
+
+// Register the Polly preoptimization passes. Preoptimizations are used to
+// prepare the LLVM-IR for Polly. They increase the amount of code that can be
+// optimized.
+// (These passes are automatically included in registerPollyPasses).
+void registerPollyPreoptPasses(llvm::PassManagerBase &PM);
+
+// Register the Polly optimizer (including its preoptimizations).
+void registerPollyPasses(llvm::PassManagerBase &PM,
+ bool DisableScheduler = false,
+ bool DisableCodegen = false);
Modified: polly/trunk/lib/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/RegisterPasses.cpp?rev=149240&r1=149239&r2=149240&view=diff
==============================================================================
--- polly/trunk/lib/RegisterPasses.cpp (original)
+++ polly/trunk/lib/RegisterPasses.cpp Mon Jan 30 03:07:50 2012
@@ -10,14 +10,7 @@
// Add the Polly passes to the optimization passes executed at -O3.
//
//===----------------------------------------------------------------------===//
-#include "llvm/Analysis/Passes.h"
-#include "llvm/InitializePasses.h"
-#include "llvm/PassManager.h"
-#include "llvm/PassRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
-#include "llvm/Support/CommandLine.h"
-
+#include "polly/RegisterPasses.h"
#include "polly/LinkAllPasses.h"
#include "polly/Cloog.h"
@@ -26,6 +19,14 @@
#include "polly/ScopInfo.h"
#include "polly/TempScopInfo.h"
+#include "llvm/Analysis/Passes.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/PassManager.h"
+#include "llvm/PassRegistry.h"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Support/CommandLine.h"
+
#include <string>
using namespace llvm;
@@ -109,8 +110,7 @@
static StaticInitializer InitializeEverything;
-static void registerPollyPreoptPasses(const llvm::PassManagerBuilder &Builder,
- llvm::PassManagerBase &PM) {
+void registerPollyPreoptPasses(llvm::PassManagerBase &PM) {
// A standard set of optimization passes partially taken/copied from the
// set of default optimization passes. It is used to bring the code into
// a canonical form that can than be analyzed by Polly. This set of passes is
@@ -142,38 +142,12 @@
PM.add(polly::createRegionSimplifyPass());
}
-static void registerPollyPasses(const llvm::PassManagerBuilder &Builder,
- llvm::PassManagerBase &PM) {
-
- if (Builder.OptLevel == 0)
- return;
-
- if (PollyOnlyPrinter || PollyPrinter || PollyOnlyViewer || PollyViewer ||
- ExportJScop || ImportJScop)
- PollyEnabled = true;
-
- if (!PollyEnabled) {
- if (DisableCodegen)
- errs() << "The option -polly-no-codegen has no effect. "
- "Polly was not enabled\n";
-
- if (DisableScheduler)
- errs() << "The option -polly-no-optimizer has no effect. "
- "Polly was not enabled\n";
-
- return;
- }
-
- // Polly is only enabled at -O3
- if (Builder.OptLevel != 3) {
- errs() << "Polly should only be run with -O3. Disabling Polly.\n";
- return;
- }
-
+void registerPollyPasses(llvm::PassManagerBase &PM, bool DisableScheduler,
+ bool DisableCodegen) {
bool RunScheduler = !DisableScheduler;
bool RunCodegen = !DisableCodegen;
- registerPollyPreoptPasses(Builder, PM);
+ registerPollyPreoptPasses(PM);
if (PollyViewer)
PM.add(polly::createDOTViewerPass());
@@ -213,6 +187,44 @@
PM.add(polly::createCodeGenerationPass());
}
+static
+void registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder,
+ llvm::PassManagerBase &PM) {
+
+ if (Builder.OptLevel == 0)
+ return;
+
+ if (PollyOnlyPrinter || PollyPrinter || PollyOnlyViewer || PollyViewer ||
+ ExportJScop || ImportJScop)
+ PollyEnabled = true;
+
+ if (!PollyEnabled) {
+ if (DisableCodegen)
+ errs() << "The option -polly-no-codegen has no effect. "
+ "Polly was not enabled\n";
+
+ if (DisableScheduler)
+ errs() << "The option -polly-no-optimizer has no effect. "
+ "Polly was not enabled\n";
+
+ return;
+ }
+
+ // Polly is only enabled at -O3
+ if (Builder.OptLevel != 3) {
+ errs() << "Polly should only be run with -O3. Disabling Polly.\n";
+ return;
+ }
+
+ registerPollyPasses(PM, DisableScheduler, DisableCodegen);
+}
+
+static void registerPollyOptLevel0Passes(const llvm::PassManagerBuilder &,
+ llvm::PassManagerBase &PM) {
+ registerPollyPreoptPasses(PM);
+}
+
+
// Execute Polly together with a set of preparing passes.
//
// We run Polly that early to run before loop optimizer passes like LICM or
@@ -221,7 +233,7 @@
static llvm::RegisterStandardPasses
PassRegister(llvm::PassManagerBuilder::EP_EarlyAsPossible,
- registerPollyPasses);
+ registerPollyEarlyAsPossiblePasses);
static llvm::RegisterStandardPasses
PassRegisterPreopt(llvm::PassManagerBuilder::EP_EnabledOnOptLevel0,
- registerPollyPreoptPasses);
+ registerPollyOptLevel0Passes);
More information about the llvm-commits
mailing list