Executing a bunch of instructions!
Very hacky module startup code, but can now start XEXs! Time to start implementing kernel stuff.
This commit is contained in:
@@ -539,7 +539,7 @@ XEEMITTER(andix, 0x70000000, D )(FunctionGenerator& g, IRBuilder<>& b, I
|
||||
// With cr0 update.
|
||||
g.update_cr_with_cond(0, v, b.getInt64(0), true);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
XEEMITTER(andisx, 0x74000000, D )(FunctionGenerator& g, IRBuilder<>& b, InstrData& i) {
|
||||
@@ -805,7 +805,6 @@ XEEMITTER(rlwinmx, 0x54000000, M )(FunctionGenerator& g, IRBuilder<>& b, I
|
||||
// g.update_cr_with_cond(0, v, b.getInt64(0), true);
|
||||
// }
|
||||
|
||||
printf("rlwinmx %d %d %d\n", i.M.SH, i.M.MB, i.M.ME);
|
||||
XEINSTRNOTIMPLEMENTED();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ XEEMITTER(bcx, 0x40000000, B )(FunctionGenerator& g, IRBuilder<>& b, I
|
||||
// Decrement counter.
|
||||
Value* ctr = g.ctr_value();
|
||||
ctr = b.CreateSub(ctr, b.getInt64(1));
|
||||
g.update_ctr_value(ctr);
|
||||
|
||||
// Ctr check.
|
||||
if (XESELECTBITS(i.B.BO, 1, 1)) {
|
||||
@@ -520,7 +521,7 @@ int XeEmitTrap(FunctionGenerator& g, IRBuilder<>& b, InstrData& i,
|
||||
b.SetInsertPoint(trap_bb);
|
||||
g.SpillRegisters();
|
||||
// TODO(benvanik): use @llvm.debugtrap? could make debugging better
|
||||
b.CreateCall2(g.gen_module()->getGlobalVariable("XeTrap"),
|
||||
b.CreateCall2(g.gen_module()->getFunction("XeTrap"),
|
||||
g.gen_fn()->arg_begin(),
|
||||
b.getInt32(i.address));
|
||||
b.CreateBr(after_bb);
|
||||
|
||||
@@ -117,7 +117,7 @@ void FunctionGenerator::GenerateBasicBlocks() {
|
||||
|
||||
if (FLAGS_trace_user_calls) {
|
||||
SpillRegisters();
|
||||
Value* traceUserCall = gen_module_->getGlobalVariable("XeTraceUserCall");
|
||||
Value* traceUserCall = gen_module_->getFunction("XeTraceUserCall");
|
||||
builder_->CreateCall3(
|
||||
traceUserCall,
|
||||
gen_fn_->arg_begin(),
|
||||
@@ -162,7 +162,7 @@ void FunctionGenerator::GenerateBasicBlocks() {
|
||||
void FunctionGenerator::GenerateSharedBlocks() {
|
||||
IRBuilder<>& b = *builder_;
|
||||
|
||||
Value* indirect_branch = gen_module_->getGlobalVariable("XeIndirectBranch");
|
||||
Value* indirect_branch = gen_module_->getFunction("XeIndirectBranch");
|
||||
|
||||
// Setup initial register fill in the entry block.
|
||||
// We can only do this once all the locals have been created.
|
||||
@@ -218,9 +218,9 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block,
|
||||
//i->setMetadata("some.name", MDNode::get(context, MDString::get(context, pname)));
|
||||
|
||||
Value* invalidInstruction =
|
||||
gen_module_->getGlobalVariable("XeInvalidInstruction");
|
||||
gen_module_->getFunction("XeInvalidInstruction");
|
||||
Value* traceInstruction =
|
||||
gen_module_->getGlobalVariable("XeTraceInstruction");
|
||||
gen_module_->getFunction("XeTraceInstruction");
|
||||
|
||||
// Walk instructions in block.
|
||||
uint8_t* p = xe_memory_addr(memory_, 0);
|
||||
@@ -390,7 +390,7 @@ int FunctionGenerator::GenerateIndirectionBranch(uint32_t cia, Value* target,
|
||||
SpillRegisters();
|
||||
|
||||
// TODO(benvanik): keep function pointer lookup local.
|
||||
Value* indirect_branch = gen_module_->getGlobalVariable("XeIndirectBranch");
|
||||
Value* indirect_branch = gen_module_->getFunction("XeIndirectBranch");
|
||||
b.CreateCall3(indirect_branch,
|
||||
gen_fn_->arg_begin(),
|
||||
target,
|
||||
@@ -861,6 +861,9 @@ Value* FunctionGenerator::ReadMemory(Value* addr, uint32_t size, bool extend) {
|
||||
}
|
||||
PointerType* pointerTy = PointerType::getUnqual(dataTy);
|
||||
|
||||
// Input address is always in 32-bit space.
|
||||
addr = b.CreateAnd(addr, UINT_MAX);
|
||||
|
||||
Value* offset_addr = b.CreateAdd(addr, b.getInt64(size));
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), offset_addr);
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
@@ -890,6 +893,9 @@ void FunctionGenerator::WriteMemory(Value* addr, uint32_t size, Value* value) {
|
||||
}
|
||||
PointerType* pointerTy = PointerType::getUnqual(dataTy);
|
||||
|
||||
// Input address is always in 32-bit space.
|
||||
addr = b.CreateAnd(addr, UINT_MAX);
|
||||
|
||||
Value* offset_addr = b.CreateAdd(addr, b.getInt64(size));
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), offset_addr);
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
|
||||
@@ -77,7 +77,7 @@ int ModuleGenerator::Generate() {
|
||||
}
|
||||
di_builder_ = new DIBuilder(*gen_module_);
|
||||
di_builder_->createCompileUnit(
|
||||
0,
|
||||
dwarf::DW_LANG_C99, //0x8010,
|
||||
StringRef(module_name_),
|
||||
StringRef(dir),
|
||||
StringRef("xenia"),
|
||||
@@ -196,7 +196,7 @@ void ModuleGenerator::AddMissingImport(FunctionSymbol* fn) {
|
||||
IRBuilder<> builder(block);
|
||||
|
||||
if (FLAGS_trace_kernel_calls) {
|
||||
Value* traceKernelCall = m->getGlobalVariable("XeTraceKernelCall");
|
||||
Value* traceKernelCall = m->getFunction("XeTraceKernelCall");
|
||||
builder.CreateCall3(
|
||||
traceKernelCall,
|
||||
f->arg_begin(),
|
||||
|
||||
Reference in New Issue
Block a user