summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colm/fsmcodegen.cc115
-rw-r--r--colm/fsmcodegen.h1
-rw-r--r--colm/redfsm.cc44
-rw-r--r--colm/redfsm.h48
4 files changed, 1 insertions, 207 deletions
diff --git a/colm/fsmcodegen.cc b/colm/fsmcodegen.cc
index 42085009..97a23b0b 100644
--- a/colm/fsmcodegen.cc
+++ b/colm/fsmcodegen.cc
@@ -583,116 +583,6 @@ void FsmCodeGen::emitRangeBSearch( RedState *state, int level, int low, int high
}
}
-void FsmCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level )
-{
- GenCondSpace *condSpace = stateCond->condSpace;
- out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
- KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
- " - " << KEY(keyOps->minKey) << "));\n";
-
- for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- out << TABS(level) << "if ( ";
- CONDITION( out, *csi );
- Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
- out << " ) _widec += " << condValOffset << ";\n";
- }
-}
-
-void FsmCodeGen::emitCondBSearch( RedState *state, int level, int low, int high )
-{
- /* Get the mid position, staying on the lower end of the range. */
- int mid = (low + high) >> 1;
- GenStateCond **data = state->stateCondVect.data;
-
- /* Determine if we need to look higher or lower. */
- bool anyLower = mid > low;
- bool anyHigher = mid < high;
-
- /* Determine if the keys at mid are the limits of the alphabet. */
- bool limitLow = data[mid]->lowKey == keyOps->minKey;
- bool limitHigh = data[mid]->highKey == keyOps->maxKey;
-
- if ( anyLower && anyHigher ) {
- /* Can go lower and higher than mid. */
- out << TABS(level) << "if ( " << GET_KEY() << " < " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- emitCondBSearch( state, level+1, low, mid-1 );
- out << TABS(level) << "} else if ( " << GET_KEY() << " > " <<
- KEY(data[mid]->highKey) << " ) {\n";
- emitCondBSearch( state, level+1, mid+1, high );
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( anyLower && !anyHigher ) {
- /* Can go lower than mid but not higher. */
- out << TABS(level) << "if ( " << GET_KEY() << " < " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- emitCondBSearch( state, level+1, low, mid-1 );
-
- /* if the higher is the highest in the alphabet then there is no
- * sense testing it. */
- if ( limitHigh ) {
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- }
- else if ( !anyLower && anyHigher ) {
- /* Can go higher than mid but not lower. */
- out << TABS(level) << "if ( " << GET_KEY() << " > " <<
- KEY(data[mid]->highKey) << " ) {\n";
- emitCondBSearch( state, level+1, mid+1, high );
-
- /* If the lower end is the lowest in the alphabet then there is no
- * sense testing it. */
- if ( limitLow ) {
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_KEY() << " >= " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- }
- else {
- /* Cannot go higher or lower than mid. It's mid or bust. What
- * tests to do depends on limits of alphabet. */
- if ( !limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " <<
- GET_KEY() << " && " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( !limitLow && limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " <<
- GET_KEY() << " )\n {";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- /* Both high and low are at the limit. No tests to do. */
- COND_TRANSLATE(data[mid], level);
- }
- }
-}
-
std::ostream &FsmCodeGen::STATE_GOTOS()
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
@@ -702,11 +592,6 @@ std::ostream &FsmCodeGen::STATE_GOTOS()
/* Writing code above state gotos. */
GOTO_HEADER( st );
- if ( st->stateCondVect.length() > 0 ) {
- out << " _widec = " << GET_KEY() << ";\n";
- emitCondBSearch( st, 1, 0, st->stateCondVect.length() - 1 );
- }
-
/* Try singles. */
if ( st->outSingle.length() > 0 )
emitSingleSwitch( st );
diff --git a/colm/fsmcodegen.h b/colm/fsmcodegen.h
index 41cd88ec..1b004f5e 100644
--- a/colm/fsmcodegen.h
+++ b/colm/fsmcodegen.h
@@ -178,7 +178,6 @@ public:
std::ostream &TO_STATE_ACTIONS();
std::ostream &FROM_STATE_ACTIONS();
- void COND_TRANSLATE( GenStateCond *stateCond, int level );
void emitCondBSearch( RedState *state, int level, int low, int high );
void STATE_CONDS( RedState *state, bool genDefault );
diff --git a/colm/redfsm.cc b/colm/redfsm.cc
index 090157b3..d8e4a983 100644
--- a/colm/redfsm.cc
+++ b/colm/redfsm.cc
@@ -53,8 +53,6 @@ RedFsm::RedFsm()
numFinStates(0),
allActions(0),
allActionTables(0),
- allConditions(0),
- allCondSpaces(0),
allStates(0),
bAnyToStateActions(false),
bAnyFromStateActions(false),
@@ -580,28 +578,6 @@ void RedFsm::setInTrans()
trans->targ->inTrans[trans->targ->numInTrans++] = trans;
}
-GenCondSpace *RedFsm::findCondSpace( Key lowKey, Key highKey )
-{
- for ( CondSpaceList::Iter cs = condSpaceList; cs.lte(); cs++ ) {
- Key csHighKey = cs->baseKey;
- csHighKey += keyOps->alphSize() * (1 << cs->condSet.length());
-
- if ( lowKey >= cs->baseKey && highKey <= csHighKey )
- return cs;
- }
- return 0;
-}
-
-Condition *RedFsm::findCondition( Key key )
-{
- for ( ConditionList::Iter cond = conditionList; cond.lte(); cond++ ) {
- Key upperKey = cond->baseKey + (1 << cond->condSet.length());
- if ( cond->baseKey <= key && key <= upperKey )
- return cond;
- }
- return 0;
-}
-
void RedFsm::setValueLimits()
{
maxSingleLen = 0;
@@ -622,16 +598,11 @@ void RedFsm::setValueLimits()
/* In both of these cases the 0 index is reserved for no value, so the max
* is one more than it would be if they started at 0. */
maxIndex = transSet.length();
- maxCond = condSpaceList.length();
+ maxCond = 0;
/* The nextStateId - 1 is the last state id assigned. */
maxState = nextStateId - 1;
- for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- if ( csi->condSpaceId > maxCondSpaceId )
- maxCondSpaceId = csi->condSpaceId;
- }
-
for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
/* Maximum single length. */
if ( st->outSingle.length() > maxSingleLen )
@@ -647,13 +618,6 @@ void RedFsm::setValueLimits()
maxIndexOffset += st->outSingle.length() + st->outRange.length() + 1;
}
- /* Max cond span. */
- if ( st->condList != 0 ) {
- unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey );
- if ( span > maxCondSpan )
- maxCondSpan = span;
- }
-
/* Max key span. */
if ( st->transList != 0 ) {
unsigned long long span = keyOps->span( st->lowKey, st->highKey );
@@ -661,12 +625,6 @@ void RedFsm::setValueLimits()
maxSpan = span;
}
- /* Max cond index offset. */
- if ( ! st.last() ) {
- if ( st->condList != 0 )
- maxCondIndexOffset += keyOps->span( st->condLowKey, st->condHighKey );
- }
-
/* Max flat index offset. */
if ( ! st.last() ) {
if ( st->transList != 0 )
diff --git a/colm/redfsm.h b/colm/redfsm.h
index 39b98d5f..74eba533 100644
--- a/colm/redfsm.h
+++ b/colm/redfsm.h
@@ -251,50 +251,12 @@ typedef BstMapEl<int, int> RedEntryMapEl;
typedef Vector<int> RegionToEntry;
-typedef Vector< GenAction* > GenCondSet;
-
-struct Condition
-{
- Condition( )
- : key(0), baseKey(0) {}
-
- Key key;
- Key baseKey;
- GenCondSet condSet;
-
- Condition *next, *prev;
-};
-typedef DList<Condition> ConditionList;
-
-struct GenCondSpace
-{
- Key baseKey;
- GenCondSet condSet;
- int condSpaceId;
-
- GenCondSpace *next, *prev;
-};
-typedef DList<GenCondSpace> CondSpaceList;
-
-struct GenStateCond
-{
- Key lowKey;
- Key highKey;
-
- GenCondSpace *condSpace;
-
- GenStateCond *prev, *next;
-};
-typedef DList<GenStateCond> GenStateCondList;
-typedef Vector<GenStateCond*> StateCondVect;
-
/* Reduced state. */
struct RedState
{
RedState()
:
defTrans(0),
- condList(0),
transList(0),
isFinal(false),
labelNeeded(false),
@@ -318,7 +280,6 @@ struct RedState
/* For flat conditions. */
Key condLowKey, condHighKey;
- GenCondSpace **condList;
/* For flat keys. */
Key lowKey, highKey;
@@ -336,8 +297,6 @@ struct RedState
RedAction *eofAction;
RedTrans *eofTrans;
int id;
- GenStateCondList stateCondList;
- StateCondVect stateCondVect;
/* Pointers for the list of states. */
RedState *prev, *next;
@@ -386,12 +345,8 @@ struct RedFsm
GenAction *allActions;
RedAction *allActionTables;
- Condition *allConditions;
- GenCondSpace *allCondSpaces;
RedState *allStates;
GenActionList genActionList;
- ConditionList conditionList;
- CondSpaceList condSpaceList;
EntryIdVect entryPointIds;
EntryNameVect entryPointNames;
RedEntryMap redEntryMap;
@@ -447,9 +402,6 @@ struct RedFsm
bool anyLmSwitchError() { return bAnyLmSwitchError; }
bool anyConditions() { return bAnyConditions; }
- GenCondSpace *findCondSpace( Key lowKey, Key highKey );
- Condition *findCondition( Key key );
-
/* Is is it possible to extend a range by bumping ranges that span only
* one character to the singles array. */
bool canExtend( const RedTransList &list, int pos );