source: icGREP/icgrep-devel/icgrep/kernels/interface.h @ 5063

Last change on this file since 5063 was 5060, checked in by cameron, 3 years ago

Kernel interface provides only those services used for building pipelines

File size: 2.3 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#ifndef KERNEL_INTERFACE_H
7#define KERNEL_INTERFACE_H
8
9
10#include <string>
11#include <vector>
12#include <llvm/IR/Type.h>
13#include <IDISA/idisa_builder.h>
14#include "streamset.h"
15
16struct ScalarBinding {
17    llvm::Type * scalarType;
18    std::string scalarName;
19};
20
21struct StreamSetBinding {
22    kernel::StreamSetType ssType;
23    std::string ssName;
24};
25   
26const std::string init_suffix = "_Init";
27const std::string doBlock_suffix = "_DoBlock";
28const std::string finalBlock_suffix = "_FinalBlock";
29const std::string accumulator_infix = "_get_";
30
31class KernelInterface {
32
33public:
34    KernelInterface(IDISA::IDISA_Builder * builder,
35                    std::string kernelName,
36                    std::vector<StreamSetBinding> stream_inputs,
37                    std::vector<StreamSetBinding> stream_outputs,
38                    std::vector<ScalarBinding> scalar_parameters,
39                    std::vector<ScalarBinding> scalar_outputs,
40                    std::vector<ScalarBinding> internal_scalars) :
41    iBuilder(builder),
42    mKernelName(kernelName),
43    mStreamSetInputs(stream_inputs),
44    mStreamSetOutputs(stream_outputs),
45    mScalarInputs(scalar_parameters),
46    mScalarOutputs(scalar_outputs),
47    mInternalScalars(internal_scalars),
48    mKernelStateType(nullptr) {}
49   
50   
51    // Add ExternalLinkage method declarations for the kernel to a given client module.
52    void addKernelDeclarations(Module * client);
53   
54    llvm::Value * createInstance(std::vector<llvm::Value *> initialParameters);
55    llvm::Value * createDoBlockCall(llvm::Value * kernelInstance, std::vector<Value *> streamSets);
56    llvm::Value * createFinalBlockCall(llvm::Value * kernelInstance, llvm::Value * remainingBytes, std::vector<llvm::Value *> streamSets);
57    llvm::Value * createGetAccumulatorCall(llvm::Value * kernelInstance, std::string accumName);
58   
59protected:
60   
61    IDISA::IDISA_Builder * iBuilder;
62    std::string mKernelName;
63    std::vector<StreamSetBinding> mStreamSetInputs;
64    std::vector<StreamSetBinding> mStreamSetOutputs;
65    std::vector<ScalarBinding> mScalarInputs;
66    std::vector<ScalarBinding> mScalarOutputs;
67    std::vector<ScalarBinding> mInternalScalars;
68    llvm::Type * mKernelStateType;
69};
70
71#endif
Note: See TracBrowser for help on using the repository browser.