source: icGREP/icgrep-devel/icgrep/IDISA/types/streamtype.cpp @ 5217

Last change on this file since 5217 was 5217, checked in by nmedfort, 2 years ago

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

File size: 1.0 KB
Line 
1#include "streamtype.h"
2#include <boost/container/flat_map.hpp>
3#include <IDISA/idisa_builder.h>
4
5using namespace boost::container;
6using namespace llvm;
7
8namespace IDISA {
9
10static flat_map<std::pair<unsigned, unsigned>, StreamType *> STREAM_TYPES;
11
12StreamType * StreamType::get(llvm::LLVMContext & ctx, unsigned NumElements, unsigned FieldWidth) {
13    const auto f = STREAM_TYPES.find(std::make_pair(NumElements, FieldWidth));
14    if (LLVM_LIKELY(f != STREAM_TYPES.end())) {
15        return f->second;
16    } else {
17        StreamType * const T = new StreamType(ctx, NumElements, FieldWidth);
18        STREAM_TYPES.emplace(std::make_pair(NumElements, FieldWidth), T);
19        return T;
20    }
21}
22
23llvm::Type * StreamType::resolveType(IDISA::IDISA_Builder * const iBuilder) {
24    return ArrayType::get(iBuilder->getBitBlockType(), mNumElements);
25}
26
27StreamType::StreamType(llvm::LLVMContext & C, unsigned NumElements, unsigned FieldWidth)
28: llvm::Type(C, (Type::TypeID)(StreamTyId))
29, mNumElements(NumElements)
30, mFieldWidth(FieldWidth) {
31
32}
33
34
35
36}
37
Note: See TracBrowser for help on using the repository browser.