source: icGREP/icgrep-devel/icgrep/do_grep.h @ 4898

Last change on this file since 4898 was 4826, checked in by cameron, 4 years ago

Reset carries for each file

File size: 2.8 KB
RevLine 
[4324]1#ifndef DO_GREP_H
2#define DO_GREP_H
3/*
[4659]4 *  Copyright (c) 2015 International Characters.
[4324]5 *  This software is licensed to the public under the Open Software License 3.0.
6 *  icgrep is a trademark of International Characters.
7 */
8
9#include <string>
10#include <stdint.h>
[4803]11#include "basis_bits.h"
[4324]12#include "include/simd-lib/bitblock.hpp"
13#include "include/simd-lib/transpose.hpp"
[4325]14#include "include/simd-lib/bitblock_iterator.hpp"
[4802]15#include <re/re_cc.h>
[4324]16
17struct Output {
18    BitBlock matches;
19    BitBlock LF;
20};
21
[4325]22#if (BLOCK_SIZE == 128)
23#define SEGMENT_BLOCKS 7
24#endif
25
26#if (BLOCK_SIZE == 256)
27#define SEGMENT_BLOCKS 15
28#endif
29
30#define SEGMENT_SIZE (BLOCK_SIZE * SEGMENT_BLOCKS)
31
32
33#if (BLOCK_SIZE == 256)
34typedef BitStreamScanner<BitBlock, uint64_t, uint64_t, SEGMENT_BLOCKS> ScannerT;
35#endif
36
37#if (BLOCK_SIZE == 128)
38typedef BitStreamScanner<BitBlock, uint32_t, uint32_t, SEGMENT_BLOCKS> ScannerT;
39#endif
40
[4826]41typedef void (*process_block_initialize_carries_fcn)();
[4726]42typedef void (*process_block_fcn)(const Basis_bits & basis_bits, Output & output);
[4324]43
[4788]44namespace llvm { class raw_ostream; }
45
[4659]46class GrepExecutor {
47public:
[4324]48
[4826]49    GrepExecutor(void * process_block_initialize_carries, void * process_block)
[4659]50    : mCountOnlyOption(false)
[4802]51    , mGetCodePointsOption(false)
[4659]52    , mShowFileNameOption(false)
53    , mShowLineNumberingOption(false)
[4802]54    , mParsedCodePointSet(nullptr)
[4826]55    , mInitializeCarriesFcn(reinterpret_cast<process_block_initialize_carries_fcn>(process_block_initialize_carries))
[4659]56    , mProcessBlockFcn(reinterpret_cast<process_block_fcn>(process_block)) {
[4324]57
[4659]58    }
[4327]59         
[4324]60    void setCountOnlyOption(bool doCount = true) {mCountOnlyOption = doCount;}
[4803]61    void setParseCodepointsOption() {
62        mGetCodePointsOption = true;
[4802]63        mParsedCodePointSet = re::makeCC();
64    }
[4324]65    void setShowFileNameOption(bool showF = true) {mShowFileNameOption = showF;}
66    void setShowLineNumberOption(bool showN = true) {mShowLineNumberingOption = showN;}
[4460]67    void setNormalizeLineBreaksOption(bool normLB = true) {mNormalizeLineBreaksOption = normLB;}
[4324]68   
[4788]69    void doGrep(const std::string & fileName);
[4802]70    re::CC * getParsedCodepoints() { return mParsedCodePointSet;}
[4324]71private:
[4788]72    ssize_t write_matches(llvm::raw_ostream & out, const char *buffer, ssize_t first_line_start);
[4802]73   
[4788]74    bool finalLineIsUnterminated() const;
[4802]75    ssize_t extract_codepoints(char * buffer, ssize_t first_line_start);
[4325]76
[4324]77    bool mCountOnlyOption;
[4802]78    bool mGetCodePointsOption;
[4324]79    bool mShowFileNameOption;
80    bool mShowLineNumberingOption;
[4460]81    bool mNormalizeLineBreaksOption;
[4802]82   
83    re::CC * mParsedCodePointSet;
[4478]84
[4826]85    process_block_initialize_carries_fcn mInitializeCarriesFcn;
[4324]86    process_block_fcn mProcessBlockFcn;
87   
[4477]88    std::string mFileName;
89    size_t mFileSize;
[4478]90    char * mFileBuffer;
91    ScannerT mLineBreak_scanner;
92    ScannerT mMatch_scanner;
[4788]93    size_t mLineNum;
[4324]94};
95
96
97#endif
Note: See TracBrowser for help on using the repository browser.