Skip to content

Commit

Permalink
Merge pull request #30 from fastly/sv/add-cdata-codegen-with-eager-ou…
Browse files Browse the repository at this point in the history
…tputs

Add cdata codegen, with eager output support
  • Loading branch information
silentbicycle authored Oct 13, 2024
2 parents c7b9e1d + 6e9b7f1 commit 7cb37be
Show file tree
Hide file tree
Showing 15 changed files with 1,303 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fuzz/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static int
fuzz_eager_output(const uint8_t *data, size_t size)
{
if (size > 0) {
unsigned seed = data[0];
const unsigned seed = data[0];
srand(seed);
}

Expand Down
2 changes: 2 additions & 0 deletions include/fsm/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ enum fsm_print_lang {
FSM_PRINT_VMC, /* ISO C90 code, VM style */
FSM_PRINT_VMDOT, /* Graphviz Dot format, showing VM opcodes */

FSM_PRINT_CDATA, /* C data tables and small interpreter */

FSM_PRINT_VMOPS_C, /* VM opcodes as a datastructure */
FSM_PRINT_VMOPS_H,
FSM_PRINT_VMOPS_MAIN
Expand Down
4 changes: 3 additions & 1 deletion src/libfsm/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ fsm_print(FILE *f, const struct fsm *fsm,
case FSM_PRINT_VMC: print_vm = fsm_print_vmc; break;
case FSM_PRINT_VMDOT: print_vm = fsm_print_vmdot; break;

case FSM_PRINT_CDATA: print_ir = fsm_print_cdata; break;

case FSM_PRINT_VMOPS_C: print_vm = fsm_print_vmops_c; break;
case FSM_PRINT_VMOPS_H: print_vm = fsm_print_vmops_h; break;
case FSM_PRINT_VMOPS_MAIN: print_vm = fsm_print_vmops_main; break;
Expand Down Expand Up @@ -363,7 +365,7 @@ fsm_print(FILE *f, const struct fsm *fsm,
}

if (print_ir != NULL) {
r = print_ir(f, opt, hooks, ir);
r = print_ir(f, fsm->alloc, opt, hooks, ir);
goto done;
}

Expand Down
2 changes: 2 additions & 0 deletions src/libfsm/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef int fsm_print_f(FILE *f,
const struct fsm *fsm);

typedef int ir_print_f(FILE *f,
const struct fsm_alloc *alloc,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ir *ir);
Expand Down Expand Up @@ -88,6 +89,7 @@ vm_print_f fsm_print_llvm;
vm_print_f fsm_print_rust;
vm_print_f fsm_print_sh;
vm_print_f fsm_print_vmc;
ir_print_f fsm_print_cdata;

vm_print_f fsm_print_vmdot;
vm_print_f fsm_print_vmops_c;
Expand Down
1 change: 1 addition & 0 deletions src/libfsm/print/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRC += src/libfsm/print/irdot.c
SRC += src/libfsm/print/irjson.c
SRC += src/libfsm/print/json.c
SRC += src/libfsm/print/llvm.c
SRC += src/libfsm/print/cdata.c
SRC += src/libfsm/print/rust.c
SRC += src/libfsm/print/sh.c
SRC += src/libfsm/print/vmasm.c
Expand Down
2 changes: 2 additions & 0 deletions src/libfsm/print/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,13 @@ fsm_print_c_body(FILE *f, const struct ir *ir,

int
fsm_print_c(FILE *f,
const struct fsm_alloc *alloc,
const struct fsm_options *opt,
const struct fsm_hooks *hooks,
const struct ir *ir)
{
const char *prefix;
(void)alloc;

assert(f != NULL);
assert(opt != NULL);
Expand Down
Loading

0 comments on commit 7cb37be

Please sign in to comment.