浮点堆栈操作
floating-point stack operation
我必须阅读一个综合基准的程序。我不熟悉浮点堆栈。代码如下。下面的代码是在for statement.I 中不要写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();
}
有人可以给我教程或 link 教浮点堆栈吗?另外,我想知道上面的代码做了什么以及为什么它必须执行上面的操作。
我必须阅读一个综合基准的程序。我不熟悉浮点堆栈。代码如下。下面的代码是在for statement.I 中不要写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();
}
有人可以给我教程或 link 教浮点堆栈吗?另外,我想知道上面的代码做了什么以及为什么它必须执行上面的操作。