source: icGREP/icgrep-devel/icgrep/kernels/streamset.h @ 5098

Last change on this file since 5098 was 5085, checked in by cameron, 3 years ago

Enforce power-of-2 segment size, add getters

File size: 1.6 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 STREAMSET_H
7#define STREAMSET_H
8
9#include <string>
10#include <vector>
11#include <IDISA/idisa_builder.h>
12#include <llvm/IR/Type.h>
13   
14namespace kernel {
15
16class StreamSetType {
17public:
18    StreamSetType(int count, int width) : mStreamCount(count), mFieldWidth(width) {}
19    int StreamCount() { return mStreamCount;}
20    int StreamFieldWidth() { return mFieldWidth;}
21   
22    llvm::Type * getStreamSetBlockType(IDISA::IDISA_Builder * iBuilder);
23   
24private:
25    int mStreamCount;
26    int mFieldWidth;
27};
28
29class StreamSetBuffer {
30public:
31    StreamSetBuffer(IDISA::IDISA_Builder * b, StreamSetType ss_type, unsigned SegmentSize) :
32    iBuilder(b), mStreamSetType(ss_type), mSegmentSize(SegmentSize), mStreamSetBufferPtr(nullptr) {
33        if (((SegmentSize - 1) & SegmentSize) != 0) {
34            throw std::runtime_error("Segment size must be a power of 2!");
35        }
36    }
37
38    llvm::Type * getStreamSetBlockType();
39   
40    llvm::Type * getStreamSetBufferType();
41   
42    void setStreamSetBuffer(llvm::Value * ptr) {mStreamSetBufferPtr = ptr;}
43   
44    llvm::Value * allocateBuffer();
45   
46    llvm::Value * getStreamSetBufferPtr() {return mStreamSetBufferPtr;}
47   
48    unsigned getSegmentSize() { return mSegmentSize; }
49
50    llvm::Value * getBlockPointer(llvm::Value * blockNo);
51   
52private:
53    IDISA::IDISA_Builder * iBuilder;
54    StreamSetType mStreamSetType;
55    unsigned mSegmentSize;
56    llvm::Value * mStreamSetBufferPtr;
57   
58
59};
60}
61#endif // STREAMSET_H
Note: See TracBrowser for help on using the repository browser.