use MemOperand instead of Reg32e
This commit is contained in:
parent
209ada4b10
commit
0fe89e3df9
3 changed files with 24 additions and 9 deletions
|
@ -37,8 +37,12 @@ private:
|
||||||
size_t constTblPos_;
|
size_t constTblPos_;
|
||||||
int regIdx_;
|
int regIdx_;
|
||||||
Map varMap_; // map var name to index
|
Map varMap_; // map var name to index
|
||||||
const Xbyak::Reg32e& valTbl_;
|
const Xbyak::MemOperand& valTbl_;
|
||||||
const Xbyak::Reg32e& tbl_;
|
#ifdef XBYAK32
|
||||||
|
const Xbyak::Reg32& tbl_;
|
||||||
|
#else
|
||||||
|
const Xbyak::Reg64& tbl_;
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
@param y [out] the value of f(var)
|
@param y [out] the value of f(var)
|
||||||
|
@ -80,7 +84,7 @@ public:
|
||||||
if (constTblPos_ >= MAX_CONST_NUM) throw;
|
if (constTblPos_ >= MAX_CONST_NUM) throw;
|
||||||
constTbl_[constTblPos_] = n;
|
constTbl_[constTblPos_] = n;
|
||||||
if (regIdx_ == 7) throw;
|
if (regIdx_ == 7) throw;
|
||||||
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + constTblPos_ * sizeof(double)]);
|
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + constTblPos_ * (int)sizeof(double)]);
|
||||||
constTblPos_++;
|
constTblPos_++;
|
||||||
}
|
}
|
||||||
// use eax
|
// use eax
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
@author herumi
|
@author herumi
|
||||||
@date $Date: 2010/11/17 11:58:06 $
|
|
||||||
|
|
||||||
tiny calculator 2
|
tiny calculator 2
|
||||||
This program generates a function to calc the value of
|
This program generates a function to calc the value of
|
||||||
|
@ -106,9 +105,13 @@ private:
|
||||||
size_t constTblPos_;
|
size_t constTblPos_;
|
||||||
int regIdx_;
|
int regIdx_;
|
||||||
#ifdef XBYAK32
|
#ifdef XBYAK32
|
||||||
const Xbyak::Reg32e& varTbl_;
|
const Xbyak::MemOperand& varTbl_;
|
||||||
|
#endif
|
||||||
|
#ifdef XBYAK32
|
||||||
|
const Xbyak::Reg32& tbl_;
|
||||||
|
#else
|
||||||
|
const Xbyak::Reg64& tbl_;
|
||||||
#endif
|
#endif
|
||||||
const Xbyak::Reg32e& tbl_;
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
double jit(double x);
|
double jit(double x);
|
||||||
|
@ -116,7 +119,7 @@ public:
|
||||||
64bit: x [rcx](win), xmm0(gcc), return xmm0
|
64bit: x [rcx](win), xmm0(gcc), return xmm0
|
||||||
*/
|
*/
|
||||||
Jit()
|
Jit()
|
||||||
: negConst_(0x8000000000000000ULL)
|
: negConst_(Xbyak::uint64(1) << 63)
|
||||||
, constTblPos_(0)
|
, constTblPos_(0)
|
||||||
, regIdx_(-1)
|
, regIdx_(-1)
|
||||||
#ifdef XBYAK32
|
#ifdef XBYAK32
|
||||||
|
@ -290,7 +293,7 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
parserJit.code_.complete();
|
parserJit.code_.complete();
|
||||||
double (*jit)(double) = (double (*)(double))parserJit.code_.getCode();
|
double (*jit)(double) = parserJit.code_.getCode<double (*)(double)>();
|
||||||
|
|
||||||
Test("VM ", vm);
|
Test("VM ", vm);
|
||||||
Test("JIT", jit);
|
Test("JIT", jit);
|
||||||
|
|
|
@ -9,6 +9,10 @@ struct A {
|
||||||
int func(int a, int b, int c, int d, int e) const { return x_ + y_ + a + b + c + d + e; }
|
int func(int a, int b, int c, int d, int e) const { return x_ + y_ + a + b + c + d + e; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4510 4512 4610)
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Code : public Xbyak::CodeGenerator {
|
struct Code : public Xbyak::CodeGenerator {
|
||||||
Code()
|
Code()
|
||||||
{
|
{
|
||||||
|
@ -25,7 +29,11 @@ struct Code : public Xbyak::CodeGenerator {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
const struct {
|
const struct {
|
||||||
const Reg32e& self;
|
#ifdef XBYAK32
|
||||||
|
const Reg32& self;
|
||||||
|
#else
|
||||||
|
const Reg64& self;
|
||||||
|
#endif
|
||||||
const Operand& a;
|
const Operand& a;
|
||||||
const Operand& b;
|
const Operand& b;
|
||||||
const Operand& c;
|
const Operand& c;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue