source: icGREP/icgrep-devel/icgrep/pablo/function.cpp @ 4744

Last change on this file since 4744 was 4726, checked in by cameron, 4 years ago

Embed carry data in compiled LLVM module; eliminate passing of carry data pointers/size

File size: 1.5 KB
Line 
1#include "function.h"
2#include <pablo/codegenstate.h>
3#include <cstring>
4
5namespace pablo {
6
7Prototype::Prototype(const PabloAST::ClassTypeId type, std::string && name, const unsigned numOfParameters, const unsigned numOfResults, void * functionPtr)
8: PabloAST(type)
9, mName(GlobalSymbolGenerator.get(name, false))
10, mNumOfParameters(numOfParameters)
11, mNumOfResults(numOfResults)
12, mFunctionPtr(functionPtr) {
13
14}
15
16PabloFunction::PabloFunction(std::string && name, const unsigned numOfParameters, const unsigned numOfResults)
17: Prototype(ClassTypeId::Function, std::move(name), numOfParameters, numOfResults, nullptr)
18, mEntryBlock(PabloBlock::Create(mSymbolTable))
19, mParameters(reinterpret_cast<Var **>(mAllocator.allocate(sizeof(Var *) * numOfParameters)))
20, mResults(reinterpret_cast<Assign **>(mAllocator.allocate(sizeof(Assign *) * numOfResults))) {
21    std::memset(mParameters, 0, sizeof(Var *) * numOfParameters);
22    std::memset(mResults, 0, sizeof(Assign *) * numOfResults);
23}
24
25void PabloFunction::throwInvalidParameterIndex(const unsigned index) const {
26    throw std::runtime_error(
27                "Invalid parameter index " +
28                std::to_string(index) + " of " + std::to_string(getNumOfParameters()) +
29                " in function " + getName()->to_string());
30}
31
32void PabloFunction::throwInvalidResultIndex(const unsigned index) const {
33    throw std::runtime_error(
34                "Invalid result index " +
35                std::to_string(index) + " of " + std::to_string(getNumOfResults()) +
36                " in function " + getName()->to_string());
37}
38
39}
Note: See TracBrowser for help on using the repository browser.