source: icGREP/icgrep-devel/icgrep/toolchain/driver.cpp

Last change on this file was 6288, checked in by cameron, 7 months ago

Repeat of prior check in

File size: 4.0 KB
RevLine 
[5464]1#include "driver.h"
2#include <kernels/kernel_builder.h>
[6184]3#include <kernels/pipeline_builder.h>
[5464]4#include <llvm/IR/Module.h>
[6184]5#include <toolchain/toolchain.h>
6#include <toolchain/object_cache.h>
7#include <llvm/Support/raw_ostream.h>
[5464]8
[6184]9using namespace kernel;
[5464]10
[6184]11using RelationshipAllocator = Relationship::Allocator;
[5464]12
[6184]13/** ------------------------------------------------------------------------------------------------------------- *
14 * @brief makePipelineWithIO
15 ** ------------------------------------------------------------------------------------------------------------- */
[6253]16std::unique_ptr<ProgramBuilder> BaseDriver::makePipelineWithIO(Bindings stream_inputs, Bindings stream_outputs, Bindings scalar_inputs, Bindings scalar_outputs) {
17    return llvm::make_unique<ProgramBuilder>(*this, std::move(stream_inputs), std::move(stream_outputs), std::move(scalar_inputs), std::move(scalar_outputs));
[6184]18}
[5464]19
[6184]20/** ------------------------------------------------------------------------------------------------------------- *
21 * @brief makePipeline
22 ** ------------------------------------------------------------------------------------------------------------- */
[6253]23std::unique_ptr<ProgramBuilder> BaseDriver::makePipeline(Bindings scalar_inputs, Bindings scalar_outputs) {
24    return llvm::make_unique<ProgramBuilder>(*this, Bindings{}, Bindings{}, std::move(scalar_inputs), std::move(scalar_outputs));
[5464]25}
26
[6184]27/** ------------------------------------------------------------------------------------------------------------- *
28 * @brief CreateStreamSet
29 ** ------------------------------------------------------------------------------------------------------------- */
30StreamSet * BaseDriver::CreateStreamSet(const unsigned NumElements, const unsigned FieldWidth) {
31    RelationshipAllocator A(mAllocator);
32    return new (A) StreamSet(getContext(), NumElements, FieldWidth);
33}
34
35/** ------------------------------------------------------------------------------------------------------------- *
36 * @brief CreateConstant
37 ** ------------------------------------------------------------------------------------------------------------- */
38Scalar * BaseDriver::CreateScalar(llvm::Type * scalarType) {
39    RelationshipAllocator A(mAllocator);
40    return new (A) Scalar(scalarType);
41}
42
43/** ------------------------------------------------------------------------------------------------------------- *
44 * @brief CreateConstant
45 ** ------------------------------------------------------------------------------------------------------------- */
46Scalar * BaseDriver::CreateConstant(llvm::Constant * const value) {
47    RelationshipAllocator A(mAllocator);
48    return new (A) ScalarConstant(value);
49}
50
51/** ------------------------------------------------------------------------------------------------------------- *
52 * @brief makeCache
53 ** ------------------------------------------------------------------------------------------------------------- */
54void BaseDriver::addKernel(Kernel * const kernel) {
[6288]55    kernel->initializeBindings(*this);
[6209]56    if (ParabixObjectCache::checkForCachedKernel(iBuilder, kernel)) {
[6184]57        assert (kernel->getModule());
58        mCachedKernel.emplace_back(kernel);
59    } else {
60        if (kernel->getModule() == nullptr) {
61            kernel->makeModule(iBuilder);
62        }
63        mUncachedKernel.emplace_back(kernel);
[5544]64    }
[5620]65}
[5998]66
[6184]67/** ------------------------------------------------------------------------------------------------------------- *
68 * @brief constructor
69 ** ------------------------------------------------------------------------------------------------------------- */
70BaseDriver::BaseDriver(std::string && moduleName)
71: mContext(new llvm::LLVMContext())
72, mMainModule(new llvm::Module(moduleName, *mContext))
73, iBuilder(nullptr) {
[6209]74    ParabixObjectCache::initializeCacheSystems();
[6184]75}
76
77/** ------------------------------------------------------------------------------------------------------------- *
78 * @brief deconstructor
79 ** ------------------------------------------------------------------------------------------------------------- */
80BaseDriver::~BaseDriver() {
81
82}
Note: See TracBrowser for help on using the repository browser.