prepare for Lua 5.3.1 merge

pull/81/head
Dibyendu Majumdar 9 years ago
parent 7fb9650cac
commit 32755f654e

@ -235,6 +235,9 @@ label_forloop:
ra = base + 0;
// if (b)
L->top = ra + b - 1;
printf("ptr diff %d\n", (int)(ra-L->top));
if (cl->p->sizep > 0)
luaF_close(L, base);
b = luaD_poscall(L, ra);

File diff suppressed because it is too large Load Diff

@ -657,6 +657,12 @@ public:
llvm::Value *emit_gep_register_or_constant(RaviFunctionDef *def, llvm::Instruction *base,
int B);
// obtain address of L->top
llvm::Value *emit_gep_L_top(RaviFunctionDef *def);
// (int)(L->top - ra)
llvm::Value *emit_num_stack_elements(RaviFunctionDef *def, llvm::Value *L_top, llvm::Value *ra);
// emit code to load the lua_Number value from register
llvm::Instruction *emit_load_reg_n(RaviFunctionDef *def, llvm::Value *ra);

@ -432,6 +432,11 @@ void RaviCodeGenerator::emit_refresh_L_top(RaviFunctionDef *def) {
ins->setMetadata(llvm::LLVMContext::MD_tbaa, def->types->tbaa_luaState_topT);
}
llvm::Value *RaviCodeGenerator::emit_gep_L_top(RaviFunctionDef *def) {
// Get pointer to L->top
return emit_gep(def, "L.top", def->L, 0, 4);
}
// L->top = R(B)
void RaviCodeGenerator::emit_set_L_top_toreg(RaviFunctionDef *def,
llvm::Instruction *base_ptr,
@ -439,12 +444,22 @@ void RaviCodeGenerator::emit_set_L_top_toreg(RaviFunctionDef *def,
// Get pointer to register at R(B)
llvm::Value *ptr = emit_gep_register(def, base_ptr, B);
// Get pointer to L->top
llvm::Value *top = emit_gep(def, "L.top", def->L, 0, 4);
llvm::Value *top = emit_gep_L_top(def);
// Assign to L->top
llvm::Instruction *ins = def->builder->CreateStore(ptr, top);
ins->setMetadata(llvm::LLVMContext::MD_tbaa, def->types->tbaa_luaState_topT);
}
// (int)(L->top - ra)
llvm::Value *RaviCodeGenerator::emit_num_stack_elements(RaviFunctionDef *def, llvm::Value *L_top, llvm::Value *ra) {
llvm::Instruction *top_ptr = def->builder->CreateLoad(L_top, "L_top");
llvm::Value *top_asint = def->builder->CreatePtrToInt(top_ptr, def->types->C_intptr_t, "L_top_as_intptr");
llvm::Value *ra_asint = def->builder->CreatePtrToInt(ra, def->types->C_intptr_t, "ra_as_intptr");
llvm::Value *result = def->builder->CreateSub(top_asint, ra_asint, "num_stack_elements");
return def->builder->CreateTrunc(result, def->types->C_intT, "num_stack_elements");
}
// Check if we can compile
// The cases we can compile will increase over time
bool RaviCodeGenerator::canCompile(Proto *p) {

Loading…
Cancel
Save