mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-15 20:51:35 +00:00
Move the ValueMapT declaration out of BlockGenerator
Value maps are created and used in many places and it is not always possible to include CodeGen/Blockgenerators.h. To this end, ValueMapT now lives in the ScopHelper.h which does not have any dependences itself. This patch also replaces uses of different other value map types with the ValueMapT. llvm-svn: 249606
This commit is contained in:
parent
512011c3f0
commit
521dd5842f
@ -60,6 +60,8 @@ bool isIgnoredIntrinsic(const llvm::Value *V);
|
||||
/// @brief Generate a new basic block for a polyhedral statement.
|
||||
class BlockGenerator {
|
||||
public:
|
||||
typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
|
||||
|
||||
/// @brief Map types to resolve scalar dependences.
|
||||
///
|
||||
///@{
|
||||
@ -67,10 +69,6 @@ public:
|
||||
/// @see The ScalarMap and PHIOpMap member.
|
||||
using ScalarAllocaMapTy = DenseMap<AssertingVH<Value>, AssertingVH<Value>>;
|
||||
|
||||
typedef llvm::DenseMap<AssertingVH<llvm::Value>, AssertingVH<llvm::Value>>
|
||||
ValueMapT;
|
||||
typedef llvm::SmallVector<ValueMapT, 8> VectorValueMapT;
|
||||
|
||||
/// @brief Simple vector of instructions to store escape users.
|
||||
using EscapeUserVectorTy = SmallVector<Instruction *, 4>;
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
#ifndef POLLY_ISL_EXPR_BUILDER_H
|
||||
#define POLLY_ISL_EXPR_BUILDER_H
|
||||
|
||||
#include "polly/CodeGen/BlockGenerators.h"
|
||||
#include "polly/CodeGen/IRBuilder.h"
|
||||
#include "polly/Support/ScopHelper.h"
|
||||
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "isl/ast.h"
|
||||
|
||||
@ -82,7 +83,6 @@ class IslExprBuilder {
|
||||
public:
|
||||
/// @brief A map from isl_ids to llvm::Values.
|
||||
typedef llvm::MapVector<isl_id *, llvm::AssertingVH<llvm::Value>> IDToValueTy;
|
||||
typedef BlockGenerator::ValueMapT ValueToValueMap;
|
||||
|
||||
/// @brief Construct an IslExprBuilder.
|
||||
///
|
||||
@ -95,7 +95,7 @@ public:
|
||||
/// specifies the LLVM-IR Values that correspond to these
|
||||
/// parameters and variables.
|
||||
IslExprBuilder(Scop &S, PollyIRBuilder &Builder, IDToValueTy &IDToValue,
|
||||
ValueToValueMap &GlobalMap, const llvm::DataLayout &DL,
|
||||
ValueMapT &GlobalMap, const llvm::DataLayout &DL,
|
||||
llvm::ScalarEvolution &SE, llvm::DominatorTree &DT,
|
||||
llvm::LoopInfo &LI)
|
||||
: S(S), Builder(Builder), IDToValue(IDToValue), GlobalMap(GlobalMap),
|
||||
@ -130,7 +130,7 @@ private:
|
||||
|
||||
PollyIRBuilder &Builder;
|
||||
IDToValueTy &IDToValue;
|
||||
ValueToValueMap &GlobalMap;
|
||||
ValueMapT &GlobalMap;
|
||||
|
||||
const llvm::DataLayout &DL;
|
||||
llvm::ScalarEvolution &SE;
|
||||
|
@ -115,7 +115,7 @@ protected:
|
||||
///
|
||||
/// When generating new code for a ScopStmt this map is used to map certain
|
||||
/// llvm::Values to new llvm::Values.
|
||||
polly::BlockGenerator::ValueMapT ValueMap;
|
||||
ValueMapT ValueMap;
|
||||
|
||||
/// @brief Materialize code for @p Id if it was not done before.
|
||||
void materializeValue(__isl_take isl_id *Id);
|
||||
@ -191,7 +191,7 @@ protected:
|
||||
/// pass down certain values.
|
||||
///
|
||||
/// @param NewValues A map that maps certain llvm::Values to new llvm::Values.
|
||||
void updateValues(ParallelLoopGenerator::ValueToValueMapTy &NewValues);
|
||||
void updateValues(ValueMapT &NewValues);
|
||||
|
||||
/// @brief Generate code for a marker now.
|
||||
///
|
||||
|
@ -15,6 +15,8 @@
|
||||
#define POLLY_LOOP_GENERATORS_H
|
||||
|
||||
#include "polly/CodeGen/IRBuilder.h"
|
||||
#include "polly/Support/ScopHelper.h"
|
||||
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/IR/ValueMap.h"
|
||||
|
||||
@ -96,9 +98,6 @@ Value *createLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
|
||||
/// }
|
||||
class ParallelLoopGenerator {
|
||||
public:
|
||||
using ValueToValueMapTy =
|
||||
llvm::DenseMap<AssertingVH<Value>, AssertingVH<Value>>;
|
||||
|
||||
/// @brief Create a parallel loop generator for the current function.
|
||||
ParallelLoopGenerator(PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
|
||||
DominatorTree &DT, const DataLayout &DL)
|
||||
@ -123,7 +122,7 @@ public:
|
||||
///
|
||||
/// @return The newly created induction variable for this loop.
|
||||
Value *createParallelLoop(Value *LB, Value *UB, Value *Stride,
|
||||
SetVector<Value *> &Values, ValueToValueMapTy &VMap,
|
||||
SetVector<Value *> &Values, ValueMapT &VMap,
|
||||
BasicBlock::iterator *LoopBody);
|
||||
|
||||
private:
|
||||
@ -190,7 +189,7 @@ private:
|
||||
/// @param VMap A map to associate every element of @p Values with the
|
||||
/// new llvm value loaded from the @p Struct.
|
||||
void extractValuesFromStruct(SetVector<Value *> Values, Type *Ty,
|
||||
Value *Struct, ValueToValueMapTy &VMap);
|
||||
Value *Struct, ValueMapT &VMap);
|
||||
|
||||
/// @brief Create the definition of the parallel subfunction.
|
||||
Function *createSubFnDefinition();
|
||||
@ -207,7 +206,7 @@ private:
|
||||
///
|
||||
/// @return The newly created induction variable.
|
||||
Value *createSubFn(Value *Stride, AllocaInst *Struct,
|
||||
SetVector<Value *> UsedValues, ValueToValueMapTy &VMap,
|
||||
SetVector<Value *> UsedValues, ValueMapT &VMap,
|
||||
Function **SubFn);
|
||||
};
|
||||
} // end namespace polly
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define POLLY_SUPPORT_IRHELPER_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
|
||||
namespace llvm {
|
||||
@ -40,6 +41,10 @@ class ScalarEvolution;
|
||||
namespace polly {
|
||||
class Scop;
|
||||
|
||||
/// @brief Type to remap values.
|
||||
using ValueMapT = llvm::DenseMap<llvm::AssertingVH<llvm::Value>,
|
||||
llvm::AssertingVH<llvm::Value>>;
|
||||
|
||||
/// Temporary Hack for extended regiontree.
|
||||
///
|
||||
/// @brief Cast the region to loop.
|
||||
|
@ -175,7 +175,7 @@ struct SubtreeReferences {
|
||||
LoopInfo &LI;
|
||||
ScalarEvolution &SE;
|
||||
Region &R;
|
||||
polly::BlockGenerator::ValueMapT &GlobalMap;
|
||||
ValueMapT &GlobalMap;
|
||||
SetVector<Value *> &Values;
|
||||
SetVector<const SCEV *> &SCEVs;
|
||||
BlockGenerator &BlockGen;
|
||||
@ -311,8 +311,7 @@ void IslNodeBuilder::getReferencesInSubtree(__isl_keep isl_ast_node *For,
|
||||
});
|
||||
}
|
||||
|
||||
void IslNodeBuilder::updateValues(
|
||||
ParallelLoopGenerator::ValueToValueMapTy &NewValues) {
|
||||
void IslNodeBuilder::updateValues(ValueMapT &NewValues) {
|
||||
SmallPtrSet<Value *, 5> Inserted;
|
||||
|
||||
for (const auto &I : IDToValue) {
|
||||
@ -592,7 +591,7 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) {
|
||||
SubtreeValues.insert(V);
|
||||
}
|
||||
|
||||
ParallelLoopGenerator::ValueToValueMapTy NewValues;
|
||||
ValueMapT NewValues;
|
||||
ParallelLoopGenerator ParallelLoopGen(Builder, P, LI, DT, DL);
|
||||
|
||||
IV = ParallelLoopGen.createParallelLoop(ValueLB, ValueUB, ValueInc,
|
||||
@ -607,7 +606,7 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) {
|
||||
updateValues(NewValues);
|
||||
IDToValue[IteratorID] = IV;
|
||||
|
||||
ParallelLoopGenerator::ValueToValueMapTy NewValuesReverse;
|
||||
ValueMapT NewValuesReverse;
|
||||
|
||||
for (auto P : NewValues)
|
||||
NewValuesReverse[P.second] = P.first;
|
||||
|
@ -146,7 +146,7 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
|
||||
|
||||
Value *ParallelLoopGenerator::createParallelLoop(
|
||||
Value *LB, Value *UB, Value *Stride, SetVector<Value *> &UsedValues,
|
||||
ValueToValueMapTy &Map, BasicBlock::iterator *LoopBody) {
|
||||
ValueMapT &Map, BasicBlock::iterator *LoopBody) {
|
||||
Function *SubFn;
|
||||
|
||||
AllocaInst *Struct = storeValuesIntoStruct(UsedValues);
|
||||
@ -305,8 +305,7 @@ ParallelLoopGenerator::storeValuesIntoStruct(SetVector<Value *> &Values) {
|
||||
}
|
||||
|
||||
void ParallelLoopGenerator::extractValuesFromStruct(
|
||||
SetVector<Value *> OldValues, Type *Ty, Value *Struct,
|
||||
ValueToValueMapTy &Map) {
|
||||
SetVector<Value *> OldValues, Type *Ty, Value *Struct, ValueMapT &Map) {
|
||||
for (unsigned i = 0; i < OldValues.size(); i++) {
|
||||
Value *Address = Builder.CreateStructGEP(Ty, Struct, i);
|
||||
Value *NewValue = Builder.CreateLoad(Address);
|
||||
@ -317,8 +316,7 @@ void ParallelLoopGenerator::extractValuesFromStruct(
|
||||
|
||||
Value *ParallelLoopGenerator::createSubFn(Value *Stride, AllocaInst *StructData,
|
||||
SetVector<Value *> Data,
|
||||
ValueToValueMapTy &Map,
|
||||
Function **SubFnPtr) {
|
||||
ValueMapT &Map, Function **SubFnPtr) {
|
||||
BasicBlock *PrevBB, *HeaderBB, *ExitBB, *CheckNextBB, *PreHeaderBB, *AfterBB;
|
||||
Value *LBPtr, *UBPtr, *UserContext, *Ret1, *HasNextSchedule, *LB, *UB, *IV;
|
||||
Function *SubFn = createSubFnDefinition();
|
||||
|
Loading…
x
Reference in New Issue
Block a user