]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Remove CHECK_DEPTH instruction
authorJustin Viiret <justin.viiret@intel.com>
Thu, 7 Jan 2016 22:11:09 +0000 (09:11 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 1 Mar 2016 00:23:11 +0000 (11:23 +1100)
src/rose/program_runtime.h
src/rose/rose_build_bytecode.cpp
src/rose/rose_dump.cpp
src/rose/rose_program.h

index 26cfce5f3c6ae2b6ada9d6724f736e803d37f268..cc345e289c31883e26b7b40febdb2ffc61b9c659 100644 (file)
@@ -829,18 +829,6 @@ hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t, u32 programOffset,
             }
             PROGRAM_NEXT_INSTRUCTION
 
-            PROGRAM_CASE(CHECK_DEPTH) {
-                DEBUG_PRINTF("current depth %u, check min depth %u\n",
-                             tctxt->depth, ri->min_depth);
-                if (ri->min_depth > tctxt->depth) {
-                    DEBUG_PRINTF("failed depth check\n");
-                    assert(ri->fail_jump); // must progress
-                    pc += ri->fail_jump;
-                    continue;
-                }
-            }
-            PROGRAM_NEXT_INSTRUCTION
-
             PROGRAM_CASE(CHECK_ONLY_EOD) {
                 struct core_info *ci = &tctxtToScratch(tctxt)->core_info;
                 if (end != ci->buf_offset + ci->len) {
index 9c6a84b3d0101c37cca839b234ee1fbc2932b511..985efef506af9301ef98c6e10a0ccbc9ec645378 100644 (file)
@@ -170,7 +170,6 @@ public:
 
     const void *get() const {
         switch (code()) {
-        case ROSE_INSTR_CHECK_DEPTH: return &u.checkDepth;
         case ROSE_INSTR_CHECK_ONLY_EOD: return &u.checkOnlyEod;
         case ROSE_INSTR_CHECK_BOUNDS: return &u.checkBounds;
         case ROSE_INSTR_CHECK_NOT_HANDLED: return &u.checkNotHandled;
@@ -199,7 +198,6 @@ public:
 
     size_t length() const {
         switch (code()) {
-        case ROSE_INSTR_CHECK_DEPTH: return sizeof(u.checkDepth);
         case ROSE_INSTR_CHECK_ONLY_EOD: return sizeof(u.checkOnlyEod);
         case ROSE_INSTR_CHECK_BOUNDS: return sizeof(u.checkBounds);
         case ROSE_INSTR_CHECK_NOT_HANDLED: return sizeof(u.checkNotHandled);
@@ -226,7 +224,6 @@ public:
     }
 
     union {
-        ROSE_STRUCT_CHECK_DEPTH checkDepth;
         ROSE_STRUCT_CHECK_ONLY_EOD checkOnlyEod;
         ROSE_STRUCT_CHECK_BOUNDS checkBounds;
         ROSE_STRUCT_CHECK_NOT_HANDLED checkNotHandled;
@@ -2633,10 +2630,6 @@ flattenProgram(const vector<vector<RoseInstruction>> &programs) {
             assert(targets[i] > offsets[i]); // jumps always progress
             ri.u.anchoredDelay.done_jump = targets[i] - offsets[i];
             break;
-        case ROSE_INSTR_CHECK_DEPTH:
-            assert(targets[i] > offsets[i]);
-            ri.u.checkDepth.fail_jump = targets[i] - offsets[i];
-            break;
         case ROSE_INSTR_CHECK_ONLY_EOD:
             assert(targets[i] > offsets[i]);
             ri.u.checkOnlyEod.fail_jump = targets[i] - offsets[i];
@@ -3365,7 +3358,6 @@ vector<RoseInstruction> makePredProgram(RoseBuildImpl &build, build_context &bc,
 static
 pair<u32, u32> makeSparseIterProgram(build_context &bc,
                     map<u32, vector<vector<RoseInstruction>>> &predProgramLists,
-                    const vector<RoseVertex> &verts,
                     const vector<RoseInstruction> &root_program) {
     vector<RoseInstruction> program;
     u32 iter_offset = 0;
@@ -3389,17 +3381,6 @@ pair<u32, u32> makeSparseIterProgram(build_context &bc,
         vector<u32> jump_table;
         u32 curr_offset = 0;
 
-        // Add a pre-check for min depth, if it's useful.
-        if (!verts.empty()) {
-            u32 min_depth = calcMinDepth(bc.depths, verts);
-            if (min_depth > 1) {
-                auto ri = RoseInstruction(ROSE_INSTR_CHECK_DEPTH);
-                ri.u.checkDepth.min_depth = min_depth;
-                program.push_back(ri);
-                curr_offset = ROUNDUP_N(ri.length(), ROSE_INSTR_MIN_ALIGN);
-            }
-        }
-
         program.push_back(RoseInstruction(ROSE_INSTR_SPARSE_ITER_BEGIN));
         curr_offset += ROUNDUP_N(program.back().length(), ROSE_INSTR_MIN_ALIGN);
 
@@ -3436,9 +3417,6 @@ pair<u32, u32> makeSparseIterProgram(build_context &bc,
         for (size_t i = 0; i < program.size(); i++) {
             auto &ri = program[i];
             switch (ri.code()) {
-            case ROSE_INSTR_CHECK_DEPTH:
-                ri.u.checkDepth.fail_jump = end_offset - curr_offset;
-                break;
             case ROSE_INSTR_SPARSE_ITER_BEGIN:
                 ri.u.sparseIterBegin.iter_offset = iter_offset;
                 ri.u.sparseIterBegin.jump_table = jump_table_offset;
@@ -3518,8 +3496,7 @@ u32 buildLiteralProgram(RoseBuildImpl &build, build_context &bc,
     }
 
     // Put it all together.
-    return makeSparseIterProgram(bc, predProgramLists, nonroot_verts,
-                                 root_program).first;
+    return makeSparseIterProgram(bc, predProgramLists, root_program).first;
 }
 
 static
@@ -3632,7 +3609,7 @@ pair<u32, u32> buildEodAnchorProgram(RoseBuildImpl &build, build_context &bc) {
         return {0, 0};
     }
 
-    return makeSparseIterProgram(bc, predProgramLists, {}, {});
+    return makeSparseIterProgram(bc, predProgramLists, {});
 }
 
 static
index beadd23e246447068dd05f80e57d711a9bf7c45a..484fde5f71af34bb608f3d6baee8f31b362286c8 100644 (file)
@@ -203,12 +203,6 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
             }
             PROGRAM_NEXT_INSTRUCTION
 
-            PROGRAM_CASE(CHECK_DEPTH) {
-                os << "    min_depth " << u32{ri->min_depth} << endl;
-                os << "    fail_jump +" << ri->fail_jump << endl;
-            }
-            PROGRAM_NEXT_INSTRUCTION
-
             PROGRAM_CASE(CHECK_ONLY_EOD) {
                 os << "    fail_jump +" << ri->fail_jump << endl;
             }
index f7028c722b8f54a8e4f1d61e8f443397e9aae11a..a232907398863b786c1eed6eaa34bce3889ae312 100644 (file)
@@ -42,7 +42,6 @@
 /** \brief Role program instruction opcodes. */
 enum RoseInstructionCode {
     ROSE_INSTR_ANCHORED_DELAY,    //!< Delay until after anchored matcher.
-    ROSE_INSTR_CHECK_DEPTH,       //!< Check minimum graph depth.
     ROSE_INSTR_CHECK_ONLY_EOD,    //!< Role matches only at EOD.
     ROSE_INSTR_CHECK_BOUNDS,      //!< Bounds on distance from offset 0.
     ROSE_INSTR_CHECK_NOT_HANDLED, //!< Test & set role in "handled".
@@ -72,12 +71,6 @@ struct ROSE_STRUCT_ANCHORED_DELAY {
     u32 done_jump; //!< Jump forward this many bytes if successful.
 };
 
-struct ROSE_STRUCT_CHECK_DEPTH {
-    u8 code; //!< From enum RoseInstructionCode.
-    u8 min_depth; //!< Minimum depth of this literal in the Rose graph.
-    u32 fail_jump; //!< Jump forward this many bytes on failure.
-};
-
 struct ROSE_STRUCT_CHECK_ONLY_EOD {
     u8 code; //!< From enum RoseInstructionCode.
     u32 fail_jump; //!< Jump forward this many bytes on failure.