Ignore:
Timestamp:
Jul 12, 2015, 3:52:43 PM (4 years ago)
Author:
nmedfort
Message:

Start of work to make the pablo compiler reenterant. Fixed bug that prevented it from using Less optimization level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/generate_predefined_ucd_functions.cpp

    r4657 r4661  
    99#include <fstream>
    1010
     11#include <cc/cc_compiler.h>
    1112#include <UCD/unicode_set.h>
     13#include <UCD/PropertyObjectTable.h>
    1214#include <UCD/ucd_compiler.hpp>
    1315#include <pablo/pablo_compiler.h>
     16#include <pablo/builder.hpp>
    1417#include <pablo/function.h>
    1518#include <llvm/Support/CommandLine.h>
     19#include <utf_encoding.h>
     20#include <pablo/optimizers/pablo_simplifier.hpp>
     21#include <pablo/optimizers/pablo_codesinking.hpp>
     22#include <pablo/optimizers/pablo_automultiplexing.hpp>
     23#include <llvm/ExecutionEngine/ExecutionEngine.h>
     24#include <boost/algorithm/string/case_conv.hpp>
     25
     26#include <iostream>
    1627
    1728using namespace pablo;
     29using namespace UCD;
     30using namespace cc;
     31
     32inline std::string lowercase(const std::string & name) {
     33    std::locale loc;
     34    return boost::algorithm::to_lower_copy(name, loc);
     35}
     36
     37ExecutionEngine * compile(std::string name, const UnicodeSet & set, PabloCompiler & pc, ExecutionEngine * engine) {
     38
     39    PabloFunction function = PabloFunction::Create(std::move(name));
     40    Encoding encoding(Encoding::Type::UTF_8, 8);
     41    CC_Compiler ccCompiler(function, encoding);
     42    UCDCompiler ucdCompiler(ccCompiler);
     43    PabloBuilder builder(function.getEntryBlock());
     44
     45    std::cerr << "Compiling " << name << std::endl;
     46
     47    // Build the unicode set function
     48    ucdCompiler.generateWithDefaultIfHierarchy(set, builder);
     49    // Optimize it at the pablo level
     50    Simplifier::optimize(function);
     51    CodeSinking::optimize(function);
     52    // AutoMultiplexing::optimize(function);
     53
     54
     55    if (engine) {
     56        engine->removeModule(pc.getModule());
     57    }
     58
     59    // Now compile the function ...
     60    return pc.compile(function).getExecutionEngine();
     61}
    1862
    1963int main(int argc, char *argv[]) {
    2064
    2165    PabloCompiler pc;
     66    ExecutionEngine * engine = nullptr;
    2267
    23     // Make the property generator create a for each loop that iterates through all properties
     68    for (PropertyObject * obj : property_object_table) {
    2469
     70        if (isa<UnsupportedPropertyObject>(obj)) continue;
    2571
     72        if (auto * enumObj = dyn_cast<EnumeratedPropertyObject>(obj)) {
     73            for (const std::string value : *enumObj) {
     74                const UnicodeSet & set = enumObj->GetCodepointSet(canonicalize_value_name(value));
     75                engine = compile("__get_" + property_enum_name[enumObj->getPropertyCode()] + "_" + value, set, pc, engine);
     76            }
     77            break;
     78        }
    2679
     80//        if (auto * extObj = dyn_cast<ExtensionPropertyObject>(obj)) {
     81//            for (const std::string value : *extObj) {
     82//                const UnicodeSet & set = extObj->GetCodepointSet(canonicalize_value_name(value));
     83//                engine = compile("__get_" + property_enum_name[extObj->getPropertyCode()] + "_" + value, set, pc, engine);
     84//            }
     85//        }
    2786
     87//        if (auto * binObj = dyn_cast<BinaryPropertyObject>(obj)) {
     88//            const UnicodeSet & set = binObj->GetCodepointSet(Binary_ns::Y);
     89//            compile("__get_" + property_enum_name[binObj->getPropertyCode()] + "_Y", set, pc);
     90//        }
     91    }
    2892
     93    pc.getModule()->dump();
    2994
    30 
    31 
    32 
    33 
    34 
    35 
     95    return 0;
    3696}
Note: See TracChangeset for help on using the changeset viewer.