Changeset 4904


Ignore:
Timestamp:
Dec 30, 2015, 9:21:06 AM (3 years ago)
Author:
cameron
Message:

Refactoring progress towards layered kernels

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

Legend:

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

    r4900 r4904  
    5656//
    5757
     58
     59void GrepExecutor::write_matched_line(llvm::raw_ostream & out, const char * buffer, ssize_t line_start, ssize_t line_end) {
     60    if (mShowFileNameOption) {
     61        out << mFileName << ':';
     62    }
     63    if (mShowLineNumberingOption) {
     64        out << mLineNum << ":";
     65    }
     66    if ((buffer[line_start] == 0xA) && (line_start != line_end)) {
     67        // The line "starts" on the LF of a CRLF.  Really the end of the last line.
     68        line_start++;
     69    }
     70    if (buffer + line_end == mFileBuffer + mFileSize) {
     71        // The match position is at end-of-file.   We have a final unterminated line.
     72        out.write(&buffer[line_start], line_end - line_start);
     73        if (mNormalizeLineBreaksOption) {
     74            out << '\n';  // terminate it
     75        }
     76        return;
     77    }
     78    unsigned char end_byte = (unsigned char)buffer[line_end];
     79    if (mNormalizeLineBreaksOption) {
     80        if (end_byte == 0x85) {
     81            // Line terminated with NEL, on the second byte.  Back up 1.
     82            line_end--;
     83        } else if (end_byte > 0xD) {
     84            // Line terminated with PS or LS, on the third byte.  Back up 2.
     85            line_end -= 2;
     86        }
     87        out.write(&buffer[line_start], line_end - line_start);
     88        out << '\n';
     89    }
     90    else {
     91        if (end_byte == 0x0D) {
     92            // Check for line_end on first byte of CRLF;  note that we don't
     93            // want to access past the end of buffer.
     94            if ((buffer + line_end + 1 < mFileBuffer + mFileSize) && (buffer[line_end + 1] == 0x0A)) {
     95                // Found CRLF; preserve both bytes.
     96                line_end++;
     97            }
     98        }
     99        out.write(&buffer[line_start], line_end - line_start + 1);
     100    }
     101   
     102}
     103
    58104ssize_t GrepExecutor::write_matches(llvm::raw_ostream & out, const char * buffer, ssize_t line_start) {
    59105
     
    71117            mLineNum++;
    72118        }
    73         if (mShowFileNameOption) {
    74             out << mFileName << ':';
    75         }
    76         if (mShowLineNumberingOption) {
    77             out << mLineNum << ":";
    78         }
    79         if ((buffer[line_start] == 0xA) && (line_start != line_end)) {
    80             // The line "starts" on the LF of a CRLF.  Really the end of the last line.
    81             line_start++;
    82         }
    83         if (buffer + line_end == mFileBuffer + mFileSize) {
    84             // The match position is at end-of-file.   We have a final unterminated line.
    85             out.write(&buffer[line_start], line_end - line_start);
    86             if (mNormalizeLineBreaksOption) {
    87               out << '\n';  // terminate it
    88             }
    89             return line_end;
    90         }
    91         unsigned char end_byte = (unsigned char)buffer[line_end];
    92         if (mNormalizeLineBreaksOption) {
    93             if (end_byte == 0x85) {
    94                 // Line terminated with NEL, on the second byte.  Back up 1.
    95                 line_end--;
    96             } else if (end_byte > 0xD) {
    97                 // Line terminated with PS or LS, on the third byte.  Back up 2.
    98                 line_end -= 2;
    99             }
    100             out.write(&buffer[line_start], line_end - line_start);
    101             out << '\n';
    102         }
    103         else {
    104             if (end_byte == 0x0D) {
    105                 // Check for line_end on first byte of CRLF;  note that we don't
    106                 // want to access past the end of buffer.
    107                 if ((buffer + line_end + 1 < mFileBuffer + mFileSize) && (buffer[line_end + 1] == 0x0A)) {
    108                     // Found CRLF; preserve both bytes.
    109                     line_end++;
    110                 }
    111             }
    112             out.write(&buffer[line_start], line_end - line_start + 1);
    113         }
     119        write_matched_line(out,buffer, line_start, line_end);
    114120        line_start = line_end + 1;
    115121        mLineNum++;
  • icGREP/icgrep-devel/icgrep/do_grep.h

    r4900 r4904  
    8383    re::CC * getParsedCodepoints() { return mParsedCodePointSet;}
    8484private:
     85    void write_matched_line(llvm::raw_ostream & out, const char * buffer, ssize_t line_start, ssize_t line_end);
     86
    8587    ssize_t write_matches(llvm::raw_ostream & out, const char *buffer, ssize_t first_line_start);
    8688   
  • icGREP/icgrep-devel/icgrep/include/simd-lib/bitblock256.hpp

    r4151 r4904  
    7474  return carryout;
    7575}
     76
     77#ifndef AVX2
     78#define _mm256_cvtepu16_epi64(x) _mm256_castps128_ps256((__m128) (x))
     79#endif
    7680
    7781static IDISA_ALWAYS_INLINE void add_ci_co(bitblock256_t x, bitblock256_t y, carry_t carry_in, carry_t & carry_out, bitblock256_t & sum) {
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4900 r4904  
    2222#include "utf_encoding.h"
    2323#include <llvm/IR/Type.h>
     24#include <IDISA/s2p_gen.h>
    2425#include <pablo/pablo_compiler.h>
    2526#include <do_grep.h>
     
    536537    Module * M = new Module("NamePattern", getGlobalContext());
    537538    IDISA::IDISA_Builder * idb = GetNativeIDISA_Builder(M, VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     539    gen_s2p_function(M, idb);
     540
    538541    pablo::PabloCompiler pablo_compiler(M, idb);
     542
    539543    llvm::Function * const nameSearchIR = pablo_compiler.compile(nameSearchFunction); // <- may throw error if parsing exception occurs.
     544    llvm::Function * s2p_IR = M->getFunction("s2p_block");
    540545
    541546    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(M);   
     
    545550    engine->finalizeObject();
    546551       
    547     void * icgrep_MCptr = engine->getPointerToFunction(nameSearchIR);   
     552    void * icgrep_MCptr = engine->getPointerToFunction(nameSearchIR);
     553    void * s2p_MCptr = engine->getPointerToFunction(s2p_IR);
     554
    548555    CC * codepoints = nullptr;
    549556    if (icgrep_MCptr) {
    550557        void * icgrep_init_carry_ptr = engine->getPointerToFunction(nameSearchIR->getParent()->getFunction("process_block_initialize_carries"));
    551         GrepExecutor grepEngine(icgrep_init_carry_ptr, icgrep_MCptr);
     558        GrepExecutor grepEngine(s2p_MCptr, icgrep_init_carry_ptr, icgrep_MCptr);
    552559        grepEngine.setParseCodepointsOption();
    553560        grepEngine.doGrep("../Uname.txt");
Note: See TracChangeset for help on using the changeset viewer.