Xbyak - AshokBhat/ml GitHub Wiki
- Xbyak is a C++ header library that enables dynamically to assemble x86(IA32), x64(AMD64, x86-64) mnemonic.
- What is Xbyak?
- Why is it called a JIT?
- How is it used in OneDNN?
- https://github.com/herumi/xbyak
- MIT like license
Inherit Xbyak::CodeGenerator
class and make the class method.
#include <xbyak/xbyak.h>
struct Code : Xbyak::CodeGenerator {
Code(int x)
{
mov(eax, x);
ret();
}
};
Make an instance of the class and get the function pointer by calling getCode()
and call it.
Code c(5);
int (*f)() = c.getCode<int (*)()>();
printf("ret=%d\n", f()); // ret = 5