LOAD_CLOCK.

This commit is contained in:
Ben Vanik 2014-01-26 18:20:59 -08:00
parent e785e31a6f
commit 672a4fd504
1 changed files with 15 additions and 1 deletions

View File

@ -55,6 +55,15 @@ void TraceContextStore(void* raw_context, uint64_t offset, uint64_t value) {
fflush(stdout);
}
uint64_t LoadClock(void* raw_context) {
LARGE_INTEGER counter;
uint64_t time = 0;
if (QueryPerformanceCounter(&counter)) {
time = counter.QuadPart;
}
return time;
}
void CallNative(X64Emitter& e, void* target) {
e.mov(e.rax, (uint64_t)target);
e.call(e.rax);
@ -1073,7 +1082,12 @@ void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) {
});
table->AddSequence(OPCODE_LOAD_CLOCK, [](X64Emitter& e, Instr*& i) {
UNIMPLEMENTED_SEQ();
// It'd be cool to call QueryPerformanceCounter directly, but w/e.
CallNative(e, LoadClock);
Reg64 dest;
e.BeginOp(i->dest, dest, REG_DEST);
e.mov(dest, e.rax);
e.EndOp(dest);
i = e.Advance(i);
return true;
});