Ignore:
Timestamp:
Nov 18, 2016, 1:46:55 PM (2 years ago)
Author:
nmedfort
Message:

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/prototype.cpp

    r5216 r5217  
    1 #include "function.h"
     1#include "prototype.h"
    22#include <pablo/codegenstate.h>
    33#include <cstring>
     
    1313}
    1414
    15 PabloFunction::PabloFunction(std::string && name)
    16 : Prototype(ClassTypeId::Function, std::move(name), 0, 0)
    17 , mSymbolTable(new SymbolGenerator())
    18 , mEntryBlock(PabloBlock::Create(*this))
    19 , mConstants(0, nullptr) {
    20 
    2115}
    22 
    23 Var * PabloFunction::addParameter(const std::string name, Type * const type) {
    24     Var * param = new Var(mSymbolTable->make(name), type);
    25     mParameters.push_back(param);
    26     mNumOfParameters = mParameters.size();
    27     return param;
    28 }
    29 
    30 Var * PabloFunction::addResult(const std::string name, Type * const type) {
    31     Var * result = new Var(mSymbolTable->make(name), type);
    32     mResults.push_back(result);
    33     mNumOfResults = mResults.size();
    34     return result;
    35 }
    36 
    37 Var * PabloFunction::makeVariable(PabloAST * name, Type * const type) {
    38     Var * const var = new Var(name, type);
    39     mVariables.push_back(var);
    40     return var;
    41 }
    42 
    43 Zeroes * PabloFunction::getNullValue(Type * type) {
    44     if (type == nullptr) {
    45         type = getStreamTy();
    46     }
    47     for (PabloAST * constant : mConstants) {
    48         if (isa<Zeroes>(constant) && constant->getType() == type) {
    49             return cast<Zeroes>(constant);
    50         }
    51     }
    52     Zeroes * value = new Zeroes(type);
    53     mConstants.push_back(value);
    54     return value;
    55 }
    56 
    57 Ones * PabloFunction::getAllOnesValue(Type * type) {
    58     if (type == nullptr) {
    59         type = getStreamTy();
    60     }
    61     for (PabloAST * constant : mConstants) {
    62         if (isa<Ones>(constant) && constant->getType() == type) {
    63             return cast<Ones>(constant);
    64         }
    65     }
    66     Ones * value = new Ones(type);
    67     mConstants.push_back(value);
    68     return value;
    69 }
    70 
    71 void PabloFunction::throwInvalidParameterIndex(const unsigned index) const {
    72     throw std::runtime_error(
    73                 "Invalid parameter index " +
    74                 std::to_string(index) + " of " + std::to_string(getNumOfParameters()) +
    75                 " in function " + getName()->to_string());
    76 }
    77 
    78 void PabloFunction::throwInvalidResultIndex(const unsigned index) const {
    79     throw std::runtime_error(
    80                 "Invalid result index " +
    81                 std::to_string(index) + " of " + std::to_string(getNumOfResults()) +
    82                 " in function " + getName()->to_string());
    83 }
    84 
    85 void PabloFunction::operator delete(void * ptr) {
    86     PabloFunction * f = static_cast<PabloFunction *>(ptr);
    87     delete f->mSymbolTable;
    88     f->mSymbolTable = nullptr;
    89 }
    90 
    91 }
Note: See TracChangeset for help on using the changeset viewer.