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/function.cpp

    r4870 r5160  
    66
    77Prototype::Prototype(const PabloAST::ClassTypeId type, std::string && name, const unsigned numOfParameters, const unsigned numOfResults, void * functionPtr)
    8 : PabloAST(type)
     8: PabloAST(type, nullptr)
    99, mName(GlobalSymbolGenerator.get(name, false))
    1010, mNumOfParameters(numOfParameters)
     
    1717: Prototype(ClassTypeId::Function, std::move(name), numOfParameters, numOfResults, nullptr)
    1818, mSymbolTable(new SymbolGenerator())
     19, mBitStreamType(getPabloType(PabloType::Stream, 1))
    1920, mEntryBlock(PabloBlock::Create(*this))
    20 , mParameters(reinterpret_cast<Var **>(mAllocator.allocate(sizeof(Var *) * numOfParameters)))
    21 , mResults(reinterpret_cast<Assign **>(mAllocator.allocate(sizeof(Assign *) * numOfResults))) {
    22     std::memset(mParameters, 0, sizeof(Var *) * numOfParameters);
    23     std::memset(mResults, 0, sizeof(Assign *) * numOfResults);
     21, mParameters(numOfParameters, nullptr)
     22, mResults(numOfResults, nullptr)
     23, mConstants(0, nullptr) {
     24
     25}
     26
     27Zeroes * PabloFunction::getNullValue(const PabloType * type) {
     28    if (type == nullptr) {
     29        type = mBitStreamType;
     30    }
     31    for (PabloAST * constant : mConstants) {
     32        if (isa<Zeroes>(constant) && constant->getType() == type) {
     33            return cast<Zeroes>(constant);
     34        }
     35    }
     36    Zeroes * value = new Zeroes(type);
     37    mConstants.push_back(value);
     38    return value;
     39}
     40
     41Ones * PabloFunction::getAllOnesValue(const PabloType * type) {
     42    if (type == nullptr) {
     43        type = mBitStreamType;
     44    }
     45    for (PabloAST * constant : mConstants) {
     46        if (isa<Ones>(constant) && constant->getType() == type) {
     47            return cast<Ones>(constant);
     48        }
     49    }
     50    Ones * value = new Ones(type);
     51    mConstants.push_back(value);
     52    return value;
    2453}
    2554
Note: See TracChangeset for help on using the changeset viewer.