mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 17:31:33 +00:00
When generating code for X86 targets, make sure the fp control word is set
to 64-bit precision, not 80 bits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f7d4f10a0d
commit
395fd5949b
@ -214,6 +214,7 @@ namespace {
|
|||||||
unsigned Indent);
|
unsigned Indent);
|
||||||
void printIndexingExpression(Value *Ptr, gep_type_iterator I,
|
void printIndexingExpression(Value *Ptr, gep_type_iterator I,
|
||||||
gep_type_iterator E);
|
gep_type_iterator E);
|
||||||
|
void printCodeForMain();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,6 +1128,9 @@ void CWriter::printFunction(Function &F) {
|
|||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
|
if (F.hasExternalLinkage() && F.getName() == "main")
|
||||||
|
printCodeForMain();
|
||||||
|
|
||||||
// print the basic blocks
|
// print the basic blocks
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
||||||
if (Loop *L = LI->getLoopFor(BB)) {
|
if (Loop *L = LI->getLoopFor(BB)) {
|
||||||
@ -1140,6 +1144,15 @@ void CWriter::printFunction(Function &F) {
|
|||||||
Out << "}\n\n";
|
Out << "}\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWriter::printCodeForMain() {
|
||||||
|
// On X86, set the FP control word to 64-bits of precision instead of 80 bits.
|
||||||
|
Out << "#if defined(__GNUC__) && !defined(__llvm__)\n"
|
||||||
|
<< "#if defined(i386) || defined(__i386__) || defined(__i386)\n"
|
||||||
|
<< "{short FPCW;__asm__ (\"fnstcw %0\" : \"=m\" (*&FPCW));\n"
|
||||||
|
<< "FPCW=(FPCW&~0x300)|0x200;__asm__(\"fldcw %0\" :: \"m\" (*&FPCW));}\n"
|
||||||
|
<< "#endif\n#endif\n";
|
||||||
|
}
|
||||||
|
|
||||||
void CWriter::printLoop(Loop *L) {
|
void CWriter::printLoop(Loop *L) {
|
||||||
Out << " do { /* Syntactic loop '" << L->getHeader()->getName()
|
Out << " do { /* Syntactic loop '" << L->getHeader()->getName()
|
||||||
<< "' to make GCC happy */\n";
|
<< "' to make GCC happy */\n";
|
||||||
|
@ -214,6 +214,7 @@ namespace {
|
|||||||
unsigned Indent);
|
unsigned Indent);
|
||||||
void printIndexingExpression(Value *Ptr, gep_type_iterator I,
|
void printIndexingExpression(Value *Ptr, gep_type_iterator I,
|
||||||
gep_type_iterator E);
|
gep_type_iterator E);
|
||||||
|
void printCodeForMain();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,6 +1128,9 @@ void CWriter::printFunction(Function &F) {
|
|||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
|
if (F.hasExternalLinkage() && F.getName() == "main")
|
||||||
|
printCodeForMain();
|
||||||
|
|
||||||
// print the basic blocks
|
// print the basic blocks
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
||||||
if (Loop *L = LI->getLoopFor(BB)) {
|
if (Loop *L = LI->getLoopFor(BB)) {
|
||||||
@ -1140,6 +1144,15 @@ void CWriter::printFunction(Function &F) {
|
|||||||
Out << "}\n\n";
|
Out << "}\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWriter::printCodeForMain() {
|
||||||
|
// On X86, set the FP control word to 64-bits of precision instead of 80 bits.
|
||||||
|
Out << "#if defined(__GNUC__) && !defined(__llvm__)\n"
|
||||||
|
<< "#if defined(i386) || defined(__i386__) || defined(__i386)\n"
|
||||||
|
<< "{short FPCW;__asm__ (\"fnstcw %0\" : \"=m\" (*&FPCW));\n"
|
||||||
|
<< "FPCW=(FPCW&~0x300)|0x200;__asm__(\"fldcw %0\" :: \"m\" (*&FPCW));}\n"
|
||||||
|
<< "#endif\n#endif\n";
|
||||||
|
}
|
||||||
|
|
||||||
void CWriter::printLoop(Loop *L) {
|
void CWriter::printLoop(Loop *L) {
|
||||||
Out << " do { /* Syntactic loop '" << L->getHeader()->getName()
|
Out << " do { /* Syntactic loop '" << L->getHeader()->getName()
|
||||||
<< "' to make GCC happy */\n";
|
<< "' to make GCC happy */\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user