Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpu reg alloc #26

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
15 changes: 14 additions & 1 deletion include/Jitter_CodeGen_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,22 @@ namespace Jitter

//FPUOP AVX
template <typename> void Emit_Fpu_Avx_MemMem(const STATEMENT&);
template <typename> void Emit_Fpu_Avx_MemMemMem(const STATEMENT&);
template <typename> void Emit_Fpu_Avx_VarVarVar(const STATEMENT&);

void Emit_Fp_Avx_Neg_VarVar(const STATEMENT&);
void Emit_Fp_Avx_Abs_VarVar(const STATEMENT&);
void Emit_Fp_Avx_Mov_Reg32RelI32(const STATEMENT&);
void Emit_Fp_Avx_Mov_Reg128Rel(const STATEMENT&);

void Emit_Fp_Avx_Cmp_VarMemMem(const STATEMENT&);
void Emit_Fp_Avx_Rsqrt_MemMem(const STATEMENT&);
void Emit_Fp_Avx_Rcpl_MemMem(const STATEMENT&);
void Emit_Fp_Avx_Mov_RelSRelI32(const STATEMENT&);

void Emit_Fp_Avx_Mov_RelSReg(const STATEMENT&);
void Emit_Fp_Avx_Mov_RegSRelS(const STATEMENT&);
void Emit_Fp_Avx_Mov_RegSRelI32(const STATEMENT&);

void Emit_Fp_Avx_ToIntTrunc_RelRel(const STATEMENT&);

//MDOP AVX
Expand Down Expand Up @@ -770,6 +780,9 @@ namespace Jitter
CX86Assembler::XMMREGISTER PrepareSymbolRegisterDefMd(CSymbol*, CX86Assembler::XMMREGISTER);
CX86Assembler::XMMREGISTER PrepareSymbolRegisterUseMdAvx(CSymbol*, CX86Assembler::XMMREGISTER);
void CommitSymbolRegisterMdAvx(CSymbol*, CX86Assembler::XMMREGISTER);
CX86Assembler::XMMREGISTER PrepareSymbolRegisterDefFpu(CSymbol*, CX86Assembler::XMMREGISTER);
CX86Assembler::XMMREGISTER PrepareSymbolRegisterUseFpuAvx(CSymbol*, CX86Assembler::XMMREGISTER);
void CommitSymbolRegisterFpuAvx(CSymbol*, CX86Assembler::XMMREGISTER);

virtual CX86Assembler::REGISTER PrepareRefSymbolRegisterUse(CSymbol*, CX86Assembler::REGISTER) = 0;

Expand Down
3 changes: 3 additions & 0 deletions include/X86Assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class CX86Assembler
void VpshufbVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VpmovmskbVo(REGISTER, XMMREGISTER);

void VandpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VaddpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VsubpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VmulpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
Expand All @@ -454,6 +455,8 @@ class CX86Assembler
void VcmpltpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VcmpgtpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);

void VxorpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);

void VminpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);
void VmaxpsVo(XMMREGISTER, XMMREGISTER, const CAddress&);

Expand Down
63 changes: 63 additions & 0 deletions src/Jitter_CodeGen_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,3 +1342,66 @@ void CCodeGen_x86::CommitSymbolRegisterMdAvx(CSymbol* symbol, CX86Assembler::XMM
break;
}
}
CX86Assembler::XMMREGISTER CCodeGen_x86::PrepareSymbolRegisterDefFpu(CSymbol* symbol, CX86Assembler::XMMREGISTER preferedRegister)
{
switch(symbol->m_type)
{
case SYM_REGISTER128:
return m_mdRegisters[symbol->m_valueLow];
break;
case SYM_FP_REL_SINGLE:
case SYM_FP_TMP_SINGLE:
case SYM_TEMPORARY128:
case SYM_RELATIVE128:
return preferedRegister;
break;
default:
throw std::runtime_error("Invalid symbol type.");
break;
}
}

CX86Assembler::XMMREGISTER CCodeGen_x86::PrepareSymbolRegisterUseFpuAvx(CSymbol* symbol, CX86Assembler::XMMREGISTER preferedRegister)
{
switch(symbol->m_type)
{
case SYM_REGISTER128:
return m_mdRegisters[symbol->m_valueLow];
break;
case SYM_TEMPORARY128:
case SYM_RELATIVE128:
m_assembler.VmovssEd(preferedRegister, MakeMemory128SymbolAddress(symbol));
return preferedRegister;
break;
case SYM_FP_REL_INT32:
case SYM_FP_REL_SINGLE:
case SYM_FP_TMP_SINGLE:
m_assembler.VmovssEd(preferedRegister, MakeMemoryFpSingleSymbolAddress(symbol));
return preferedRegister;
break;
default:
throw std::runtime_error("Invalid symbol type.");
break;
}
}

void CCodeGen_x86::CommitSymbolRegisterFpuAvx(CSymbol* symbol, CX86Assembler::XMMREGISTER usedRegister)
{
switch(symbol->m_type)
{
case SYM_REGISTER128:
assert(usedRegister == m_mdRegisters[symbol->m_valueLow]);
break;
case SYM_TEMPORARY128:
case SYM_RELATIVE128:
m_assembler.VmovssEd(MakeMemory128SymbolAddress(symbol), usedRegister);
break;
case SYM_FP_REL_SINGLE:
case SYM_FP_TMP_SINGLE:
m_assembler.VmovssEd(MakeMemoryFpSingleSymbolAddress(symbol), usedRegister);
break;
default:
throw std::runtime_error("Invalid symbol type.");
break;
}
}
1 change: 1 addition & 0 deletions src/Jitter_CodeGen_x86_Fpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CX86Assembler::CAddress CCodeGen_x86::MakeMemoryFpSingleSymbolAddress(CSymbol* s
{
switch(symbol->m_type)
{
case SYM_FP_REL_INT32:
case SYM_FP_REL_SINGLE:
return MakeRelativeFpSingleSymbolAddress(symbol);
break;
Expand Down
Loading