Ignore:
Timestamp:
Sep 23, 2016, 4:12:41 PM (3 years ago)
Author:
nmedfort
Message:

Initial work for incorporating Types into Pablo AST.

File:
1 edited

Legend:

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

    r5156 r5160  
    1616#include <unordered_map>
    1717#include <vector>
     18#include <pablo/pablo_type.h>
    1819
    1920using namespace llvm;
     
    2223
    2324class PabloBlock;
     25class Statement;
    2426class String;
    25 class Statement;
    2627
    2728class PabloAST {
     
    110111    }
    111112
     113    inline const PabloType * getType() const {
     114        return mType;
     115    }
     116
    112117    void replaceAllUsesWith(PabloAST * const expr);
    113118
     
    125130
    126131protected:
    127     inline PabloAST(const ClassTypeId id)
     132    inline PabloAST(const ClassTypeId id, const PabloType * const type)
    128133    : mClassTypeId(id)
     134    , mType(type)
    129135    , mUsers(mVectorAllocator)
    130136    {
     
    135141    virtual ~PabloAST() {
    136142        mUsers.clear();
    137     }
     143    }   
     144    static void throwIfNonMatchingTypes(const PabloAST * const a, const PabloAST * const b);
     145    static void throwIfNonMatchingType(const PabloAST * const a, const PabloType::TypeId typeId);
    138146    static Allocator        mAllocator;
    139147    static VectorAllocator  mVectorAllocator;
    140148private:
    141149    const ClassTypeId       mClassTypeId;
     150    const PabloType * const mType;
    142151    Users                   mUsers;
    143152};
     
    218227    virtual ~Statement() {}
    219228protected:
    220     explicit Statement(const ClassTypeId id, std::initializer_list<PabloAST *> operands, const String * const name)
    221     : PabloAST(id)
     229    explicit Statement(const ClassTypeId id, const PabloType * const type, std::initializer_list<PabloAST *> operands, const String * const name)
     230    : PabloAST(id, type)
    222231    , mName(name)
    223232    , mNext(nullptr)
     
    234243        }
    235244    }
    236     explicit Statement(const ClassTypeId id, const unsigned reserved, const String * const name)
    237     : PabloAST(id)
     245    explicit Statement(const ClassTypeId id, const PabloType * const type, const unsigned reserved, const String * const name)
     246    : PabloAST(id, type)
    238247    , mName(name)
    239248    , mNext(nullptr)
     
    245254    }
    246255    template<typename iterator>
    247     explicit Statement(const ClassTypeId id, iterator begin, iterator end, const String * const name)
    248     : PabloAST(id)
     256    explicit Statement(const ClassTypeId id, const PabloType * const type, iterator begin, iterator end, const String * const name)
     257    : PabloAST(id, type)
    249258    , mName(name)
    250259    , mNext(nullptr)
     
    334343
    335344protected:
    336     explicit Variadic(const ClassTypeId id, std::initializer_list<PabloAST *> operands, const String * const name)
    337     : Statement(id, operands, name)
     345    explicit Variadic(const ClassTypeId id, const PabloType * const type, std::initializer_list<PabloAST *> operands, const String * const name)
     346    : Statement(id, type, operands, name)
    338347    , mCapacity(operands.size()) {
    339348
    340349    }
    341     explicit Variadic(const ClassTypeId id, const unsigned reserved, String * name)
    342     : Statement(id, reserved, name)
     350    explicit Variadic(const ClassTypeId id, const PabloType * const type, const unsigned reserved, String * name)
     351    : Statement(id, type, reserved, name)
    343352    , mCapacity(reserved) {
    344353
    345354    }
    346355    template<typename iterator>
    347     explicit Variadic(const ClassTypeId id, iterator begin, iterator end, String * name)
    348     : Statement(id, begin, end, name)
     356    explicit Variadic(const ClassTypeId id, const PabloType * const type, iterator begin, iterator end, String * name)
     357    : Statement(id, type, begin, end, name)
    349358    , mCapacity(std::distance(begin, end)) {
    350359
Note: See TracChangeset for help on using the changeset viewer.