>>106768606
i have simple ast expressions that i want to optimize and turn them into executable bytecode, right now i'm pretty much asking chatgtp to generate defines that matches the asm.
switch (e->as.bin.op)
{
case OP_Operand_Add:
APPEND_ASM("add rax, r9;\n");
APPEND_BYTES(ADD_RAX_R9);
break;
case OP_Operand_Sub:
APPEND_ASM("sub rax, r9;\n");
APPEND_BYTES(SUB_RAX_R9);
break;
case OP_Operand_Multiply:
APPEND_ASM("imul rax, r9;\n");
APPEND_BYTES(IMUL_RAX_R9);
break;
case OP_Operand_Divide:
APPEND_ASM("cqo;\nidiv r9;\n");
APPEND_BYTES(CDQ);
APPEND_BYTES(IDIV_R9);
break; // rax / r9-> rax
default: PARSER_THROW_ERR("Unsupported operator");
}
..and so on. would be much nicer if i could ditch the APPEND_BYTES out and compile the asm-string into bytecode.
>>106768657
for example, there's libggcjit and dynasm that could do the trick, but they are somewhat big decencies when the asm/bytecode part of the whole program is still relative very small entirety.