#ifndef ROSE_RUNTIME_H
#define ROSE_RUNTIME_H
#include "rose_internal.h"
#include "scratch.h"
#include "util/partial_store.h"
#define rose_inline really_inline
#define EAGER_STOP_OFFSET 64
static really_inline
const void *getByOffset(const struct RoseEngine *t, u32 offset) {
assert(offset < t->size);
return (const u8 *)t + offset;
}
static really_inline
void *getRoleState(char *state) {
return state + ROSE_STATE_OFFSET_ROLE_MMBIT;
}
static really_inline
u8 *getActiveLeafArray(const struct RoseEngine *t, char *state) {
return (u8 *)(state + t->stateOffsets.activeLeafArray);
}
static really_inline
u8 *getActiveLeftArray(const struct RoseEngine *t, char *state) {
return (u8 *)(state + t->stateOffsets.activeLeftArray);
}
static really_inline
rose_group loadGroups(const struct RoseEngine *t, const char *state) {
return partial_load_u64a(state + t->stateOffsets.groups,
t->stateOffsets.groups_size);
}
static really_inline
void storeGroups(const struct RoseEngine *t, char *state, rose_group groups) {
partial_store_u64a(state + t->stateOffsets.groups, groups,
t->stateOffsets.groups_size);
}
static really_inline
u8 *getLongLitState(const struct RoseEngine *t, char *state) {
return (u8 *)(state + t->stateOffsets.longLitState);
}
static really_inline
u8 *getLeftfixLagTable(const struct RoseEngine *t, char *state) {
return (u8 *)(state + t->stateOffsets.leftfixLagTable);
}
static really_inline
const u8 *getLeftfixLagTableConst(const struct RoseEngine *t,
const char *state) {
return (const u8 *)(state + t->stateOffsets.leftfixLagTable);
}
static really_inline
u32 has_chained_nfas(const struct RoseEngine *t) {
return t->outfixBeginQueue;
}
static really_inline
void updateLastMatchOffset(struct RoseContext *tctxt, u64a offset) {
DEBUG_PRINTF("match @%llu, last match @%llu\n", offset,
tctxt->lastMatchOffset);
assert(offset >= tctxt->minMatchOffset);
assert(offset >= tctxt->lastMatchOffset);
tctxt->lastMatchOffset = offset;
}
static really_inline
void updateLastCombMatchOffset(struct RoseContext *tctxt, u64a offset) {
DEBUG_PRINTF("match @%llu, last match @%llu\n", offset,
tctxt->lastCombMatchOffset);
assert(offset >= tctxt->lastCombMatchOffset);
tctxt->lastCombMatchOffset = offset;
}
static really_inline
void updateMinMatchOffset(struct RoseContext *tctxt, u64a offset) {
DEBUG_PRINTF("min match now @%llu, was @%llu\n", offset,
tctxt->minMatchOffset);
assert(offset >= tctxt->minMatchOffset);
assert(offset >= tctxt->minNonMpvMatchOffset);
tctxt->minMatchOffset = offset;
tctxt->minNonMpvMatchOffset = offset;
}
static really_inline
void updateMinMatchOffsetFromMpv(struct RoseContext *tctxt, u64a offset) {
DEBUG_PRINTF("min match now @%llu, was @%llu\n", offset,
tctxt->minMatchOffset);
assert(offset >= tctxt->minMatchOffset);
assert(tctxt->minNonMpvMatchOffset >= tctxt->minMatchOffset);
tctxt->minMatchOffset = offset;
tctxt->minNonMpvMatchOffset = MAX(tctxt->minNonMpvMatchOffset, offset);
}
#endif