CPU skeleton.
This commit is contained in:
@@ -17,19 +17,68 @@
|
||||
using namespace llvm;
|
||||
|
||||
|
||||
void do_cpu_stuff() {
|
||||
typedef struct xe_cpu {
|
||||
xe_ref_t ref;
|
||||
|
||||
xe_cpu_options_t options;
|
||||
|
||||
xe_pal_ref pal;
|
||||
xe_memory_ref memory;
|
||||
} xe_cpu_t;
|
||||
|
||||
|
||||
xe_cpu_ref xe_cpu_create(xe_pal_ref pal, xe_memory_ref memory,
|
||||
xe_cpu_options_t options) {
|
||||
xe_cpu_ref cpu = (xe_cpu_ref)xe_calloc(sizeof(xe_cpu));
|
||||
xe_ref_init((xe_ref)cpu);
|
||||
|
||||
xe_copy_struct(&cpu->options, &options, sizeof(xe_cpu_options_t));
|
||||
|
||||
cpu->pal = xe_pal_retain(pal);
|
||||
cpu->memory = xe_memory_retain(memory);
|
||||
|
||||
return cpu;
|
||||
}
|
||||
|
||||
void xe_cpu_dealloc(xe_cpu_ref cpu) {
|
||||
xe_memory_release(cpu->memory);
|
||||
xe_pal_release(cpu->pal);
|
||||
}
|
||||
|
||||
xe_cpu_ref xe_cpu_retain(xe_cpu_ref cpu) {
|
||||
xe_ref_retain((xe_ref)cpu);
|
||||
return cpu;
|
||||
}
|
||||
|
||||
void xe_cpu_release(xe_cpu_ref cpu) {
|
||||
xe_ref_release((xe_ref)cpu, (xe_ref_dealloc_t)xe_cpu_dealloc);
|
||||
}
|
||||
|
||||
xe_pal_ref xe_cpu_get_pal(xe_cpu_ref cpu) {
|
||||
return xe_pal_retain(cpu->pal);
|
||||
}
|
||||
|
||||
xe_memory_ref xe_cpu_get_memory(xe_cpu_ref cpu) {
|
||||
return xe_memory_retain(cpu->memory);
|
||||
}
|
||||
|
||||
int xe_cpu_prepare_module(xe_cpu_ref cpu, xe_module_ref module) {
|
||||
// TODO(benvanik): lookup the module in the cache.
|
||||
|
||||
// TODO(benvanik): implement prepare module.
|
||||
|
||||
XELOGCPU(XT("cpu"));
|
||||
|
||||
LLVMContext &context = getGlobalContext();
|
||||
//IRBuilder<> builder(context);
|
||||
Module *module = new Module("my cool jit", context);
|
||||
Module *m = new Module("my cool jit", context);
|
||||
|
||||
Constant* c = module->getOrInsertFunction("mul_add",
|
||||
/*ret type*/ IntegerType::get(context, 32),
|
||||
/*args*/ IntegerType::get(context, 32),
|
||||
IntegerType::get(context, 32),
|
||||
IntegerType::get(context, 32),
|
||||
/*varargs terminated with null*/ NULL);
|
||||
Constant* c = m->getOrInsertFunction("mul_add",
|
||||
/*ret type*/ IntegerType::get(context, 32),
|
||||
/*args*/ IntegerType::get(context, 32),
|
||||
IntegerType::get(context, 32),
|
||||
IntegerType::get(context, 32),
|
||||
/*varargs terminated with null*/ NULL);
|
||||
|
||||
Function* mul_add = cast<Function>(c);
|
||||
mul_add->setCallingConv(CallingConv::C);
|
||||
@@ -54,6 +103,18 @@ void do_cpu_stuff() {
|
||||
|
||||
XELOGD(XT("woo %d"), 123);
|
||||
|
||||
module->dump();
|
||||
delete module;
|
||||
m->dump();
|
||||
delete m;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xe_cpu_execute(xe_cpu_ref cpu, uint32_t address) {
|
||||
// TODO(benvanik): implement execute.
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t xe_cpu_create_callback(xe_cpu_ref cpu,
|
||||
void (*callback)(void*), void *data) {
|
||||
// TODO(benvanik): implement callback creation.
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user