source: icGREP/icgrep-devel/icgrep/kernels/binding.h

Last change on this file was 6184, checked in by nmedfort, 9 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 2.8 KB
Line 
1#ifndef BINDING_H
2#define BINDING_H
3
4#include <kernels/processing_rate.h>
5#include <kernels/attributes.h>
6#include <llvm/ADT/STLExtras.h>
7
8namespace llvm { class Type; }
9namespace llvm { class raw_ostream; }
10
11namespace kernel {
12
13class Kernel;
14class Relationship;
15
16struct Binding : public AttributeSet {
17
18    friend class Kernel;
19    friend class PipelineBuilder;
20    friend class PipelineKernel;
21
22    // TODO: use templatized var-args to simplify the constructors? would need to default in the processing rate and verify only one was added.
23
24    Binding(std::string name, Relationship * const value, ProcessingRate r = FixedRate(1));
25    Binding(std::string name, Relationship * const value, ProcessingRate r, Attribute && attribute);
26    Binding(std::string name, Relationship * const value, ProcessingRate r, std::initializer_list<Attribute> attributes);
27
28    Binding(llvm::Type * const scalarType, std::string name, ProcessingRate r = FixedRate(1));
29    Binding(llvm::Type * const scalarType, std::string name, ProcessingRate r, Attribute && attribute);
30    Binding(llvm::Type * const scalarType, std::string name, ProcessingRate r, std::initializer_list<Attribute> attributes);
31
32    Binding(llvm::Type * const scalarType, std::string name, Relationship * const value, ProcessingRate r = FixedRate(1));
33    Binding(llvm::Type * const scalarType, std::string name, Relationship * const value, ProcessingRate r, Attribute && attribute);
34    Binding(llvm::Type * const scalarType, std::string name, Relationship * const value, ProcessingRate r, std::initializer_list<Attribute> attributes);
35
36    const std::string & getName() const LLVM_READNONE {
37        return mName;
38    }
39
40    const ProcessingRate & getRate() const LLVM_READNONE {
41        return mRate;
42    }
43
44    bool isPrincipal() const LLVM_READNONE {
45        return hasAttribute(AttributeId::Principal);
46    }
47
48    bool hasLookahead() const LLVM_READNONE {
49        return hasAttribute(AttributeId::LookAhead);
50    }
51
52    unsigned const getLookahead() const LLVM_READNONE {
53        return findAttribute(AttributeId::LookAhead).amount();
54    }
55
56    bool isDeferred() const LLVM_READNONE {
57        return hasAttribute(AttributeId::Deferred);
58    }
59
60    llvm::Type * getType() const {
61        return mType;
62    }
63
64    Relationship * getRelationship() const {
65        return mValue;
66    }
67
68    LLVM_READNONE unsigned getNumElements() const;
69
70    LLVM_READNONE unsigned getFieldWidth() const;
71
72protected:
73
74    void print(const Kernel * const kernel, llvm::raw_ostream & out) const noexcept;
75
76    void setRelationship(Relationship * const value);
77
78private:
79    const std::string       mName;
80    const ProcessingRate    mRate;
81    llvm::Type * const      mType;
82    Relationship *          mValue;
83};
84
85using Bindings = std::vector<Binding>;
86
87}
88
89#endif // BINDING_H
Note: See TracBrowser for help on using the repository browser.