source: icGREP/icgrep-devel/icgrep/kernels/UCD_property_kernel.cpp @ 6184

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

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 1.5 KB
Line 
1/*
2 *  Copyright (c) 2018 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6#include "UCD_property_kernel.h"
7#include <re/re_toolchain.h>
8#include <re/re_name.h>
9#include <cc/cc_compiler.h>
10#include <UCD/ucd_compiler.hpp>
11#include <pablo/pablo_toolchain.h>
12#include <kernels/kernel_builder.h>
13#include <pablo/builder.hpp>
14#include <llvm/Support/ErrorHandling.h>
15
16using namespace kernel;
17using namespace pablo;
18
19
20UnicodePropertyKernelBuilder::UnicodePropertyKernelBuilder(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::Name * property_value_name, StreamSet *BasisBits, StreamSet * property)
21: PabloKernel(iBuilder,
22"UCD:" + property_value_name->getFullName(),
23{Binding{"basis", BasisBits}},
24{Binding{"property_stream", property}}),
25  mName(property_value_name) {
26
27}
28
29void UnicodePropertyKernelBuilder::generatePabloMethod() {
30    PabloBuilder pb(getEntryScope());
31    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
32    UCD::UCDCompiler ucdCompiler(ccc);
33    UCD::UCDCompiler::NameMap nameMap;
34    nameMap.emplace(mName, nullptr);
35    ucdCompiler.generateWithDefaultIfHierarchy(nameMap, pb);
36    auto f = nameMap.find(mName);
37    if (f == nameMap.end()) llvm::report_fatal_error("Unknown property");
38    PabloAST * theStream = f-> second;
39    Var * const property_stream = getOutputStreamVar("property_stream");
40    pb.createAssign(pb.createExtract(property_stream, pb.getInteger(0)), theStream);
41}
42
Note: See TracBrowser for help on using the repository browser.