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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    {
Note: See TracChangeset for help on using the changeset viewer.