use MemOperand instead of Reg32e

This commit is contained in:
MITSUNARI Shigeo 2013-06-11 20:41:37 +09:00
parent 209ada4b10
commit 0fe89e3df9
3 changed files with 24 additions and 9 deletions

View file

@ -37,8 +37,12 @@ private:
size_t constTblPos_;
int regIdx_;
Map varMap_; // map var name to index
const Xbyak::Reg32e& valTbl_;
const Xbyak::Reg32e& tbl_;
const Xbyak::MemOperand& valTbl_;
#ifdef XBYAK32
const Xbyak::Reg32& tbl_;
#else
const Xbyak::Reg64& tbl_;
#endif
public:
/*
@param y [out] the value of f(var)
@ -80,7 +84,7 @@ public:
if (constTblPos_ >= MAX_CONST_NUM) throw;
constTbl_[constTblPos_] = n;
if (regIdx_ == 7) throw;
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + constTblPos_ * sizeof(double)]);
movsd(Xbyak::Xmm(++regIdx_), ptr[tbl_ + constTblPos_ * (int)sizeof(double)]);
constTblPos_++;
}
// use eax

View file

@ -1,6 +1,5 @@
/*
@author herumi
@date $Date: 2010/11/17 11:58:06 $
tiny calculator 2
This program generates a function to calc the value of
@ -106,9 +105,13 @@ private:
size_t constTblPos_;
int regIdx_;
#ifdef XBYAK32
const Xbyak::Reg32e& varTbl_;
const Xbyak::MemOperand& varTbl_;
#endif
#ifdef XBYAK32
const Xbyak::Reg32& tbl_;
#else
const Xbyak::Reg64& tbl_;
#endif
const Xbyak::Reg32e& tbl_;
public:
/*
double jit(double x);
@ -116,7 +119,7 @@ public:
64bit: x [rcx](win), xmm0(gcc), return xmm0
*/
Jit()
: negConst_(0x8000000000000000ULL)
: negConst_(Xbyak::uint64(1) << 63)
, constTblPos_(0)
, regIdx_(-1)
#ifdef XBYAK32
@ -290,7 +293,7 @@ int main(int argc, char *argv[])
return 1;
}
parserJit.code_.complete();
double (*jit)(double) = (double (*)(double))parserJit.code_.getCode();
double (*jit)(double) = parserJit.code_.getCode<double (*)(double)>();
Test("VM ", vm);
Test("JIT", jit);

View file

@ -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; }
};
#ifdef _MSC_VER
#pragma warning(disable : 4510 4512 4610)
#endif
struct Code : public Xbyak::CodeGenerator {
Code()
{
@ -25,7 +29,11 @@ struct Code : public Xbyak::CodeGenerator {
#endif
#endif
const struct {
const Reg32e& self;
#ifdef XBYAK32
const Reg32& self;
#else
const Reg64& self;
#endif
const Operand& a;
const Operand& b;
const Operand& c;