Ignore:
Timestamp:
Jan 19, 2017, 2:41:02 PM (3 years ago)
Author:
nmedfort
Message:

Code clean-up. Removed Pablo Call, SetIthBit? and Prototype.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5245 r5267  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <pablo/symbol_generator.h>
    12 #include <pablo/boolean.h>
    13 #include <pablo/arithmetic.h>
    14 #include <pablo/branch.h>
    15 
    16 #include <pablo/pe_advance.h>
    17 #include <pablo/pe_lookahead.h>
    18 #include <pablo/pe_matchstar.h>
    19 #include <pablo/pe_scanthru.h>
    20 #include <pablo/pe_infile.h>
    21 
    22 #include <pablo/pe_count.h>
    23 
     11#include <pablo/pablo_kernel.h>
    2412#include <pablo/pe_integer.h>
    25 #include <pablo/pe_string.h>
    26 #include <pablo/pe_zeroes.h>
    27 #include <pablo/pe_ones.h>
    28 
    29 #include <pablo/pe_var.h>
    30 #include <pablo/ps_assign.h>
    31 
    32 #include <pablo/pe_call.h>
    33 
    34 #include <pablo/pablo_kernel.h>
    35 
    36 #include <llvm/ADT/ArrayRef.h>
    37 #include <stdexcept>
     13namespace llvm { class Type; }
     14namespace llvm { class raw_ostream; }
     15namespace pablo { class Add; }
     16namespace pablo { class Advance; }
     17namespace pablo { class And; }
     18namespace pablo { class Assign; }
     19namespace pablo { class AtEOF; }
     20namespace pablo { class Branch; }
     21namespace pablo { class If; }
     22namespace pablo { class While; }
     23namespace pablo { class Count; }
     24namespace pablo { class Extract; }
     25namespace pablo { class InFile; }
     26namespace pablo { class LessThan; }
     27namespace pablo { class Lookahead; }
     28namespace pablo { class MatchStar; }
     29namespace pablo { class Not; }
     30namespace pablo { class Ones; }
     31namespace pablo { class Or; }
     32namespace pablo { class PabloKernel; }
     33namespace pablo { class ScanThru; }
     34namespace pablo { class Sel; }
     35namespace pablo { class String; }
     36namespace pablo { class Subtract; }
     37namespace pablo { class Var; }
     38namespace pablo { class Xor; }
     39namespace pablo { class Zeroes; }
     40
    3841
    3942namespace pablo {
    40 
    41 class PabloKernel;
    4243
    4344class PabloBlock : public PabloAST, public StatementList {
     
    6162    }
    6263
    63     inline static PabloBlock * Create(PabloKernel * const parent) noexcept {
    64         Allocator & allocator = parent->mAllocator;
    65         return new (allocator) PabloBlock(parent, allocator);
    66     }
     64    static PabloBlock * Create(PabloKernel * const parent) noexcept;
    6765
    6866    Advance * createAdvance(PabloAST * expr, PabloAST * shiftAmount) {
     
    8684    Lookahead * createLookahead(PabloAST * expr, PabloAST * shiftAmount, String * name);
    8785
    88     inline Zeroes * createZeroes(Type * const type = nullptr) {
     86    inline Zeroes * createZeroes(llvm::Type * const type = nullptr) {
    8987        return mParent->getNullValue(type);
    9088    }
    9189
    92     inline Ones * createOnes(Type * const type = nullptr) {
     90    inline Ones * createOnes(llvm::Type * const type = nullptr) {
    9391        return mParent->getAllOnesValue(type);
    94     }
    95 
    96     inline Call * createCall(Prototype * prototype, const std::vector<Var *> & args) {
    97         return createCall(prototype, reinterpret_cast<const std::vector<PabloAST *> &>(args));
    98     }
    99 
    100     inline Call * createCall(Prototype * prototype, const std::vector<PabloAST *> & args) {
    101         if (prototype == nullptr) {
    102             throw std::runtime_error("Call object cannot be created with a Null prototype!");
    103         }
    104         if (args.size() != cast<Prototype>(prototype)->getNumOfParameters()) {
    105             throw std::runtime_error("Invalid number of arguments passed into Call object!");
    106         }
    107         return createCall(static_cast<PabloAST *>(prototype), args);
    10892    }
    10993
     
    118102    Not * createNot(PabloAST * expr, String * name);
    119103
    120     inline Var * createVar(const std::string & name, Type * const type = nullptr) {
     104    inline Var * createVar(const std::string & name, llvm::Type * const type = nullptr) {
    121105        return createVar(makeName(name), type);
    122106    }
    123107
    124     inline Var * createVar(String * name, Type * const type = nullptr) {
    125         return createVar(cast<PabloAST>(name), type);
     108    inline Var * createVar(String * name, llvm::Type * const type = nullptr) {
     109        return createVar(reinterpret_cast<PabloAST *>(name), type);
    126110    }
    127111
     
    150134    AtEOF * createAtEOF(PabloAST * expr, String * name);
    151135
     136    inline Extract * createExtract(PabloAST * array, PabloAST * index) {
     137        return createExtract(array, index, nullptr);
     138    }
     139
     140    Extract * createExtract(PabloAST * array, PabloAST * index, const std::string & prefix) {
     141        return createExtract(array, index, makeName(prefix));
     142    }
     143
    152144    Extract * createExtract(PabloAST * array, const int64_t index) {
    153145        return createExtract(array, getInteger(index), nullptr);
    154146    }
    155147
    156     inline Extract * createExtract(PabloAST * array, PabloAST * index) {
    157         return createExtract(array, index, nullptr);
    158     }
    159 
    160     Extract * createExtract(PabloAST * array, PabloAST * index, const std::string & prefix) {
    161         return createExtract(array, index, makeName(prefix));
    162     }
    163 
    164148    Extract * createExtract(PabloAST * array, const int64_t index, const std::string & prefix) {
    165149        return createExtract(array, getInteger(index), makeName(prefix));
     
    180164    And * createAnd(PabloAST * expr1, PabloAST * expr2, String * name);
    181165
    182     And * createAnd(Type * const type, const unsigned reserved) {
     166    And * createAnd(llvm::Type * const type, const unsigned reserved) {
    183167        return createAnd(type, reserved, nullptr);
    184168    }
    185169
    186     And * createAnd(Type * const type, const unsigned reserved, String * name);
     170    And * createAnd(llvm::Type * const type, const unsigned reserved, String * name);
    187171
    188172    Or * createOr(PabloAST * expr1, PabloAST * expr2) {
     
    196180    Or * createOr(PabloAST * expr1, PabloAST * expr2, String * name);
    197181
    198     Or * createOr(Type * const type, const unsigned reserved) {
     182    Or * createOr(llvm::Type * const type, const unsigned reserved) {
    199183        return createOr(type, reserved, nullptr);
    200184    }
    201185
    202     Or * createOr(Type * const type, const unsigned reserved, String * name);
     186    Or * createOr(llvm::Type * const type, const unsigned reserved, String * name);
    203187
    204188    Xor * createXor(PabloAST * expr1, PabloAST * expr2) {
     
    212196    Xor * createXor(PabloAST * expr1, PabloAST * expr2, String * name);
    213197
    214     Xor * createXor(Type * const type, const unsigned reserved) {
     198    Xor * createXor(llvm::Type * const type, const unsigned reserved) {
    215199        return createXor(type, reserved, nullptr);
    216200    }
    217201
    218     Xor * createXor(Type * const type, const unsigned reserved, String * name);
     202    Xor * createXor(llvm::Type * const type, const unsigned reserved, String * name);
    219203
    220204    Sel * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr) {
     
    258242    While * createWhile(PabloAST * condition, PabloBlock * body);
    259243
    260     Type * getStreamTy(const unsigned FieldWidth = 1) {
     244    llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
    261245        return mParent->getStreamTy(FieldWidth);
    262246    }
    263247   
    264     Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
     248    llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    265249        return mParent->getStreamSetTy(NumElements, FieldWidth);
    266250    }
    267251   
    268     inline PabloBlock * getPredecessor() const {
    269         return getBranch() ? getBranch()->getParent() : nullptr;
    270     }
     252    PabloBlock * getPredecessor() const;
    271253
    272254    inline PabloKernel * getParent() const {
     
    306288    }
    307289
    308     void print(raw_ostream & O, const bool expandNested = true) const;
     290    void print(llvm::raw_ostream & O, const bool expandNested = true) const;
    309291
    310292    virtual ~PabloBlock() {}
     
    323305    template<typename Type>
    324306    inline Type * insertAtInsertionPoint(Type * expr) {
    325         if (isa<Statement>(expr)) {
    326             insert(cast<Statement>(expr));
     307        if (llvm::isa<Statement>(expr)) {
     308            insert(llvm::cast<Statement>(expr));
    327309        }
    328310        return expr;
    329311    }
    330312
    331     Call * createCall(PabloAST * prototype, const std::vector<PabloAST *> &);
    332 
    333     Var * createVar(PabloAST * name, Type * const type);
     313    Var * createVar(PabloAST * name, llvm::Type * const type);
    334314
    335315private:       
Note: See TracChangeset for help on using the changeset viewer.