Sat Jan 19 14:22:26 CET 2013

C code generation from scheme syntax?

Generating Scheme syntax has the benefit that some checks can be
performed on the generated syntax.  It might be best to convert the
Scheme syntax to C, instead of generating C directly.

Trouble is though that processing state should be abstracted into
structs at the very end (primitives should stick to scalar addressing).

I'm just using a #define indirection to map the generated state names
to float array elements.

It seems best to also compile straight to chunk processing function.

EDIT: Ok, works, this is what comes out:

void fun(_ * restrict so,
         _ * restrict si,
         const _ ** restrict in,
         _ ** restrict out,
         int nb_samples) {
	for (int i = 0; i < nb_samples; i++) {
		#define si0_17 (si[0])
		#define so0_18 (so[0])
		#define si0_20 (si[1])
		#define so0_21 (so[1])
		#define i0_12 (in[0][i])
		#define i1_13 (in[1][i])
		_ o0_14; mul(&o0_14, i0_12, i0_12);
		_ o0_15; mul(&o0_15, i1_13, i1_13);
		_ o0_16; add(&o0_16, o0_14, o0_15);
		_ o0_19; integrate(&so0_18, &o0_19, si0_17, o0_16);
		_ o0_22; integrate(&so0_21, &o0_22, si0_20, o0_19);
		out[0][i] = o0_22;
		_ *tmp = si; si = so; so = tmp;