[llvm-commits] [polly] r155547 - in /polly/trunk: include/polly/BlockGenerators.h include/polly/CodeGen/ include/polly/CodeGen/BlockGenerators.h include/polly/CodeGen/CodeGeneration.h include/polly/CodeGen/LoopGenerators.h include/polly/CodeGeneration.h include/polly/LoopGenerators.h lib/CodeGen/BlockGenerators.cpp lib/CodeGen/CodeGeneration.cpp lib/CodeGen/LoopGenerators.cpp lib/ScheduleOptimizer.cpp
Hongbin Zheng
etherzhhb at gmail.com
Wed Apr 25 06:18:29 PDT 2012
Author: ether
Date: Wed Apr 25 08:18:28 2012
New Revision: 155547
URL: http://llvm.org/viewvc/llvm-project?rev=155547&view=rev
Log:
Refactor: Move the code generation related header files to include/polly/CodeGen.
Added:
polly/trunk/include/polly/CodeGen/
polly/trunk/include/polly/CodeGen/BlockGenerators.h
- copied, changed from r155546, polly/trunk/include/polly/BlockGenerators.h
polly/trunk/include/polly/CodeGen/CodeGeneration.h
- copied, changed from r155546, polly/trunk/include/polly/CodeGeneration.h
polly/trunk/include/polly/CodeGen/LoopGenerators.h
- copied, changed from r155546, polly/trunk/include/polly/LoopGenerators.h
Removed:
polly/trunk/include/polly/BlockGenerators.h
polly/trunk/include/polly/CodeGeneration.h
polly/trunk/include/polly/LoopGenerators.h
Modified:
polly/trunk/lib/CodeGen/BlockGenerators.cpp
polly/trunk/lib/CodeGen/CodeGeneration.cpp
polly/trunk/lib/CodeGen/LoopGenerators.cpp
polly/trunk/lib/ScheduleOptimizer.cpp
Removed: polly/trunk/include/polly/BlockGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/BlockGenerators.h?rev=155546&view=auto
==============================================================================
--- polly/trunk/include/polly/BlockGenerators.h (original)
+++ polly/trunk/include/polly/BlockGenerators.h (removed)
@@ -1,243 +0,0 @@
-//===-BlockGenerators.h - Helper to generate code for statements-*- 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 the BlockGenerator and VectorBlockGenerator classes, which
-// generate sequential code and vectorized code for a polyhedral statement,
-// respectively.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLLY_BLOCK_GENERATORS_H
-#define POLLY_BLOCK_GENERATORS_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/Support/IRBuilder.h"
-
-#include "isl/map.h"
-
-#include <vector>
-
-namespace llvm {
-class Pass;
-}
-
-namespace polly {
-using namespace llvm;
-class ScopStmt;
-
-typedef DenseMap<const Value*, Value*> ValueMapT;
-typedef std::vector<ValueMapT> VectorValueMapT;
-
-/// @brief Generate a new basic block for a polyhedral statement.
-///
-/// The only public function exposed is generate().
-class BlockGenerator {
-public:
- /// @brief Generate a new BasicBlock for a ScopStmt.
- ///
- /// @param Builder The LLVM-IR Builder used to generate the statement. The
- /// code is generated at the location, the Builder points to.
- /// @param Stmt The statement to code generate.
- /// @param GlobalMap A map that defines for certain Values referenced from the
- /// original code new Values they should be replaced with.
- /// @param P A reference to the pass this function is called from.
- /// The pass is needed to update other analysis.
- static void generate(IRBuilder<> &Builder, ScopStmt &Stmt,
- ValueMapT &GlobalMap, Pass *P) {
- BlockGenerator Generator(Builder, Stmt, P);
- Generator.copyBB(GlobalMap);
- }
-
-protected:
- IRBuilder<> &Builder;
- ScopStmt &Statement;
- Pass *P;
-
- BlockGenerator(IRBuilder<> &B, ScopStmt &Stmt, Pass *P);
-
- /// @brief Get the new version of a Value.
- ///
- /// @param Old The old Value.
- /// @param BBMap A mapping from old values to their new values
- /// (for values recalculated within this basic block).
- /// @param GlobalMap A mapping from old values to their new values
- /// (for values recalculated in the new ScoP, but not
- /// within this basic block).
- ///
- /// @returns o The old value, if it is still valid.
- /// o The new value, if available.
- /// o NULL, if no value is found.
- Value *getNewValue(const Value *Old, ValueMapT &BBMap, ValueMapT &GlobalMap);
-
- void copyInstScalar(const Instruction *Inst, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- /// @brief Get the memory access offset to be added to the base address
- std::vector<Value*> getMemoryAccessIndex(__isl_keep isl_map *AccessRelation,
- Value *BaseAddress, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- /// @brief Get the new operand address according to the changed access in
- /// JSCOP file.
- Value *getNewAccessOperand(__isl_keep isl_map *NewAccessRelation,
- Value *BaseAddress, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- /// @brief Generate the operand address
- Value *generateLocationAccessed(const Instruction *Inst,
- const Value *Pointer, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- Value *generateScalarStore(const StoreInst *store, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- /// @brief Copy a single Instruction.
- ///
- /// This copies a single Instruction and updates references to old values
- /// with references to new values, as defined by GlobalMap and BBMap.
- ///
- /// @param BBMap A mapping from old values to their new values
- /// (for values recalculated within this basic block).
- /// @param GlobalMap A mapping from old values to their new values
- /// (for values recalculated in the new ScoP, but not
- /// within this basic block).
- void copyInstruction(const Instruction *Inst, ValueMapT &BBMap,
- ValueMapT &GlobalMap);
-
- /// @brief Copy the basic block.
- ///
- /// This copies the entire basic block and updates references to old values
- /// with references to new values, as defined by GlobalMap.
- ///
- /// @param GlobalMap A mapping from old values to their new values
- /// (for values recalculated in the new ScoP, but not
- /// within this basic block).
- void copyBB(ValueMapT &GlobalMap);
-};
-
-/// @brief Generate a new vector basic block for a polyhedral statement.
-///
-/// The only public function exposed is generate().
-class VectorBlockGenerator : BlockGenerator {
-public:
- /// @brief Generate a new vector basic block for a ScoPStmt.
- ///
- /// This code generation is similar to the normal, scalar code generation,
- /// except that each instruction is code generated for several vector lanes
- /// at a time. If possible instructions are issued as actual vector
- /// instructions, but e.g. for address calculation instructions we currently
- /// generate scalar instructions for each vector lane.
- ///
- /// @param Builder The LLVM-IR Builder used to generate the statement. The
- /// code is generated at the location, the builder points
- /// to.
- /// @param Stmt The statement to code generate.
- /// @param GlobalMaps A vector of maps that define for certain Values
- /// referenced from the original code new Values they should
- /// be replaced with. Each map in the vector of maps is
- /// used for one vector lane. The number of elements in the
- /// vector defines the width of the generated vector
- /// instructions.
- /// @param P A reference to the pass this function is called from.
- /// The pass is needed to update other analysis.
- static void generate(IRBuilder<> &B, ScopStmt &Stmt,
- VectorValueMapT &GlobalMaps, __isl_keep isl_set *Domain,
- Pass *P) {
- VectorBlockGenerator Generator(B, GlobalMaps, Stmt, Domain, P);
- Generator.copyBB();
- }
-
-private:
- // This is a vector of global value maps. The first map is used for the first
- // vector lane, ...
- // Each map, contains information about Instructions in the old ScoP, which
- // are recalculated in the new SCoP. When copying the basic block, we replace
- // all referenes to the old instructions with their recalculated values.
- VectorValueMapT &GlobalMaps;
-
- isl_set *Domain;
-
- VectorBlockGenerator(IRBuilder<> &B, VectorValueMapT &GlobalMaps,
- ScopStmt &Stmt, __isl_keep isl_set *Domain, Pass *P);
-
- int getVectorWidth();
-
- Value *getVectorValue(const Value *Old, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- Type *getVectorPtrTy(const Value *V, int Width);
-
- /// @brief Load a vector from a set of adjacent scalars
- ///
- /// In case a set of scalars is known to be next to each other in memory,
- /// create a vector load that loads those scalars
- ///
- /// %vector_ptr= bitcast double* %p to <4 x double>*
- /// %vec_full = load <4 x double>* %vector_ptr
- ///
- Value *generateStrideOneLoad(const LoadInst *Load, ValueMapT &BBMap);
-
- /// @brief Load a vector initialized from a single scalar in memory
- ///
- /// In case all elements of a vector are initialized to the same
- /// scalar value, this value is loaded and shuffeled into all elements
- /// of the vector.
- ///
- /// %splat_one = load <1 x double>* %p
- /// %splat = shufflevector <1 x double> %splat_one, <1 x
- /// double> %splat_one, <4 x i32> zeroinitializer
- ///
- Value *generateStrideZeroLoad(const LoadInst *Load, ValueMapT &BBMap);
-
- /// @brief Load a vector from scalars distributed in memory
- ///
- /// In case some scalars a distributed randomly in memory. Create a vector
- /// by loading each scalar and by inserting one after the other into the
- /// vector.
- ///
- /// %scalar_1= load double* %p_1
- /// %vec_1 = insertelement <2 x double> undef, double %scalar_1, i32 0
- /// %scalar 2 = load double* %p_2
- /// %vec_2 = insertelement <2 x double> %vec_1, double %scalar_1, i32 1
- ///
- Value *generateUnknownStrideLoad(const LoadInst *Load,
- VectorValueMapT &ScalarMaps);
-
- void generateLoad(const LoadInst *Load, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- void copyUnaryInst(const UnaryInstruction *Inst, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- void copyBinaryInst(const BinaryOperator *Inst, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- void copyStore(const StoreInst *Store, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- void copyInstScalarized(const Instruction *Inst, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- bool extractScalarValues(const Instruction *Inst, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- bool hasVectorOperands(const Instruction *Inst, ValueMapT &VectorMap);
-
- void copyInstruction(const Instruction *Inst, ValueMapT &VectorMap,
- VectorValueMapT &ScalarMaps);
-
- void copyBB();
-};
-
-}
-#endif
-
Copied: polly/trunk/include/polly/CodeGen/BlockGenerators.h (from r155546, polly/trunk/include/polly/BlockGenerators.h)
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/BlockGenerators.h?p2=polly/trunk/include/polly/CodeGen/BlockGenerators.h&p1=polly/trunk/include/polly/BlockGenerators.h&r1=155546&r2=155547&rev=155547&view=diff
==============================================================================
(empty)
Copied: polly/trunk/include/polly/CodeGen/CodeGeneration.h (from r155546, polly/trunk/include/polly/CodeGeneration.h)
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/CodeGeneration.h?p2=polly/trunk/include/polly/CodeGen/CodeGeneration.h&p1=polly/trunk/include/polly/CodeGeneration.h&r1=155546&r2=155547&rev=155547&view=diff
==============================================================================
(empty)
Copied: polly/trunk/include/polly/CodeGen/LoopGenerators.h (from r155546, polly/trunk/include/polly/LoopGenerators.h)
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/LoopGenerators.h?p2=polly/trunk/include/polly/CodeGen/LoopGenerators.h&p1=polly/trunk/include/polly/LoopGenerators.h&r1=155546&r2=155547&rev=155547&view=diff
==============================================================================
(empty)
Removed: polly/trunk/include/polly/CodeGeneration.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGeneration.h?rev=155546&view=auto
==============================================================================
--- polly/trunk/include/polly/CodeGeneration.h (original)
+++ polly/trunk/include/polly/CodeGeneration.h (removed)
@@ -1,20 +0,0 @@
-//===------ polly/CodeGeneration.h - The Polly code generator *- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLLY_CODEGENERATION_H
-#define POLLY_CODEGENERATION_H
-
-namespace polly {
- extern bool EnablePollyVector;
-}
-
-#endif
-
Removed: polly/trunk/include/polly/LoopGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LoopGenerators.h?rev=155546&view=auto
==============================================================================
--- polly/trunk/include/polly/LoopGenerators.h (original)
+++ polly/trunk/include/polly/LoopGenerators.h (removed)
@@ -1,115 +0,0 @@
-//===- LoopGenerators.h - IR helper to create loops -------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains functions to create scalar and OpenMP parallel loops
-// as LLVM-IR.
-//
-//===----------------------------------------------------------------------===//
-#ifndef POLLY_LOOP_GENERATORS_H
-#define POLLY_LOOP_GENERATORS_H
-#include "llvm/Support/IRBuilder.h"
-#include "llvm/ADT/SetVector.h"
-
-#include <map>
-
-namespace llvm {
- class Value;
- class Pass;
- class BasicBlock;
-}
-
-namespace polly {
-using namespace llvm;
-
-/// @brief Create a scalar loop.
-///
-/// @param LowerBound The starting value of the induction variable.
-/// @param UpperBound The upper bound of the induction variable.
-/// @param Stride The value by which the induction variable is incremented.
-///
-/// @param Builder The builder used to create the loop.
-/// @param P A pointer to the pass that uses this function. It is used
-/// to update analysis information.
-///
-/// @return Value* The newly created induction variable for this loop.
-Value *createLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
- IRBuilder<> &Builder, Pass *P, BasicBlock *&AfterBlock);
-
-class OMPGenerator {
-public:
- typedef std::map<Value*, Value*> ValueToValueMapTy;
-
- OMPGenerator(IRBuilder<> &Builder, Pass *P): Builder(Builder), P(P) {}
-
- /// @brief Create an OpenMP parallel loop.
- ///
- ///
- /// @param LowerBound The starting value of the induction variable.
- /// @param UpperBound The upper bound of the induction variable.
- /// @param Stride The value by which the induction variable is
- /// incremented.
- ///
- /// @param UsedValues A set of LLVM-IR Values that should be available to
- /// the new loop body.
- /// @param VMap This map is filled by createParallelLoop(). It
- /// maps the values in UsedValues to Values through which
- /// their content is available within the loop body.
- /// @param LoopBody A pointer to an iterator that is set to point to the
- /// body of the created loop. It should be used to insert
- /// instructions that form the actual loop body.
- ///
- /// @return Value* The newly created induction variable for this loop.
- Value *createParallelLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
- SetVector<Value*> &UsedValues,
- ValueToValueMapTy &VMap,
- BasicBlock::iterator *LoopBody);
-
-private:
- IRBuilder<> &Builder;
- Pass *P;
-
- IntegerType *getIntPtrTy();
- Module *getModule();
-
- void createCallParallelLoopStart(Value *SubFunction, Value *SubfunctionParam,
- Value *NumberOfThreads, Value *LowerBound,
- Value *UpperBound, Value *Stride);
- Value *createCallLoopNext(Value *LowerBoundPtr, Value *UpperBoundPtr);
- void createCallParallelEnd();
- void createCallLoopEndNowait();
-
- Value *loadValuesIntoStruct(SetVector<Value*> &Values);
- void extractValuesFromStruct(SetVector<Value*> OldValues,
- Value *Struct, ValueToValueMapTy &Map);
-
- /// @brief Create the OpenMP subfunction.
- ///
- /// @param Stride The value by which the induction variable is
- /// incremented.
- /// @param Struct The structure that is used to make Values available to
- /// the loop body.
- /// @param UsedValues A set of LLVM-IR Values that should be available to
- /// the new loop body.
- /// @param VMap This map that is filled by createSubfunction(). It
- /// maps the values in UsedValues to Values through which
- /// their content is available within the loop body.
- /// @param SubFunction The newly created SubFunction is returned here.
- ///
- /// @return Value* The newly created induction variable.
- Value *createSubfunction(Value *Stride, Value *Struct,
- SetVector<Value*> UsedValues,
- ValueToValueMapTy &VMap,
- Function **SubFunction);
-
- /// @brief Create the definition of the OpenMP subfunction.
- Function *createSubfunctionDefinition();
-};
-} // end namespace polly
-#endif
-
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=155547&r1=155546&r2=155547&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Wed Apr 25 08:18:28 2012
@@ -14,8 +14,7 @@
//===----------------------------------------------------------------------===//
#include "polly/ScopInfo.h"
-#include "polly/BlockGenerators.h"
-#include "polly/CodeGeneration.h"
+#include "polly/CodeGen/BlockGenerators.h"
#include "polly/Support/GICHelper.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=155547&r1=155546&r2=155547&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Wed Apr 25 08:18:28 2012
@@ -23,13 +23,13 @@
#define DEBUG_TYPE "polly-codegen"
#include "polly/Cloog.h"
-#include "polly/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/LinkAllPasses.h"
#include "polly/ScopInfo.h"
#include "polly/TempScopInfo.h"
-#include "polly/BlockGenerators.h"
-#include "polly/LoopGenerators.h"
+#include "polly/CodeGen/CodeGeneration.h"
+#include "polly/CodeGen/BlockGenerators.h"
+#include "polly/CodeGen/LoopGenerators.h"
#include "polly/Support/GICHelper.h"
#include "llvm/Module.h"
Modified: polly/trunk/lib/CodeGen/LoopGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/LoopGenerators.cpp?rev=155547&r1=155546&r2=155547&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/LoopGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/LoopGenerators.cpp Wed Apr 25 08:18:28 2012
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#include "polly/LoopGenerators.h"
#include "polly/ScopDetection.h"
+#include "polly/CodeGen/LoopGenerators.h"
#include "llvm/Module.h"
#include "llvm/Analysis/Dominators.h"
Modified: polly/trunk/lib/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=155547&r1=155546&r2=155547&view=diff
==============================================================================
--- polly/trunk/lib/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/ScheduleOptimizer.cpp Wed Apr 25 08:18:28 2012
@@ -19,7 +19,7 @@
#include "polly/ScheduleOptimizer.h"
-#include "polly/CodeGeneration.h"
+#include "polly/CodeGen/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/LinkAllPasses.h"
#include "polly/ScopInfo.h"
More information about the llvm-commits
mailing list