Changeset 3940


Ignore:
Timestamp:
Jul 31, 2014, 9:11:28 PM (5 years ago)
Author:
daled
Message:

The framework for the unicode categories is in place. The static c++ code for each of the categories just needs to be placed into the stub unicode categories class.

Location:
icGREP/icgrep-devel/icgrep
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r3916 r3940  
    3838
    3939 
    40 add_library(PabloADT pe_advance.cpp  pe_all.cpp  pe_and.cpp pe_charclass.cpp  pe_matchstar.cpp  pe_not.cpp  pe_or.cpp  pe_pabloe.cpp  pe_sel.cpp  pe_var.cpp  pe_xor.cpp ps_assign.cpp  ps_if.cpp  ps_pablos.cpp  ps_while.cpp printer_pablos.cpp)
     40add_library(PabloADT pe_advance.cpp  pe_all.cpp  pe_and.cpp pe_call.cpp pe_charclass.cpp  pe_matchstar.cpp  pe_not.cpp  pe_or.cpp  pe_pabloe.cpp  pe_sel.cpp  pe_var.cpp  pe_xor.cpp ps_assign.cpp  ps_if.cpp  ps_pablos.cpp  ps_while.cpp printer_pablos.cpp)
    4141
    4242add_library(RegExpADT re_alt.cpp  re_cc.cpp  re_end.cpp  re_name.cpp re_parser.cpp  re_re.cpp  re_rep.cpp  re_seq.cpp  re_start.cpp parsefailure.cpp  parseresult.cpp  parsesuccess.cpp printer_re.cpp)
     
    5050 
    5151# add the executable
    52 add_executable(icgrep icgrep.cpp llvm_gen.cpp  llvm_gen_helper.cpp utf_encoding.cpp cc_codegenobject.cpp  cc_compiler.cpp  cc_compiler_helper.cpp re_simplifier.cpp re_reducer.cpp re_nullable.cpp re_compiler.cpp pbix_compiler.cpp  symbol_generator.cpp utf8_encoder.cpp)
     52add_executable(icgrep icgrep.cpp llvm_gen.cpp  llvm_gen_helper.cpp utf_encoding.cpp unicode_categories.cpp cc_codegenobject.cpp  cc_compiler.cpp  cc_compiler_helper.cpp re_simplifier.cpp re_reducer.cpp re_nullable.cpp re_compiler.cpp pbix_compiler.cpp  symbol_generator.cpp utf8_encoder.cpp)
    5353
    5454target_link_libraries (icgrep PabloADT RegExpADT ${REQ_LLVM_LIBRARIES})
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r3914 r3940  
    3030#include <simd-lib/buffer.hpp>
    3131#include <simd-lib/bitblock_iterator.hpp>
    32 //#include <simd-lib/perflib/perfsec.h>
    3332
    3433#define SEGMENT_BLOCKS 15
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r3935 r3940  
    1212      print_register<BitBlock>("", bit_block);
    1313  }
     14}
     15
     16extern "C" {
     17    BitBlock wrapped_get_unicode_category(const char* name){
     18        return Unicode_Categories::getCategory(name);
     19    }
     20}
     21
     22BitBlock LLVM_Generator::Get_UnicodeCategory(const char *name)
     23{
     24    return Unicode_Categories::getCategory(name);
    1425}
    1526
     
    8192
    8293    //Generate the IR instructions for the function.
     94
    8395    Generate_PabloStatements(cc_cgo_stmtsl);
    8496    Generate_PabloStatements(cg_state.stmtsl);
     
    129141    //The BitBlock vector.
    130142    m64x2Vect = VectorType::get(IntegerType::get(mMod->getContext(), 64), 2);
     143    m128x1Vect = VectorType::get(IntegerType::get(mMod->getContext(), 128), 1);
    131144    //A pointer to the BitBlock vector.
    132145    m64x2Vect_Ptr1 = PointerType::get(m64x2Vect, 0);
     
    187200void LLVM_Generator::DeclareFunctions()
    188201{
     202    mFunc_get_unicode_category = mMod->getOrInsertFunction("wrapped_get_unicode_category", m64x2Vect, Type::getInt8PtrTy(mMod->getContext()), NULL);
     203    mExecutionEngine->addGlobalMapping(cast<GlobalValue>(mFunc_get_unicode_category), (void *)&wrapped_get_unicode_category);
     204
    189205    //This function can be used for testing to print the contents of a register from JIT'd code to the terminal window.
    190     mFunc_print_register = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(getGlobalContext()), m64x2Vect, NULL);
    191     mExecutionEngine->addGlobalMapping(cast<GlobalValue>(mFunc_print_register), (void *)&wrapped_print_register);
     206    //mFunc_print_register = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(getGlobalContext()), m64x2Vect, NULL);
     207
     208    //mExecutionEngine->addGlobalMapping(cast<GlobalValue>(mFunc_print_register), (void *)&wrapped_print_register);
     209    // to call->  b.CreateCall(mFunc_print_register, unicode_category);
    192210
    193211    SmallVector<AttributeSet, 4> Attrs;
     
    386404        retVal = all_value;
    387405    }
     406    else if (Call* call = dynamic_cast<Call*>(expr))
     407    {
     408        IRBuilder<> b(mBasicBlock);
     409
     410        //Call the callee once and then store the result in the marker map.
     411        if (mMarkerMap.find(call->getCallee()) == mMarkerMap.end())
     412        {
     413            Value* unicode_category = b.CreateCall(mFunc_get_unicode_category, b.CreateGlobalStringPtr(call->getCallee()));
     414            Value* ptr = b.CreateAlloca(m64x2Vect);
     415            Value* void_1 = b.CreateStore(unicode_category, ptr);
     416
     417            mMarkerMap.insert(make_pair(call->getCallee(), ptr));
     418        }
     419        std::map<std::string, Value*>::iterator itGet = mMarkerMap.find(call->getCallee());
     420        Value * var_value = b.CreateLoad(itGet->second);
     421
     422        retVal = var_value;
     423    }
    388424    else if (Var* var = dynamic_cast<Var*>(expr))
    389425    {
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r3935 r3940  
    2828#include "pe_not.h"
    2929#include "pe_or.h"
     30#include "pe_call.h"
    3031#include "pe_var.h"
    3132#include "pe_xor.h"
     
    4142
    4243#include "llvm_gen_helper.h"
     44
     45#include "unicode_categories.h"
    4346
    4447#include <iostream>
     
    103106                                    std::list<PabloS*> cc_cgo);
    104107    void Print_Register(char* name, BitBlock bit_block);
     108    BitBlock Get_UnicodeCategory(const char* name);
    105109private:
    106110    void MakeLLVMModule();
     
    108112    void DeclareFunctions();
    109113    void StoreBitBlockMarkerPtr(std::string name, int index);
     114    void LoadBitBlocksFromStaticExtern();
    110115    void SetReturnMarker(std::string marker, int output_idx);
    111116    Value* GetMarker(std::string name);
     
    125130    VectorType*  m64x2Vect;
    126131    PointerType* m64x2Vect_Ptr1;
     132
     133    VectorType* m128x1Vect;
    127134
    128135    PointerType* mStruct_Basis_Bits_Ptr1;
     
    144151
    145152    Constant*     mFunc_print_register;
     153    Constant*     mFunc_test_getCategory;
     154    Constant*     mFunc_get_unicode_category;
    146155
    147156    AllocaInst*  mPtr_basis_bits_addr;
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r3914 r3940  
    3737    {
    3838        std::string gs_retVal = symgen.gensym("marker");
    39         cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), new CharClass(name->getName())))));
     39
     40        PabloE* expr;
     41        if (name->getType() == Name::UnicodeCategory)
     42            expr = new Call(name->getName());
     43        else
     44            expr =  new CharClass(name->getName());
     45
     46        cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), expr))));
    4047        cg_state.newsym = gs_retVal;
    4148
  • icGREP/icgrep-devel/icgrep/pbix_compiler.h

    r3914 r3940  
    2424#include "pe_and.h"
    2525#include "pe_charclass.h"
     26#include "pe_call.h"
    2627#include "pe_matchstar.h"
    2728#include "pe_not.h"
  • icGREP/icgrep-devel/icgrep/printer_pablos.cpp

    r3914 r3940  
    7676        retVal = "All " + INT2STRING(all->getNum()) + " ";
    7777    }
     78    else if (Call* pablo_call = dynamic_cast<Call*>(expr))
     79    {
     80        retVal = "Call '" + pablo_call->getCallee() + "'";
     81    }
    7882    else if (Var* pablo_var = dynamic_cast<Var*>(expr))
    7983    {
  • icGREP/icgrep-devel/icgrep/re_compiler.cpp

    r3935 r3940  
    3636
    3737    //Print to the terminal the AST that was generated by the parser before adding the UTF encoding:
    38     std::cout << "\nParser:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
     38    //std::cout << "\nParser:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
    3939
    4040    //Add the UTF encoding.
     
    5353
    5454    //Print to the terminal the AST that was generated by the utf8 encoder.
    55     std::cout << "\nUTF8-encoder:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
     55    //std::cout << "\nUTF8-encoder:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
    5656
    5757    //Optimization passes to simplify the AST.
     
    5959
    6060    //Print to the terminal the AST that was generated by the simplifier.
    61     std::cout << "\nSimplifier:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
     61    //std::cout << "\nSimplifier:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
    6262
    6363    //Map all of the unique character classes in order to reduce redundancy.
     
    6666
    6767    //Print to the terminal the AST with the reduced REs.
    68     std::cout << "\nReducer:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
     68    //std::cout << "\nReducer:\n" + Printer_RE::PrintRE(re_ast) + "\n" << std::endl;
    6969
    7070    //Build our list of predefined characters.
  • icGREP/icgrep-devel/icgrep/re_name.cpp

    r3935 r3940  
    44{
    55    mName = "";
     6    mType = Name::FixedLength;
    67}
    78
     
    910{
    1011    mName = name;
     12    mType = Name::FixedLength;
    1113}
    1214
     
    2224    return mName;
    2325}
     26
     27void Name::setType(Name::Type type)
     28{
     29    mType = type;
     30}
     31
     32Name::Type Name::getType()
     33{
     34    return mType;
     35}
     36
     37
  • icGREP/icgrep-devel/icgrep/re_name.h

    r3935 r3940  
    99{
    1010public:
     11    typedef enum {FixedLength,Unicode,UnicodeCategory} Type;
    1112    Name();
    1213    Name(std::string name);
    1314    void setName(std::string name);
    1415    std::string getName();
     16    void setType(Type type);
     17    Type getType();
    1518    ~Name();
    1619private:
    1720    std::string mName;
     21    Type mType;
    1822};
    1923
  • icGREP/icgrep-devel/icgrep/re_parser.cpp

    r3935 r3940  
    452452    {
    453453        Name* name = new Name();
     454        name->setType(Name::UnicodeCategory);
    454455        result_retVal = parse_unicode_category1(s.substr(1,1), s.substr(2, s.length() - 2), name);
    455456    }
  • icGREP/icgrep-devel/icgrep/re_reducer.cpp

    r3935 r3940  
    5656    else if (Name* re_name = dynamic_cast<Name*>(re))
    5757    {
    58         retVal = new Name(re_name->getName());
     58        Name* name = new Name(re_name->getName());
     59        name->setType(re_name->getType());
     60        retVal = name;
    5961    }
    6062    else if (Start* re_start = dynamic_cast<Start*>(re))
  • icGREP/icgrep-devel/icgrep/re_simplifier.cpp

    r3935 r3940  
    11#include "re_simplifier.h"
    2 
    32
    43RE* RE_Simplifier::simplify(RE* re)
     
    3635    else if (Name* re_name = dynamic_cast<Name*>(re))
    3736    {
    38         retVal = new Name(re_name->getName());
     37        Name* name = new Name(re_name->getName());
     38        name->setType(re_name->getType());
     39        retVal = name;
    3940    }
    4041    else if (Rep* re_rep = dynamic_cast<Rep*>(re))
  • icGREP/icgrep-devel/icgrep/utf8_encoder.cpp

    r3935 r3940  
    7474    else if (Name* re_name = dynamic_cast<Name*>(re))
    7575    {
    76         retVal = new Name(re_name->getName());
     76        Name* name = new Name(re_name->getName());
     77        name->setType(re_name->getType());
     78        retVal = name;
    7779    }
    7880    else if (Start* re_start = dynamic_cast<Start*>(re))
Note: See TracChangeset for help on using the changeset viewer.