void TR_Debug::print(TR::FILE *pOutFile, TR::X86FPConvertToIntSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); TR::RealRegister *targetRegister = toRealRegister(snippet->getConvertInstruction()->getTargetRegister()); uint8_t reg = targetRegister->getRegisterNumber(); if (reg != TR::RealRegister::eax) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, targetRegister, TR_WordReg); trfprintf(pOutFile, ", eax\t\t%s preserve helper return reg", commentString()); bufferPos += 2; } printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "sub\tesp, 4\t\t%s push parameter", commentString()); bufferPos += 3; TR::X86RegRegInstruction *instr = snippet->getConvertInstruction()->getIA32RegRegInstruction(); if (instr) { printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movss\t dword ptr [esp], "); print(pOutFile, toRealRegister(instr->getSourceRegister()), TR_QuadWordReg); bufferPos += 5; } else { printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "fst\tdword ptr [esp]"); bufferPos += 3; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "add\tesp, 4\t\t%s pop parameter", commentString()); bufferPos += 3; if (reg != TR::RealRegister::eax) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "xchg\teax, "); print(pOutFile, targetRegister, TR_WordReg); trfprintf(pOutFile, "\t\t%s restore eax", commentString()); bufferPos++; } printRestartJump(pOutFile, snippet, bufferPos); }
void TR_Debug::print(TR::FILE *pOutFile, TR::X86FPConvertToLongSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); uint8_t action = TR::X86FPConvertToLongSnippet::_registerActions[snippet->getAction() & 0x7f ]; printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); if (snippet->getAction() & snippet->kNeedFXCH) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "fxch\t"); print(pOutFile, snippet->getDoubleRegister(), TR_FloatReg); trfprintf(pOutFile, "\t\t%s register to convert", commentString()); bufferPos += 2; } if (action & snippet->kPreserveEAX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "push\teax\t\t%s preserve eax", commentString()); bufferPos++; } if (action & snippet->kPreserveEDX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "push\tedx\t\t%s preserve eax", commentString()); bufferPos++; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; if (action & snippet->kMOVLow) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, snippet->getLowRegister(), TR_WordReg); trfprintf(pOutFile, ", eax\t%s result register (low)", commentString()); bufferPos += 2; } if (action & snippet->kMOVHigh) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, snippet->getHighRegister(), TR_WordReg); trfprintf(pOutFile, ", edx\t%s result register (high)", commentString()); bufferPos += 2; } if (action & snippet->kXCHG) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "xchg\teax, edx"); bufferPos += 1; } if (action & snippet->kPreserveEDX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "pop\tedx\t\t%s restore edx", commentString()); bufferPos += 1; } if (action & snippet->kPreserveEAX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "pop\teax\t\t%s restore eax", commentString()); bufferPos += 1; } if (snippet->getAction() & snippet->kNeedFXCH) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "fxch\t"); print(pOutFile, snippet->getDoubleRegister(), TR_FloatReg); bufferPos += 2; } printRestartJump(pOutFile, snippet, bufferPos); }
void TR_Debug::print(TR::FILE *pOutFile, TR::AMD64FPConversionSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); TR::Machine *machine = _cg->machine(); TR::RealRegister *sourceRegister = toRealRegister(snippet->getConvertInstruction()->getSourceRegister()); TR::RealRegister *targetRegister = toRealRegister(snippet->getConvertInstruction()->getTargetRegister()); uint8_t sreg = sourceRegister->getRegisterNumber(); uint8_t treg = targetRegister->getRegisterNumber(); TR::ILOpCodes opCode = snippet->getConvertInstruction()->getNode()->getOpCodeValue(); TR_RegisterSizes size = TR_DoubleWordReg; if (treg != TR::RealRegister::eax) { int instrSize = IS_REX(*bufferPos)? 3 : 2; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "mov \t"); print(pOutFile, targetRegister, size); trfprintf(pOutFile, ", "); print(pOutFile, machine->getX86RealRegister(TR::RealRegister::eax), size); trfprintf(pOutFile, "\t%s preserve helper return reg", commentString()); bufferPos += instrSize; } if (sreg != TR::RealRegister::xmm0) { printPrefix(pOutFile, NULL, bufferPos, 4); trfprintf(pOutFile, "sub \trsp, 8"); printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movsd\t[rsp], xmm0\t%s save xmm0", commentString()); bufferPos += 9; int instrSize = IS_REX(*bufferPos)? 5 : 4; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "movsd\txmm0, "); print(pOutFile, sourceRegister, TR_QuadWordReg); trfprintf(pOutFile, "\t%s load parameter", commentString()); bufferPos += instrSize; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; if (sreg != TR::RealRegister::xmm0) { printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movsd\txmm0, [rsp]\t%s restore xmm0", commentString()); printPrefix(pOutFile, NULL, bufferPos, 4); trfprintf(pOutFile, "add \trsp, 8"); bufferPos += 9; } if (treg != TR::RealRegister::eax) { int instrSize = IS_REX(*bufferPos)? 2 : 1; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "xchg\t"); print(pOutFile, targetRegister, size); trfprintf(pOutFile, ", "); print(pOutFile, machine->getX86RealRegister(TR::RealRegister::eax), size); trfprintf(pOutFile, "\t%s restore result reg & put result in target reg", commentString()); bufferPos += instrSize; } printRestartJump(pOutFile, snippet, bufferPos); }