stable 重构文件结构
抽象出Machine Code
This commit is contained in:
23
src/ccompiler/backend/backend.c
Normal file
23
src/ccompiler/backend/backend.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "backend.h"
|
||||
|
||||
int gen_asm_from_ir(ir_prog_t* ir, cc_arch_t arch, asm_prog_t* out_asm) {
|
||||
switch (arch) {
|
||||
case CC_ARCH_RISCV32:
|
||||
// TODO using maroc to choice
|
||||
init_rv32_prog(&(out_asm->rv32), NULL);
|
||||
gen_rv32_from_ir(ir, &(out_asm->rv32));
|
||||
break;
|
||||
case CC_ARCH_X86_32:
|
||||
default:
|
||||
Panic("Unsupported arch");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
asm_prog_t* cc_backend(ir_prog_t* ir, cc_backend_conf_t* conf) {
|
||||
// TODO
|
||||
asm_prog_t* bin = (asm_prog_t*)salloc_alloc(sizeof(asm_prog_t));
|
||||
gen_asm_from_ir(ir, conf->arch, bin);
|
||||
return bin;
|
||||
}
|
||||
Reference in New Issue
Block a user