Ignore:
Timestamp:
Nov 6, 2016, 8:37:11 PM (3 years ago)
Author:
nmedfort
Message:

Initial work on adding types to PabloAST and mutable Var objects.

File:
1 edited

Legend:

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

    r5160 r5202  
    99
    1010#include <pablo/pabloAST.h>
    11 #include <pablo/ps_assign.h>
    12 #include <pablo/pe_next.h>
    1311#include <pablo/pe_string.h>
    14 #include <stdexcept>
    15 
    16 namespace llvm {
    17     class Value;
    18     class BasicBlock;
    19 }
     12#include <pablo/pe_integer.h>
    2013
    2114namespace pablo {
    2215
     16class Assign;
     17
     18// A Var is unique in that it is not a statement but a "lives" within a
     19// scope and cannot be accessed outside of it. A Var is mutable (via an
     20// Assign instruction.
     21
    2322class Var : public PabloAST {
    2423    friend class PabloBlock;
    25     friend class And;
    26     friend class Or;
    27     friend class Not;
    28     friend class Sel;
    29     friend class Xor;
    30     friend class Zeroes;
    31     friend class Ones;
     24    friend class PabloAST;
     25    friend class PabloFunction;
     26    friend class Statement;
    3227public:
    3328    static inline bool classof(const PabloAST * e) {
     
    3732        return false;
    3833    }
    39     virtual ~Var(){
     34protected:
     35    Var(const PabloAST * name, Type * const type)
     36    : PabloAST(ClassTypeId::Var, type, cast<String>(name)) {
     37
    4038    }
    41     inline const String * getName() const {
    42         return mName;
     39};
     40
     41class Extract : public Statement {
     42    friend class PabloBlock;
     43public:
     44    static inline bool classof(const PabloAST * e) {
     45        return e->getClassTypeId() == ClassTypeId::Extract;
     46    }
     47    static inline bool classof(const void *) {
     48        return false;
     49    }
     50    virtual ~Extract(){
     51    }
     52    inline PabloAST * getArray() const {
     53        return getOperand(0);
     54    }
     55    inline Integer * getIndex() const {
     56        return cast<Integer>(getOperand(1));
    4357    }
    4458protected:
    45     Var(PabloAST * var, const PabloType * const type)
    46     : PabloAST(ClassTypeId::Var, type)
    47     , mName(cast<String>(var)) {
     59    Extract(PabloAST * array, PabloAST * const index, const String * const name)
     60    : Statement(ClassTypeId::Extract, cast<ArrayType>(array->getType())->getArrayElementType(), {array, cast<Integer>(index)}, name) {
    4861
    4962    }
    50 private:
    51     const String *     mName;
    5263};
    5364
    54 }
     65//class Extract : public PabloAST {
     66//    friend class PabloBlock;
     67//public:
     68//    static inline bool classof(const PabloAST * e) {
     69//        return e->getClassTypeId() == ClassTypeId::Extract;
     70//    }
     71//    static inline bool classof(const void *) {
     72//        return false;
     73//    }
     74//    virtual ~Extract(){
     75//    }
     76//    inline const String * getName() const {
     77//        if (isa<Parameter>(mArray)) {
     78//            return cast<Parameter>(mArray)->getName();
     79//        } else {
     80//            return cast<Statement>(mArray)->getName();
     81//        }
     82//    }
     83//    inline const PabloAST * getArray() const {
     84//        return mArray;
     85//    }
     86//    inline const Integer * getIndex() const {
     87//        return mIndex;
     88//    }
     89//protected:
     90//    Extract(PabloAST * array, PabloAST * const index)
     91//    : PabloAST(ClassTypeId::Extract, array->getType()->getIndexedType())
     92//    , mArray(array)
     93//    , mIndex(cast<Integer>(index)) {
     94//        assert (isa<Parameter>(array) || isa<Statement>(array));
     95//    }
     96//private:
     97//    PabloAST * mArray;
     98//    Integer * mIndex;
     99//};
     100
     101//class ParameterBinding {
     102//    using Allocator = SlabAllocator<Parameter *>;
     103
     104//public:
     105
     106//    void add(Parameter * const param);
     107
     108//private:
     109//    std::vector<Parameter *, Allocator> mParameters;
     110//};
    55111
    56112
     113}
    57114
    58115#endif // PE_VAR_H
Note: See TracChangeset for help on using the changeset viewer.