source: icGREP/icgrep-devel/icgrep/kernels/relationship.cpp @ 6297

Last change on this file since 6297 was 6184, checked in by nmedfort, 10 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 1.3 KB
Line 
1#include "relationship.h"
2#include <llvm/IR/Constant.h>
3#include <llvm/IR/DerivedTypes.h>
4
5using namespace llvm;
6
7namespace kernel {
8
9inline VectorType * LLVM_READNONE getStreamTy(LLVMContext & C, const unsigned FieldWidth) {
10    return VectorType::get(IntegerType::getIntNTy(C, FieldWidth), 0);
11}
12
13inline ArrayType * LLVM_READNONE getStreamSetTy(LLVMContext & C, const unsigned NumElements, const unsigned FieldWidth) {
14    return ArrayType::get(getStreamTy(C, FieldWidth), NumElements);
15}
16
17unsigned StreamSet::getNumElements() const {
18    return mType->getArrayNumElements();
19}
20
21unsigned StreamSet::getFieldWidth() const {
22    return mType->getArrayElementType()->getVectorElementType()->getIntegerBitWidth();
23}
24
25StreamSet::StreamSet(LLVMContext & C, const unsigned NumElements, const unsigned FieldWidth) noexcept
26: Relationship(Relationship::ClassTypeId::StreamSet, getStreamSetTy(C, NumElements, FieldWidth)) {
27
28}
29
30Scalar::Scalar(const ClassTypeId typeId, llvm::Type * type) noexcept
31: Relationship(typeId, type){
32
33}
34
35Scalar::Scalar(not_null<Type *> type) noexcept
36: Scalar(Relationship::ClassTypeId::Scalar, type.get()){
37
38}
39
40ScalarConstant::ScalarConstant(not_null<Constant *> constant) noexcept
41: Scalar(Relationship::ClassTypeId::ScalarConstant, constant->getType())
42, mConstant(constant.get()) {
43
44}
45
46}
Note: See TracBrowser for help on using the repository browser.