Changeset 4284


Ignore:
Timestamp:
Nov 1, 2014, 2:10:07 PM (4 years ago)
Author:
nmedfort
Message:

Initial stage of pablo metadata inclusion.

Location:
icGREP/icgrep-devel/icgrep
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4280 r4284  
    5151set(Boost_USE_MULTITHREADED OFF)
    5252set(Boost_USE_STATIC_RUNTIME OFF)
    53 find_package(Boost COMPONENTS system filesystem)
     53find_package(Boost COMPONENTS system REQUIRED)
    5454
    5555add_library(PabloADT pablo/pe_and.cpp pablo/pe_not.cpp pablo/pe_or.cpp  pablo/pabloAST.cpp  pablo/pe_sel.cpp  pablo/pe_xor.cpp pablo/codegenstate.cpp  pablo/symbol_generator.cpp pablo/analysis/useanalysis.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp)
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r4280 r4284  
    3333namespace cc {
    3434
    35 CC_Compiler::CC_Compiler(PabloBlock & cg, const Encoding encoding, const std::string basis_pattern)
     35CC_Compiler::CC_Compiler(PabloBlock & cg, const Encoding encoding, const bool annotateVariableConstraints, const std::string basis_pattern)
    3636: mCG(cg)
     37, mAnnotateVariableConstraints(annotateVariableConstraints)
    3738, mBasisBit(encoding.getBits())
    3839, mEncoding(encoding)
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r4270 r4284  
    2222public:
    2323
    24     CC_Compiler(pablo::PabloBlock & cg, const Encoding encoding, const std::string basis_pattern = "basis");
     24    CC_Compiler(pablo::PabloBlock & cg, const Encoding encoding, const bool annotateVariableConstraints = false, const std::string basis_pattern = "basis");
    2525
    2626    std::vector<pablo::Var *> compile(const CC_NameMap & nameMap);
     
    4242    pablo::PabloAST * charset_expr(const re::CC *cc);
    4343    pablo::PabloAST * tempify(pablo::PabloAST * value);
     44
     45private:
    4446    pablo::PabloBlock &         mCG;
     47    const bool                  mAnnotateVariableConstraints;
    4548    std::vector<pablo::Var *>   mBasisBit;
    4649    const Encoding              mEncoding;
  • icGREP/icgrep-devel/icgrep/icgrep-devel.config

    r4182 r4284  
    1 // Add predefined macros for your project here. For example:
    2 // #define THE_ANSWER 42
     1#define USE_LLVM_3_5
  • icGREP/icgrep-devel/icgrep/icgrep-devel.files

    r4280 r4284  
    226226re/re_re.cpp
    227227pablo/ps_if.cpp
     228pablo/pe_metadata.h
  • icGREP/icgrep-devel/icgrep/pablo/analysis/useanalysis.cpp

    r4282 r4284  
    11#include "useanalysis.h"
    2 #ifdef USE_BOOST
    32#include <queue>
    43
     
    1615
    1716void UseAnalysis::cse(PabloBlock & block) {
    18 
    1917    VertexIterator vi, vi_end;
    2018    auto mGraphMap = get(vertex_name, mUseDefGraph);
    2119    for (std::tie(vi, vi_end) = vertices(mUseDefGraph); vi != vi_end; ++vi) {
    2220        const Vertex u = *vi;
    23         if (out_degree(u, mUseDefGraph) > 1) {
     21        const auto count = out_degree(u, mUseDefGraph) ;
     22        if (count > 1) {
    2423            PabloAST * expr = mGraphMap[u];
    2524            if (isa<Statement>(expr) || isa<Var>(expr)) {
     
    116115}
    117116
    118 
    119117void UseAnalysis::dce() {
    120118    auto mGraphMap = get(vertex_name, mUseDefGraph);
     
    241239}
    242240}
    243 #endif
  • icGREP/icgrep-devel/icgrep/pablo/analysis/useanalysis.h

    r4280 r4284  
    33
    44#include <pablo/codegenstate.h>
    5 
    6 #ifdef USE_BOOST
    75#include <boost/graph/adjacency_list.hpp>
    86#include <unordered_map>
     
    3937
    4038}
    41 #else
    42 
    43 namespace pablo {
    44 class UseAnalysis {
    45 public:
    46     static bool optimize(PabloBlock &) {
    47         return false;
    48     }
    49 };
    50 }
    51 
    52 #endif
    5339
    5440#endif // USEANALYSIS_H
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r4280 r4284  
    9292}
    9393
     94
     95void PabloAST::setMetadata(const std::string & name, PMDNode * node) {
     96    if (LLVM_UNLIKELY(mMetadataMap == nullptr)) {
     97        mMetadataMap = new PMDNodeMap();
     98    }
     99    mMetadataMap->insert(std::make_pair(name, node));
     100}
     101
     102PMDNode * PabloAST::getMetadata(const std::string & name) {
     103    if (LLVM_UNLIKELY(mMetadataMap == nullptr)) {
     104        return nullptr;
     105    }
     106    auto f = mMetadataMap->find(name);
     107    if (f == mMetadataMap->end()) {
     108        return nullptr;
     109    }
     110    return f->second;
     111}
     112
    94113Statement::~Statement() {
    95114
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4280 r4284  
    1212#include <slab_allocator.h>
    1313#include <iterator>
     14#include <unordered_map>
    1415
    1516using namespace llvm;
     
    1920class PabloBlock;
    2021
     22class PMDNode;
     23
    2124class PabloAST {
     25    friend class PMDNode;
     26    typedef std::unordered_map<std::string, PMDNode *> PMDNodeMap;
    2227public:
    2328    typedef SlabAllocator<1024> Allocator;
     
    6267    virtual void setOperand(const unsigned index, PabloAST * value) = 0;
    6368
     69    void setMetadata(const std::string & name, PMDNode * node);
     70
     71    PMDNode * getMetadata(const std::string & name);
     72
    6473    inline static void release_memory() {
    6574        mAllocator.release_memory();
     75    }
     76
     77    void* operator new (std::size_t size) noexcept {
     78        return mAllocator.allocate(size);
    6679    }
    6780protected:
    6881    inline PabloAST(const ClassTypeId id)
    6982    : mClassTypeId(id)
     83    , mMetadataMap(nullptr)
    7084    {
    7185
     
    7488private:
    7589    const ClassTypeId   mClassTypeId;
     90    PMDNodeMap *        mMetadataMap;
    7691};
    7792
     
    106121    inline void insertAfter(Statement * const statement);
    107122    inline void removeFromParent();
    108 
     123    inline Statement * getNextNode() const {
     124        return mNext;
     125    }
     126    inline Statement * getPrevNode() const {
     127        return mPrev;
     128    }
     129    inline StatementList * getParent() const {
     130        return mParent;
     131    }
    109132protected:
    110133    Statement(const ClassTypeId id, StatementList * parent)
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4282 r4284  
    172172    delete fZp;
    173173    delete fZs;
    174 
    175174}
    176175
     
    252251    fpm.add(new DataLayoutPass(mMod));
    253252#endif
    254 
    255253#ifdef USE_LLVM_3_4
    256254    fpm.add(new DataLayout(*mExecutionEngine->getDataLayout()));
    257 #endif
    258 #ifndef USE_BOOST
    259     fpm.add(createCorrelatedValuePropagationPass());
    260     fpm.add(createEarlyCSEPass());
    261     fpm.add(createInstructionCombiningPass());    //Simple peephole optimizations and bit-twiddling.
    262     fpm.add(createReassociatePass());             //Reassociate expressions.
    263     fpm.add(createGVNPass());                     //Eliminate common subexpressions.
    264255#endif
    265256    fpm.doInitialization();
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r4280 r4284  
    4141    }
    4242protected:
    43     void* operator new (std::size_t size) noexcept {
    44         return mAllocator.allocate(size);
    45     }
    4643    Advance(PabloAST * expr, int shiftAmount)
    4744    : PabloAST(ClassTypeId::Advance)
  • icGREP/icgrep-devel/icgrep/pablo/pe_and.h

    r4280 r4284  
    4545    }
    4646protected:
    47     void* operator new (std::size_t size) noexcept {
    48         return mAllocator.allocate(size);
    49     }
    5047    And(PabloAST * expr1, PabloAST * expr2)
    5148    : PabloAST(ClassTypeId::And)
  • icGREP/icgrep-devel/icgrep/pablo/pe_call.h

    r4280 r4284  
    3535    }
    3636protected:
    37     void* operator new (std::size_t size) noexcept {
    38         return mAllocator.allocate(size);
    39     }
    4037    Call(PabloAST * callee)
    4138    : PabloAST(ClassTypeId::Call)
  • icGREP/icgrep-devel/icgrep/pablo/pe_next.h

    r4280 r4284  
    4141    }
    4242protected:
    43     void* operator new (std::size_t size) noexcept {
    44         return mAllocator.allocate(size);
    45     }
    4643    Next(PabloAST * initial, PabloAST * expr, StatementList * parent)
    4744    : Statement(ClassTypeId::Next, parent)
  • icGREP/icgrep-devel/icgrep/pablo/pe_not.h

    r4280 r4284  
    4141    }
    4242protected:
    43     void* operator new (std::size_t size) noexcept {
    44         return mAllocator.allocate(size);
    45     }
    4643    Not(PabloAST * expr)
    4744    : PabloAST(ClassTypeId::Not)
  • icGREP/icgrep-devel/icgrep/pablo/pe_ones.h

    r4280 r4284  
    4040    }
    4141protected:
    42     void* operator new (std::size_t size) noexcept {
    43         return mAllocator.allocate(size);
    44     }
    4542    Ones() : PabloAST(ClassTypeId::Ones) { }
    4643};
  • icGREP/icgrep-devel/icgrep/pablo/pe_or.h

    r4280 r4284  
    4545    }
    4646protected:
    47     void* operator new (std::size_t size) noexcept {
    48         return mAllocator.allocate(size);
    49     }
    5047    Or(PabloAST * expr1, PabloAST * expr2)
    5148    : PabloAST(ClassTypeId::Or)
  • icGREP/icgrep-devel/icgrep/pablo/pe_sel.h

    r4280 r4284  
    4848    }
    4949protected:
    50     void* operator new (std::size_t size) noexcept {
    51         return mAllocator.allocate(size);
    52     }
    5350    Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr)
    5451    : PabloAST(ClassTypeId::Sel)
  • icGREP/icgrep-devel/icgrep/pablo/pe_var.h

    r4280 r4284  
    6060    }
    6161protected:
    62     void* operator new (std::size_t size) noexcept {
    63         return mAllocator.allocate(size);
    64     }
    6562    Var(PabloAST * var)
    6663    : PabloAST(ClassTypeId::Var)
  • icGREP/icgrep-devel/icgrep/pablo/pe_xor.h

    r4280 r4284  
    4545    }
    4646protected:
    47     void* operator new (std::size_t size) noexcept {
    48         return mAllocator.allocate(size);
    49     }
    5047    Xor(PabloAST * expr1, PabloAST * expr2)
    5148    : PabloAST(ClassTypeId::Xor)
  • icGREP/icgrep-devel/icgrep/pablo/pe_zeroes.h

    r4280 r4284  
    4141    }
    4242protected:
    43     void* operator new (std::size_t size) noexcept {
    44         return mAllocator.allocate(size);
    45     }
    4643    Zeroes() : PabloAST(ClassTypeId::Zeroes) { }
    4744};
  • icGREP/icgrep-devel/icgrep/pablo/ps_assign.h

    r4280 r4284  
    4949    }
    5050protected:
    51     void* operator new (std::size_t size) noexcept {
    52         return mAllocator.allocate(size);
    53     }
    5451    Assign(PabloAST * name, PabloAST * expr, const int outputIndex, StatementList * parent)
    5552    : Statement(ClassTypeId::Assign, parent)
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.h

    r4280 r4284  
    5050    }
    5151protected:
    52     void* operator new (std::size_t size) noexcept {
    53         return mAllocator.allocate(size);
    54     }
    5552    If(PabloAST * expr, StatementList && body, StatementList * parent)
    5653    : Statement(ClassTypeId::If, parent)
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4280 r4284  
    5050    }
    5151protected:
    52     void* operator new (std::size_t size) noexcept {
    53         return mAllocator.allocate(size);
    54     }
    5552    While(PabloAST * expr, StatementList && body, StatementList * parent)
    5653    : Statement(ClassTypeId::While, parent)
Note: See TracChangeset for help on using the changeset viewer.