7 #define XBYAK_NO_OP_NAMES
16static inline bool in_addN(
Unit *out,
const Unit *x,
const Unit *y,
size_t n)
20 for (
size_t i = 0; i < n; i++) {
27 c =
y[i] > xc ? 1 : 0;
37static inline bool in_add(
Unit *out,
const Unit *x,
size_t n,
Unit y)
41 Unit c =
y > xc ? 1 : 0;
43 for (
size_t i = 1; i < n; i++) {
57static inline bool in_subN(
Unit *out,
const Unit *x,
const Unit *y,
size_t n)
61 for (
size_t i = 0; i < n; i++) {
67 c = x[i] < yc ? 1 : 0;
77static inline bool in_sub(
Unit *out,
const Unit *x,
size_t n,
Unit y)
80 Unit c = x[0] <
y ? 1 : 0;
82 for (
size_t i = 1; i < n; i++) {
100#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
109#if defined(_WIN64) && !defined(__INTEL_COMPILER)
110 return _umul128(
a, b, H);
113 uint128 t = uint128(
a) * b;
124static inline void in_mul(
Unit *out,
const Unit *x,
size_t n,
Unit y)
128 for (
size_t i = 0; i < n; i++) {
130 Unit L = mulUnit(&H, x[i], y);
151#elif defined(_MSC_VER)
153 fprintf(stderr,
"not implemented divUnit\n");
157 uint128 t = (uint128(H) << 64) | L;
172 for (
int i = (
int)xn - 1; i >= 0; i--) {
173 q[i] = divUnit(&
r,
r, x[i], y);
178static inline Unit in_mod(
const Unit *x,
size_t xn,
Unit y)
181 for (
int i = (
int)xn - 1; i >= 0; i--) {
182 divUnit(&
r,
r, x[i], y);
197 void genAddSub(
bool isAdd)
199 using namespace Xbyak;
201 const Reg64&
a = rax;
203 const Reg64& out = rcx;
204 const Reg64& x = rdx;
207 const Reg64& t0 = r10;
208 const Reg64& t1 = r11;
209 const Reg64& t2 = rsi;
211 const Reg64& out = rdi;
212 const Reg64& x = rsi;
213 const Reg64&
y = rdx;
214 const Reg64& n = rcx;
215 const Reg64& t0 = r8;
216 const Reg64& t1 = r9;
217 const Reg64& t2 = r10;
248 mov(
ptr [out + 8 * 1], t0);
267 mov(
ptr [out + 8 * 1], t0);
268 mov(
ptr [out + 8 * 2], t1);
274 mov(
ptr [rsp + 8 * 1], t2);
308 mov(
ptr [out + 8 * 1], t0);
311 lea(out,
ptr [out + 8 * 2]);
328 mov(
ptr [out + 8 * 1], t0);
329 mov(
ptr [out + 8 * 2], t1);
332 lea(out,
ptr [out + 8 * 3]);
351 mov(
ptr [out + 8 * 1], t0);
352 mov(
ptr [out + 8 * 2], t1);
353 mov(
ptr [out + 8 * 3], t2);
356 lea(out,
ptr [out + 8 * 4]);
363 mov(t2,
ptr [rsp + 8 * 1]);
369 void genAddSub1(
bool isAdd)
371 using namespace Xbyak;
373 const Reg64&
a = rax;
374 const Reg64& c = rcx;
378 const Reg64& out = r10;
379 const Reg64& x = rdx;
381 const Reg64& t = r11;
385 const Reg64& out = rdi;
386 const Reg64& x = rsi;
387 const Reg64&
y = r10;
390 lea(out,
ptr [out + c * 8]);
400 mov(
ptr [out + c * 8], t);
411 mov(
ptr [out + c * 8], t);
421 using namespace Xbyak;
426 const Reg64&
a = rax;
427 const Reg64&
d = rdx;
428 const Reg64& t = r11;
433 const Reg64& out = rcx;
434 const Reg64& x = r10;
438 const Reg64& out = rdi;
439 const Reg64& x = rsi;
440 const Reg64& n = r10;
441 const Reg64&
y = rcx;
443 const int s = (int)
sizeof(
Unit);
463 using namespace Xbyak;
467 const Reg64&
a = rax;
468 const Reg64&
d = rdx;
473 const Reg64& q = rcx;
474 const Reg64& x = r10;
478 const Reg64& q = rdi;
479 const Reg64& x = rsi;
480 const Reg64& n = r10;
481 const Reg64&
y = rcx;
483 const int s = (int)
sizeof(
Unit);
501 using namespace Xbyak;
505 const Reg64&
a = rax;
506 const Reg64&
d = rdx;
511 const Reg64& x = rcx;
512 const Reg64& n = r10;
515 const Reg64& x = rdi;
516 const Reg64& n = rsi;
517 const Reg64&
y = r10;
519 const int s = (int)
sizeof(
Unit);
560 static bool isInit =
false;
565 }
catch (std::exception& e) {
566 fprintf(stderr,
"zmInit ERR:%s\n", e.what());
const uint8 * getCurr() const
void shr(const Operand &op, const Reg8 &_cl)
void and_(const Operand &op, uint32 imm)
void xor_(const Operand &op, uint32 imm)
void cmp(const Operand &op, uint32 imm)
void setc(const Operand &op)
void align(size_t x=16, bool useMultiByteNop=true)
void jmp(const Operand &op)
void jge(const Label &label, LabelType type=T_AUTO)
void inc(const Operand &op)
void jne(const Label &label, LabelType type=T_AUTO)
void add(const Operand &op, uint32 imm)
void sub(const Operand &op, uint32 imm)
void neg(const Operand &op)
void adc(const Operand &op, uint32 imm)
void jz(const Label &label, LabelType type=T_AUTO)
void div(const Operand &op)
void mov(const Operand ®1, const Operand ®2)
void mul(const Operand &op)
void lea(const Reg ®, const Address &addr)
void jnz(const Label &label, LabelType type=T_AUTO)
void L(const std::string &label)
void dec(const Operand &op)
void sbb(const Operand &op, uint32 imm)
struct sysio::chain::eosvmoc::code_cache_header __attribute__((packed))
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
unsigned __int64 uint64_t
static Unit(* div1)(Unit *q, const Unit *x, size_t n, Unit y)
static bool(* sub1)(Unit *out, const Unit *x, size_t n, Unit y)
static bool(* add1)(Unit *out, const Unit *x, size_t n, Unit y)
static void(* mul1)(Unit *out, const Unit *x, size_t n, Unit y)
static Unit(* mod1)(const Unit *x, size_t n, Unit y)
static bool(* subN)(Unit *out, const Unit *x, const Unit *y, size_t n)
static bool(* addN)(Unit *out, const Unit *x, const Unit *y, size_t n)
Xbyak ; JIT assembler for x86(IA32)/x64 by C++.