| 8682 | static unsigned char opsBuffer[16384]; |
| 8683 | |
| 8684 | void generateSource(struct CPU* cpu, U32 eip, struct Block* block) { |
| 8685 | struct Op* op = block->ops; |
| 8686 | char name[256]; |
| 8687 | char tmp[1024]; |
| 8688 | int i; |
| 8689 | U32 crc; |
| 8690 | struct GenData* data = &d; |
| 8691 | |
| 8692 | // if the block has only one op then don't compile it |
| 8693 | if (!block->ops->next) { |
| 8694 | return; |
| 8695 | } |
| 8696 | |
| 8697 | data->eip = eip; |
| 8698 | data->cpu = cpu; |
| 8699 | data->block = block; |
| 8700 | data->lazyFlags = sFLAGS_UNKNOWN; |
| 8701 | data->ops = opsBuffer; |
| 8702 | data->opPos = 0; |
| 8703 | data->maxOpPos = sizeof(opsBuffer); |
| 8704 | data->ip = eip; |
| 8705 | |
| 8706 | while (op) { |
| 8707 | if (!srcgen[op->inst]) { |
| 8708 | klog("missing instruction for recompiler: %X", op->inst); |
| 8709 | return; |
| 8710 | } |
| 8711 | for (i=0;i<op->eipCount;i++) { |
| 8712 | if (!isValidReadAddress(cpu->thread, data->ip)) |
| 8713 | return; |
| 8714 | data->ops[data->opPos++] = readb(cpu->thread, data->ip++); |
| 8715 | } |
| 8716 | op = op->next; |
| 8717 | } |
| 8718 | crc = crc32b(data->ops, data->opPos); |
| 8719 | |
| 8720 | if (doesBlockExist(crc, data->ops, data->opPos)) |
| 8721 | return; |
| 8722 | |
| 8723 | op = block->ops; |
| 8724 | if (!data->sourceBuffer) { |
| 8725 | data->sourceBufferLen = 1024*1024*10; |
| 8726 | data->sourceBuffer = kalloc(data->sourceBufferLen, KALLOC_SRCGENBUFFER); |
| 8727 | data->sourceBufferPos = 0; |
| 8728 | out(data, "#include \"platform.h\"\n"); |
| 8729 | out(data, "#include \"cpu.h\"\n"); |
| 8730 | out(data, "#include \"../../../../source/emulation/cpu/shift.h\"\n"); |
| 8731 | out(data, "#include \"../../../../source/emulation/cpu/strings.h\"\n"); |
| 8732 | out(data, "#include \"decoder.h\"\n"); |
| 8733 | out(data, "void FPU_FCOM(struct FPU* fpu, int st, int other);\n"); |
| 8734 | out(data, "void FPU_FUCOM(struct FPU* fpu, int st, int other);\n"); |
| 8735 | out(data, "void FPU_FABS(struct FPU* fpu);\n"); |
| 8736 | out(data, "void FPU_FXAM(struct FPU* fpu);\n"); |
| 8737 | out(data, "void FPU_F2XM1(struct FPU* fpu);\n"); |
| 8738 | out(data, "void FPU_FYL2X(struct FPU* fpu);\n"); |
| 8739 | out(data, "void FPU_FPTAN(struct FPU* fpu);\n"); |
| 8740 | out(data, "void FPU_FPATAN(struct FPU* fpu);\n"); |
| 8741 | out(data, "void FPU_FXTRACT(struct FPU* fpu);\n"); |
nothing calls this directly
no test coverage detected