Writing a new front-end questions

58 views
Skip to first unread message

Philipp Kewisch

unread,
Nov 26, 2012, 3:08:16 PM11/26/12
to lib...@googlegroups.com
Heya,

I'm writing a frontend for a custom CPU and have some questions:

1. I see upcc generates the stubs for most things and the wiki mentions it doesn't generate translated instructions for a reason. On the other hand, I see examples with "insn" and adding a line "insn add : a = %CC (a + b);" parses and generates at least the enum for the instruction in myarch_opc.h. Whats the point of adding the insn lines? What is decoder_operands? What is %CC ?

2. I see there seems to be a new way to specify registers. I see a few frontends that seem to be using a mix of both. I don't understand how it fits together... Lets say I implement an instruction translation like this:

    case INC: {
        llvm::Value *v = ADD(R24(instr.A), CONST(1));
        arch_put_reg(cpu, instr.A, v, 24, true, bb);
        break;
    }

This seems to set the register internally, but on the other hand I see backends like 6502 use a reg_6502_t to hold all the registers. I couldn't find out how/where the 6502 arch or libcpu itself actually fills the reg_6502_t structure. I've done the same in my arch and setting the regs like above doesn't change anything in the reg_myarch_t structure (based on my observations, as expected). Looking at the intermediate code, it seems the code actually does what it should though.

3. Extending on my last question, how would a debug function look that dumps all registers? Just dumping the reg_myarch_t gives me a bunch of 0 values for the same expected reason as mentioned in the last question.

4. Whats the correct way to end the program? Currently, debug says "basic block L00000406 not found in function 0x8093828 - creating return basic block!" where 406h is the cpu->code_end value. Calling cpu_run returns JIT_RETURN_FUNCNOTFOUND. Should I be detecting this and then checking if the pc is at cpu->code_end and then breaking out? Or am I doing something wrong and should be getting JIT_RETURN_NOERR ?

5. Is the intermediate code actually fed to llvm and run? Can I use a debugger to step through the generated code run on the host machine? Or is the only way to debug using CPU_DEBUG_SINGLESTEP?

Thanks for the help,
Philipp
Reply all
Reply to author
Forward
0 new messages