source: icGREP/icgrep-devel/icgrep/pablo/type/streamtype.cpp @ 5202

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

Initial work on adding types to PabloAST and mutable Var objects.

File size: 943 bytes
Line 
1#include <pablo/type/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 pablo {
9
10static flat_map<uint64_t, StreamType *> STREAM_TYPES;
11
12StreamType * StreamType::get(llvm::LLVMContext & ctx, const uint64_t FieldWidth) {
13    const auto f = STREAM_TYPES.find(FieldWidth);
14    if (LLVM_LIKELY(f != STREAM_TYPES.end())) {
15        return f->second;
16    } else {
17        StreamType * const T = new StreamType(ctx, FieldWidth);
18        STREAM_TYPES.emplace(FieldWidth, T);
19        return T;
20    }
21}
22
23llvm::Type * StreamType::resolveType(IDISA::IDISA_Builder * const iBuilder) {
24    return mFieldWidth == 1 ? iBuilder->getBitBlockType() : ArrayType::get(iBuilder->getBitBlockType(), mFieldWidth);
25}
26
27StreamType::StreamType(llvm::LLVMContext & C, uint64_t FieldWidth)
28: llvm::Type(C, (Type::TypeID)(StreamTyId))
29, mFieldWidth(FieldWidth) {
30
31}
32
33
34
35}
36
Note: See TracBrowser for help on using the repository browser.