Ignore:
Timestamp:
Nov 6, 2016, 8:37:11 PM (3 years ago)
Author:
nmedfort
Message:

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

File:
1 edited

Legend:

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

    r5177 r5202  
    162162}
    163163
    164 Function * editdPipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
    165     Type * mBitBlockType = iBuilder->getBitBlockType();
    166    
    167     ExternalFileBuffer ChStream(iBuilder, StreamSetType(4, i1));
    168     SingleBlockBuffer MatchResults(iBuilder, StreamSetType(editDistance+1, i1));
     164Function * editdPipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, PabloFunction * function) {
     165   
     166    ExternalFileBuffer ChStream(iBuilder, StreamSetType(iBuilder, 4, i1));
     167    SingleBlockBuffer MatchResults(iBuilder, StreamSetType(iBuilder, editDistance + 1, i1));
    169168
    170169    pablo_function_passes(function);
    171     pablo::PabloKernel  editdk(iBuilder, "editd", function, {});
     170    PabloKernel editdk(iBuilder, "editd", function);
    172171    kernel::editdScanKernel editdScanK(iBuilder, editDistance);
    173172   
     
    180179    Type * const size_ty = iBuilder->getSizeTy();
    181180    Type * const voidTy = Type::getVoidTy(mMod->getContext());
    182     Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
     181    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(iBuilder->getBitBlockType(), 8), 1), 0);
    183182   
    184183    Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", voidTy, inputType, size_ty, nullptr));
     
    210209}
    211210
    212 Function * preprocessPipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
     211Function * preprocessPipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, PabloFunction * function) {
    213212    Type * mBitBlockType = iBuilder->getBitBlockType();
    214213   
    215     ExternalFileBuffer ByteStream(iBuilder, StreamSetType(1, i8));
    216     SingleBlockBuffer BasisBits(iBuilder, StreamSetType(8, i1));
    217     ExternalFileBuffer CCResults(iBuilder, StreamSetType(4, i1));
     214    ExternalFileBuffer ByteStream(iBuilder, StreamSetType(iBuilder,1, i8));
     215    SingleBlockBuffer BasisBits(iBuilder, StreamSetType(iBuilder,8, i1));
     216    ExternalFileBuffer CCResults(iBuilder, StreamSetType(iBuilder,4, i1));
    218217
    219218    s2pKernel  s2pk(iBuilder);
     
    221220
    222221    pablo_function_passes(function);
    223     pablo::PabloKernel  ccck(iBuilder, "ccc", function, {});
     222    PabloKernel  ccck(iBuilder, "ccc", function);
    224223   
    225224    std::unique_ptr<Module> cccM = ccck.createKernelModule({&BasisBits}, {&CCResults});
     
    274273    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    275274
    276     PabloFunction * function = PabloFunction::Create("preprocess", 8, 4);
     275    PabloFunction * function = PabloFunction::Create("preprocess"); // , 8, 4
    277276    cc::CC_Compiler ccc(*function);
    278     pablo::PabloBuilder pBuilder(ccc.getBuilder().getPabloBlock(), ccc.getBuilder());
    279 
    280     pablo::PabloAST * A = ccc.compileCC(re::makeCC(re::makeCC(0x41), re::makeCC(0x61)));
    281     pablo::PabloAST * C = ccc.compileCC(re::makeCC(re::makeCC(0x43), re::makeCC(0x63)));
    282     pablo::PabloAST * T = ccc.compileCC(re::makeCC(re::makeCC(0x54), re::makeCC(0x74)));
    283     pablo::PabloAST * G = ccc.compileCC(re::makeCC(re::makeCC(0x47), re::makeCC(0x67)));
    284 
    285     function->setResult(0, pBuilder.createAssign("A", A));
    286     function->setResult(1, pBuilder.createAssign("C", C));
    287     function->setResult(2, pBuilder.createAssign("T", T));
    288     function->setResult(3, pBuilder.createAssign("G", G));
     277    PabloBuilder & pb = ccc.getBuilder();
     278
     279    PabloAST * A = ccc.compileCC(re::makeCC(re::makeCC(0x41), re::makeCC(0x61)), pb);
     280    PabloAST * C = ccc.compileCC(re::makeCC(re::makeCC(0x43), re::makeCC(0x63)), pb);
     281    PabloAST * T = ccc.compileCC(re::makeCC(re::makeCC(0x54), re::makeCC(0x74)), pb);
     282    PabloAST * G = ccc.compileCC(re::makeCC(re::makeCC(0x47), re::makeCC(0x67)), pb);
     283
     284    Var * pat = function->addResult("pat", getStreamTy(1, 4));
     285
     286    pb.createAssign(pb.createExtract(pat, 0), A);
     287    pb.createAssign(pb.createExtract(pat, 1), C);
     288    pb.createAssign(pb.createExtract(pat, 2), T);
     289    pb.createAssign(pb.createExtract(pat, 3), G);
    289290
    290291    llvm::Function * main_IR = preprocessPipeline(M, idb, function);
     
    307308    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    308309
    309     PabloFunction * function = PabloFunction::Create("editd", 4, editDistance+1);
    310     pablo::PabloBuilder main (function->getEntryBlock());
    311 
    312     const PabloType * streamType = getPabloType(PabloType::Stream, 1);
    313 
    314     std::vector<pablo::Var *>   basisBits(4);
    315     function->setParameter(0, basisBits[0] = main.createVar("PatA", streamType));
    316     function->setParameter(1, basisBits[1] = main.createVar("PatC", streamType));
    317     function->setParameter(2, basisBits[2] = main.createVar("PatT", streamType));
    318     function->setParameter(3, basisBits[3] = main.createVar("PatG", streamType));
     310    PabloFunction * function = PabloFunction::Create("editd"); // , 4, editDistance + 1
     311    PabloBuilder main (function->getEntryBlock());
     312
     313    Var * pat = function->addParameter("pat", getStreamTy(1, 4));
     314
     315    PabloAST * basisBits[4];
     316
     317    basisBits[0] = main.createExtract(pat, 0, "A");
     318    basisBits[1] = main.createExtract(pat, 1, "C");
     319    basisBits[2] = main.createExtract(pat, 2, "T");
     320    basisBits[3] = main.createExtract(pat, 3, "G");
    319321
    320322    re::Pattern_Compiler pattern_compiler(*function);
Note: See TracChangeset for help on using the changeset viewer.