我必须阅读一个合成基准的程序。我不熟悉浮点堆栈。代码如下。以下代码位于for语句中。我不写for语句,因为它非常大。每个循环似乎都会修改FP堆栈,每个循环都必须在下一个循环开始之前恢复FP堆栈。
//since the synthetic will be run (probably) multiple times, the FP stack needs to be clear
if(floatStackSize > 6)
{
initializeFPStack();
floatStackSize = 0;
}
else
{
while(floatStackSize > 0)
{
adjustFPStack(floatStackSize);
floatStackSize = floatStackSize - 1;
}
}
initializeFPStack和adjustFPStack功能代码如下。
//initializeFPStack
void initializeFPStack(void) //needed
{
string fileName = outputFileName;
ofstream outputFile(fileName.c_str(), ios::app); //open a file for writing (append the current contents)
if(!outputFile) //check to be sure file is open
cout << "Error opening file.";
outputFile << " __asm__ __volatile__ (\"fninit " << "\");\n";
outputFile.close();
}
//adjustFPStack
void adjustFPStack(size_t floatStackSizE) //needed
{
string fileName = outputFileName;
ofstream outputFile(fileName.c_str(), ios::app); //open a file for writing (append the current contents)
if(!outputFile) //check to be sure file is open
cout << "Error opening file.";
outputFile << "\n __asm__ __volatile__ (\"fcomp " << "%st" << "\");\n";
outputFile.close();
}
有人可以给我一个教授浮点堆栈的教程或链接吗?另外,我想知道上面代码的作用以及它为什么要执行上述操作。