mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
Add line info support
This commit is contained in:
parent
6a5885cafa
commit
344c3bdeaa
4 changed files with 19 additions and 67 deletions
|
@ -113,55 +113,27 @@ IRFunction* JitCompiler::Codegen()
|
|||
labels[i].index = labels[i].block->code.size();
|
||||
|
||||
int curLine = sfunc->PCToLine(pc);
|
||||
if (curLine != lastLine)
|
||||
{
|
||||
lastLine = curLine;
|
||||
|
||||
/*auto label = cc.newLabel();
|
||||
cc.bind(label);
|
||||
|
||||
JitLineInfo info;
|
||||
info.Label = label;
|
||||
info.LineNumber = curLine;
|
||||
LineInfo.Push(info);*/
|
||||
}
|
||||
|
||||
#if 0
|
||||
FString lineinfo;
|
||||
if (op != OP_PARAM && op != OP_PARAMI && op != OP_VTBL)
|
||||
{
|
||||
FString lineinfo;
|
||||
lineinfo.Format("; line %d: %02x%02x%02x%02x %s", curLine, pc->op, pc->a, pc->b, pc->c, OpNames[op]);
|
||||
cc.comment("", 0);
|
||||
cc.comment(lineinfo.GetChars(), lineinfo.Len());
|
||||
lineinfo.Format("line %d: %02x%02x%02x%02x %s", curLine, pc->op, pc->a, pc->b, pc->c, OpNames[op]);
|
||||
}
|
||||
|
||||
labels[i].cursor = cc.getCursor();
|
||||
#endif
|
||||
|
||||
EmitOpcode();
|
||||
|
||||
// Add line info to first instruction emitted for the opcode
|
||||
IRInst* inst = labels[i].block->code[labels[i].index];
|
||||
inst->fileIndex = 0;
|
||||
inst->lineNumber = curLine;
|
||||
if (inst->comment.empty())
|
||||
inst->comment = lineinfo.GetChars();
|
||||
else
|
||||
inst->comment = lineinfo.GetChars() + ("; " + inst->comment);
|
||||
|
||||
pc++;
|
||||
}
|
||||
|
||||
/*
|
||||
auto code = cc.getCode ();
|
||||
for (unsigned int j = 0; j < LineInfo.Size (); j++)
|
||||
{
|
||||
auto info = LineInfo[j];
|
||||
|
||||
if (!code->isLabelValid (info.Label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
info.InstructionIndex = code->getLabelOffset (info.Label);
|
||||
|
||||
LineInfo[j] = info;
|
||||
}
|
||||
|
||||
std::stable_sort(LineInfo.begin(), LineInfo.end(), [](const JitLineInfo &a, const JitLineInfo &b) { return a.InstructionIndex < b.InstructionIndex; });
|
||||
*/
|
||||
|
||||
return irfunc;
|
||||
}
|
||||
|
||||
|
@ -252,6 +224,8 @@ void JitCompiler::Setup()
|
|||
//cc.comment("", 0);
|
||||
|
||||
irfunc = ircontext->createFunction(GetFunctionType5<int, VMFunction*, void*, int, void*, int>(), sfunc->PrintableName.GetChars());
|
||||
irfunc->fileInfo.push_back({ sfunc->PrintableName.GetChars(), sfunc->SourceFileName.GetChars() });
|
||||
|
||||
args = irfunc->args[1];
|
||||
numargs = irfunc->args[2];
|
||||
ret = irfunc->args[3];
|
||||
|
@ -457,11 +431,8 @@ IRBasicBlock* JitCompiler::EmitThrowExceptionLabel(EVMAbortException reason)
|
|||
auto bb = irfunc->createBasicBlock({});
|
||||
auto cursor = cc.GetInsertBlock();
|
||||
cc.SetInsertPoint(bb);
|
||||
//JitLineInfo info;
|
||||
//info.Label = bb;
|
||||
//info.LineNumber = sfunc->PCToLine(pc);
|
||||
//LineInfo.Push(info);
|
||||
EmitThrowException(reason);
|
||||
bb->code.front()->lineNumber = sfunc->PCToLine(pc);
|
||||
cc.SetInsertPoint(cursor);
|
||||
return bb;
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ void JitCompiler::EmitVMCall(IRValue* vmfunc, VMFunction* target)
|
|||
IRValue* paramsptr = OffsetPtr(vmframe, offsetParams);
|
||||
IRValue* scriptcall = Load(ToInt8PtrPtr(vmfunc, myoffsetof(VMScriptFunction, ScriptCall)));
|
||||
|
||||
/*IRValue* call =*/ cc.CreateCall(cc.CreateBitCast(scriptcall, GetFunctionType5<int, VMFunction*, VMValue*, int, VMReturn*, int>()), { vmfunc, paramsptr, ConstValueD(B), GetCallReturns(), ConstValueD(C) });
|
||||
//call->setComment(target ? target->PrintableName.GetChars() : "VMCall");
|
||||
IRInst* call = cc.CreateCall(cc.CreateBitCast(scriptcall, GetFunctionType5<int, VMFunction*, VMValue*, int, VMReturn*, int>()), { vmfunc, paramsptr, ConstValueD(B), GetCallReturns(), ConstValueD(C) });
|
||||
call->comment = target ? target->PrintableName.GetChars() : "VMCall";
|
||||
|
||||
LoadInOuts();
|
||||
LoadReturns(pc + 1, C);
|
||||
|
|
|
@ -218,11 +218,8 @@ void JitCompiler::EmitBOUND()
|
|||
IRBasicBlock* exceptionbb = irfunc->createBasicBlock({});
|
||||
cc.CreateCondBr(cc.CreateICmpUGE(LoadD(A), ConstValueD(BC)), exceptionbb, continuebb);
|
||||
cc.SetInsertPoint(exceptionbb);
|
||||
//JitLineInfo info;
|
||||
//info.Label = exceptionbb;
|
||||
//info.LineNumber = sfunc->PCToLine(pc);
|
||||
//LineInfo.Push(info);
|
||||
cc.CreateCall(GetNativeFunc<void, int, int>("__ThrowArrayOutOfBounds", &JitCompiler::ThrowArrayOutOfBounds), { LoadD(A), ConstValueD(BC) });
|
||||
exceptionbb->code.front()->lineNumber = sfunc->PCToLine(pc);
|
||||
cc.CreateBr(continuebb);
|
||||
cc.SetInsertPoint(continuebb);
|
||||
}
|
||||
|
@ -233,11 +230,8 @@ void JitCompiler::EmitBOUND_K()
|
|||
IRBasicBlock* exceptionbb = irfunc->createBasicBlock({});
|
||||
cc.CreateCondBr(cc.CreateICmpUGE(LoadD(A), ConstD(BC)), exceptionbb, continuebb);
|
||||
cc.SetInsertPoint(exceptionbb);
|
||||
//JitLineInfo info;
|
||||
//info.Label = exceptionbb;
|
||||
//info.LineNumber = sfunc->PCToLine(pc);
|
||||
//LineInfo.Push(info);
|
||||
cc.CreateCall(GetNativeFunc<void, int, int>("__ThrowArrayOutOfBounds", &JitCompiler::ThrowArrayOutOfBounds), { LoadD(A), ConstD(BC) });
|
||||
exceptionbb->code.front()->lineNumber = sfunc->PCToLine(pc);
|
||||
cc.CreateBr(continuebb);
|
||||
cc.SetInsertPoint(continuebb);
|
||||
}
|
||||
|
@ -248,11 +242,8 @@ void JitCompiler::EmitBOUND_R()
|
|||
IRBasicBlock* exceptionbb = irfunc->createBasicBlock({});
|
||||
cc.CreateCondBr(cc.CreateICmpUGE(LoadD(A), LoadD(B)), exceptionbb, continuebb);
|
||||
cc.SetInsertPoint(exceptionbb);
|
||||
//JitLineInfo info;
|
||||
//info.Label = exceptionbb;
|
||||
//info.LineNumber = sfunc->PCToLine(pc);
|
||||
//LineInfo.Push(info);
|
||||
cc.CreateCall(GetNativeFunc<void, int, int>("__ThrowArrayOutOfBounds", &JitCompiler::ThrowArrayOutOfBounds), { LoadD(A), LoadD(BC) });
|
||||
exceptionbb->code.front()->lineNumber = sfunc->PCToLine(pc);
|
||||
cc.CreateBr(continuebb);
|
||||
cc.SetInsertPoint(continuebb);
|
||||
}
|
||||
|
|
|
@ -21,15 +21,6 @@ extern int VMCalls[10];
|
|||
#define ABCs (pc[0].i24)
|
||||
#define JMPOFS(x) ((x)->i24)
|
||||
|
||||
#if 0
|
||||
struct JitLineInfo
|
||||
{
|
||||
ptrdiff_t InstructionIndex = 0;
|
||||
int32_t LineNumber = -1;
|
||||
asmjit::Label Label;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct JitLabel
|
||||
{
|
||||
IRBasicBlock* block = nullptr;
|
||||
|
@ -44,7 +35,6 @@ public:
|
|||
IRFunction* Codegen();
|
||||
|
||||
// VMScriptFunction* GetScriptFunction() { return sfunc; }
|
||||
// TArray<JitLineInfo> LineInfo;
|
||||
|
||||
private:
|
||||
// Declare EmitXX functions for the opcodes:
|
||||
|
|
Loading…
Reference in a new issue