9ff2990724
- 新增 src/codegen/target.h/c: target_init/get_default_triple/create_machine/emit_obj - main.c 移除 inline LLVM Target API 调用,改调 target_* 接口 - codegen.c 专注 AST→IR,不再混入目标平台初始化 基于 Codex 分析报告 4.1 节架构改进建议。
22 lines
627 B
C
22 lines
627 B
C
#ifndef TARGET_H
|
|
#define TARGET_H
|
|
|
|
#include <llvm-c/Core.h>
|
|
#include <llvm-c/TargetMachine.h>
|
|
|
|
// 初始化 X86 目标平台(LLVMInitializeAllTarget* 的替代,LLVM-C.lib 不导出 All 系列)
|
|
void target_init(void);
|
|
|
|
// 获取默认目标三元组
|
|
char* target_get_default_triple(void);
|
|
|
|
// 从三元组获取目标机
|
|
LLVMTargetMachineRef target_create_machine(const char* triple);
|
|
|
|
// 将模块写入目标文件
|
|
// 返回 0 成功,非 0 失败(*error_msg 包含错误信息)
|
|
int target_emit_obj(LLVMTargetMachineRef tm, LLVMModuleRef module,
|
|
const char* filename, char** error_msg);
|
|
|
|
#endif
|