Changeset 6215 for icGREP


Ignore:
Timestamp:
Dec 3, 2018, 4:23:14 PM (4 months ago)
Author:
cameron
Message:

pablo.terminateAt

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/builder.cpp

    r6202 r6215  
    1717#include <pablo/pe_var.h>
    1818#include <pablo/ps_assign.h>
     19#include <pablo/ps_terminate.h>
    1920#include <boost/preprocessor/variadic/elem.hpp>
    2021#include <type_traits>
     
    488489}
    489490
     491PabloAST * PabloBuilder::createTerminateAt(PabloAST * strm, not_null<Integer *> code) {
     492    if (isa<Zeroes>(strm)) return strm;
     493    return MAKE_BINARY(TerminateAt, strm, code.get());
     494}
     495
     496PabloAST * PabloBuilder::createTerminateAt(PabloAST * strm, not_null<Integer *> code, const llvm::StringRef & prefix) {
     497    if (isa<Zeroes>(strm)) return strm;
     498    return MAKE_NAMED_BINARY(TerminateAt, prefix, strm, code.get());
     499}
     500
    490501PabloAST * PabloBuilder::createMatchStar(PabloAST * marker, PabloAST * charclass) {
    491502    if (isa<Zeroes>(marker) || isa<Zeroes>(charclass)) {
     
    494505    return MAKE_BINARY(MatchStar, marker, charclass);
    495506}
    496 
     507   
    497508PabloAST * PabloBuilder::createMatchStar(PabloAST * marker, PabloAST * charclass, const llvm::StringRef & prefix) {
    498509    if (isa<Zeroes>(marker) || isa<Zeroes>(charclass)) {
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r6194 r6215  
    207207    PabloAST * createAtEOF(PabloAST * expr, const llvm::StringRef & prefix);
    208208   
     209    PabloAST * createTerminateAt(PabloAST * strm, not_null<Integer *> code);
     210   
     211    PabloAST * createTerminateAt(PabloAST * strm, not_null<Integer *> code, const llvm::StringRef & prefix);
     212   
     213    PabloAST * createTerminateAt(PabloAST * strm, int64_t code) {
     214        return createTerminateAt(strm, mPb->getInteger(code));
     215    }
     216   
     217    PabloAST * createTerminateAt(PabloAST * strm, int64_t code, const llvm::StringRef & prefix) {
     218        return createTerminateAt(strm, mPb->getInteger(code), prefix);
     219    }
     220   
    209221    PabloAST * createAdd(PabloAST * expr1, PabloAST * expr2);
    210222
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r6189 r6215  
    2424#include <pablo/pe_zeroes.h>
    2525#include <pablo/ps_assign.h>
     26#include <pablo/ps_terminate.h>
    2627#include <pablo/pablo_kernel.h>
    2728#include <IR_Gen/idisa_builder.h>
     
    7778    assert (expr);
    7879    return insertAtInsertionPoint(new (mAllocator) AtEOF(expr, name, mAllocator));
     80}
     81
     82TerminateAt * PabloBlock::createTerminateAt(PabloAST * strm, Integer *  code, const String * const name) {
     83    assert (strm); assert(code);
     84    return insertAtInsertionPoint(new (mAllocator) TerminateAt(strm, code, name, mAllocator));
    7985}
    8086
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5889 r6215  
    4343namespace pablo { class String; }
    4444namespace pablo { class Subtract; }
     45namespace pablo { class TerminateAt; }
    4546namespace pablo { class Var; }
    4647namespace pablo { class Xor; }
     
    140141        return createAtEOF(expr, makeName(prefix));
    141142    }
    142 
     143   
    143144    AtEOF * createAtEOF(PabloAST * expr, const String * const name = nullptr);
    144145
     146    TerminateAt * createTerminateAt(PabloAST * strm, Integer * code) {
     147        return createTerminateAt(strm, code, nullptr);
     148    }
     149   
     150    TerminateAt * createTerminateAt(PabloAST * strm, Integer * code, const llvm::StringRef & prefix) {
     151        return createTerminateAt(strm, code, makeName(prefix));
     152    }
     153   
     154    TerminateAt * createTerminateAt(PabloAST * strm, Integer * code, const String * const name);
     155   
    145156    Extract * createExtract(Var * array, Integer * index);
    146157
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r5836 r6215  
    175175            MAKE_PREFIX(InFile, "inFile");
    176176            MAKE_PREFIX(AtEOF, "atEOF");
     177            MAKE_PREFIX(TerminateAt, "terminateAt");
    177178            // Statistics operations
    178179            MAKE_PREFIX(Count, "count");
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r5836 r6215  
    8686        , InFile
    8787        , AtEOF
     88        , TerminateAt
    8889        // Statistics operations
    8990        , Count
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r6189 r6215  
    2626#include <pablo/pe_var.h>
    2727#include <pablo/ps_assign.h>
     28#include <pablo/ps_terminate.h>
    2829#ifdef USE_CARRYPACK_MANAGER
    2930#include <pablo/carrypack_manager.h>
     
    481482            Value * const sum = mCarryManager->addCarryInCarryOut(b, sthru, from, b->simd_or(from, b->simd_not(to)));
    482483            value = b->simd_and(sum, to);
     484        } else if (const TerminateAt * s = dyn_cast<TerminateAt>(stmt)) {
     485            Value * signal_strm = compileExpression(b, s->getExpr());
     486            llvm::errs() << "Here\n";
     487            b->CallPrintRegister("signal_strm", signal_strm);
     488            BasicBlock * signalCallBack = b->CreateBasicBlock("signalCallBack");
     489            BasicBlock * postSignal = b->CreateBasicBlock("postSignal");
     490            b->CreateCondBr(b->bitblock_any(signal_strm), signalCallBack, postSignal);
     491            b->SetInsertPoint(signalCallBack);
     492            // Perhaps check for handler address and skip call back if none???
     493            Value * handler = b->getScalarField("handler_address");
     494            Function * const dispatcher = b->getModule()->getFunction("signal_dispatcher"); assert (dispatcher);
     495            b->CreateCall(dispatcher, {handler, ConstantInt::get(b->getInt32Ty(), s->getSignalCode())});
     496            //Value * rel_position = b->createCountForwardZeroes(signal_strm);
     497            //Value * position = b->CreateAdd(b->getProcessedItemCount(), rel_position);
     498            b->setTerminationSignal();
     499            b->CreateBr(postSignal);
     500            b->SetInsertPoint(postSignal);
     501            value = signal_strm;
    483502        } else if (LLVM_UNLIKELY(isa<Assign>(stmt))) {
    484503            expr = cast<Assign>(stmt)->getVariable();
  • icGREP/icgrep-devel/icgrep/pablo/printer_pablos.cpp

    r5933 r6215  
    2525#include <pablo/pe_zeroes.h>
    2626#include <pablo/ps_assign.h>
     27#include <pablo/ps_terminate.h>
    2728#include <llvm/IR/Type.h>
    2829#include <llvm/IR/DerivedTypes.h>  // for get getSequentialElementType
     
    170171            print(e->getExpr(), out);
    171172            out << ")";
     173        } else if (const TerminateAt * s = dyn_cast<TerminateAt>(stmt)) {
     174            out << " = pablo.TerminateAt(";
     175            print(s->getExpr(), out);
     176            out << ", " << std::to_string(s->getSignalCode()) << ")";
    172177        } else {
    173178            out << "???";
Note: See TracChangeset for help on using the changeset viewer.