Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
toyvm.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <vector>
#include "xbyak/xbyak.h"
#include "xbyak/xbyak_util.h"
Include dependency graph for toyvm.cpp:

Go to the source code of this file.

Classes

class  ToyVm
 
class  Fib
 

Macros

#define XBYAK_NO_OP_NAMES
 
#define NUM_OF_ARRAY(x)
 

Functions

void fibC (uint32 n)
 
int main ()
 

Macro Definition Documentation

◆ NUM_OF_ARRAY

#define NUM_OF_ARRAY ( x)
Value:
(sizeof(x) / sizeof(x[0]))

Definition at line 33 of file toyvm.cpp.

◆ XBYAK_NO_OP_NAMES

#define XBYAK_NO_OP_NAMES

Definition at line 30 of file toyvm.cpp.

Function Documentation

◆ fibC()

void fibC ( uint32 n)

Definition at line 286 of file toyvm.cpp.

287{
288 uint32 p, c, t;
289 p = 1;
290 c = 1;
291lp:
292 t = c;
293 c += p;
294 p = t;
295 n--;
296 if (n != 0) goto lp;
297 printf("c=%d(0x%08x)\n", c, c);
298}
const mie::Vuint & p
Definition bn.cpp:27
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Xbyak::uint32 uint32
Definition quantize.cpp:52
Here is the caller graph for this function:

◆ main()

int main ( void )

Definition at line 300 of file toyvm.cpp.

301{
302 try {
303 const int n = 10000;
304 Fib fib(n);
305
306 fib.recompile();
307
308 {
310 clk.begin();
311 fib.run();
312 clk.end();
313 printf("vm %.2fKclk\n", clk.getClock() * 1e-3);
314 }
315
316 {
318 clk.begin();
319 fib.runByJIT();
320 clk.end();
321 printf("jit %.2fKclk\n", clk.getClock() * 1e-3);
322 }
323
324 {
326 clk.begin();
327 fibC(n);
328 clk.end();
329 printf("native C %.2fKclk\n", clk.getClock() * 1e-3);
330 }
331 } catch (std::exception& e) {
332 printf("ERR:%s\n", e.what());
333 } catch (...) {
334 printf("unknown error\n");
335 }
336 return 0;
337}
Definition toyvm.cpp:248
uint64 getClock() const
Definition xbyak_util.h:401
void fibC(uint32 n)
Definition toyvm.cpp:286
Here is the call graph for this function: