[llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Mon Jul 7 13:35:01 PDT 2003
Changes in directory llvm/lib/Target/X86:
Printer.cpp updated: 1.41 -> 1.42
---
Log message:
Insert workaround for GAS bug in assembling FLD/FSTP XWORD PTR [...]
instructions, by outputting them as bytes.
---
Diffs of the changes:
Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.41 llvm/lib/Target/X86/Printer.cpp:1.42
--- llvm/lib/Target/X86/Printer.cpp:1.41 Thu Jun 26 19:00:46 2003
+++ llvm/lib/Target/X86/Printer.cpp Mon Jul 7 13:34:20 2003
@@ -1,7 +1,7 @@
//===-- X86/Printer.cpp - Convert X86 code to human readable rep. ---------===//
//
// This file contains a printer that converts from our internal representation
-// of LLVM code to a nice human readable form that is suitable for debuggging.
+// of LLVM code to a nice human readable form that is suitable for debugging.
//
//===----------------------------------------------------------------------===//
@@ -819,7 +819,36 @@
isMem(MI, 0) && "Bad MRMSxM format!");
assert((MI->getNumOperands() != 5 || MI->getOperand(4).isImmediate()) &&
"Bad MRMSxM format!");
-
+ // Work around GNU assembler bugs in FSTP and FLD.
+ if (MI->getOpCode() == X86::FSTPr80) {
+ if ((MI->getOperand(0).getReg() == X86::ESP)
+ && (MI->getOperand(1).getImmedValue() == 1)) {
+ int DispVal = MI->getOperand(3).getImmedValue();
+ if ((DispVal < -128) || (DispVal > 127)) { // 4 byte disp.
+ unsigned int val = (unsigned int) DispVal;
+ O << ".byte 0xdb, 0xbc, 0x24\n\t";
+ O << ".long 0x" << std::hex << (unsigned) val << std::dec << "\t# ";
+ } else { // 1 byte disp.
+ unsigned char val = (unsigned char) DispVal;
+ O << ".byte 0xdb, 0x7c, 0x24, 0x" << std::hex << (unsigned) val
+ << std::dec << "\t# ";
+ }
+ }
+ } else if (MI->getOpCode() == X86::FLDr80) {
+ if ((MI->getOperand(0).getReg() == X86::ESP)
+ && (MI->getOperand(1).getImmedValue() == 1)) {
+ int DispVal = MI->getOperand(3).getImmedValue();
+ if ((DispVal < -128) || (DispVal > 127)) { // 4 byte disp.
+ unsigned int val = (unsigned int) DispVal;
+ O << ".byte 0xdb, 0xac, 0x24\n\t";
+ O << ".long 0x" << std::hex << (unsigned) val << std::dec << "\t# ";
+ } else { // 1 byte disp.
+ unsigned char val = (unsigned char) DispVal;
+ O << ".byte 0xdb, 0x6c, 0x24, 0x" << std::hex << (unsigned) val
+ << std::dec << "\t# ";
+ }
+ }
+ }
O << TII.getName(MI->getOpCode()) << " ";
O << sizePtr(Desc) << " ";
printMemReference(O, MI, 0, RI);
More information about the llvm-commits
mailing list