[llvm-commits] CVS: llvm/lib/Target/X86/Makefile Printer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Aug 11 14:36:03 PDT 2003
Changes in directory llvm/lib/Target/X86:
Makefile updated: 1.6 -> 1.7
Printer.cpp updated: 1.55 -> 1.56
---
Log message:
Add a new -enable-cygwin-compatible-output argument, which make the output more
consumably by the cygwin assembler. This is really just a nasty hack until we
get real target triple support.
---
Diffs of the changes:
Index: llvm/lib/Target/X86/Makefile
diff -u llvm/lib/Target/X86/Makefile:1.6 llvm/lib/Target/X86/Makefile:1.7
--- llvm/lib/Target/X86/Makefile:1.6 Mon Aug 11 10:30:20 2003
+++ llvm/lib/Target/X86/Makefile Mon Aug 11 14:35:26 2003
@@ -23,7 +23,7 @@
$(TBLGEN) $< -gen-instr-desc -o $@
X86GenInstrSelector.inc: X86.td X86InstrInfo.td ../Target.td $(TBLGEN)
- $(TBLGEN) $< -gen-instr-selector -o $@
+ $(TBLGEN) $< -debug -gen-instr-selector -o $@
clean::
$(VERB) rm -f *.inc
Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.55 llvm/lib/Target/X86/Printer.cpp:1.56
--- llvm/lib/Target/X86/Printer.cpp:1.55 Mon Aug 11 14:05:46 2003
+++ llvm/lib/Target/X86/Printer.cpp Mon Aug 11 14:35:26 2003
@@ -3,7 +3,7 @@
// This file contains a printer that converts from our internal
// representation of machine-dependent LLVM code to Intel-format
// assembly language. This printer is the output mechanism used
-// by `llc' and `lli -printmachineinstrs' on X86.
+// by `llc' and `lli -print-machineinstrs' on X86.
//
//===----------------------------------------------------------------------===//
@@ -20,8 +20,14 @@
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/Mangler.h"
#include "Support/StringExtras.h"
+#include "Support/CommandLine.h"
namespace {
+ // FIXME: This should be automatically picked up by autoconf from the C
+ // frontend
+ cl::opt<bool> EmitCygwin("enable-cygwin-compatible-output", cl::Hidden,
+ cl::desc("Emit X86 assembly code suitable for consumption by cygwin"));
+
struct Printer : public MachineFunctionPass {
/// Output stream on which we're printing assembly code.
///
@@ -399,7 +405,8 @@
O << "\t.text\n";
O << "\t.align 16\n";
O << "\t.globl\t" << CurrentFnName << "\n";
- O << "\t.type\t" << CurrentFnName << ", @function\n";
+ if (!EmitCygwin)
+ O << "\t.type\t" << CurrentFnName << ", @function\n";
O << CurrentFnName << ":\n";
// Number each basic block so that we can consistently refer to them
@@ -455,10 +462,11 @@
}
// FALLTHROUGH
case MachineOperand::MO_MachineRegister:
- if (MO.getReg() < MRegisterInfo::FirstVirtualRegister)
+ if (MO.getReg() < MRegisterInfo::FirstVirtualRegister) {
// Bug Workaround: See note in Printer::doInitialization about %.
- O << "%" << RI.get(MO.getReg()).Name;
- else
+ if (!EmitCygwin) O << "%";
+ O << RI.get(MO.getReg()).Name;
+ } else
O << "%reg" << MO.getReg();
return;
@@ -559,7 +567,7 @@
if (Desc.TSFlags & X86II::PrintImplUses) {
for (const unsigned *p = Desc.ImplicitUses; *p; ++p) {
// Bug Workaround: See note in Printer::doInitialization about %.
- O << ", %" << RI.get(*p).Name;
+ O << ", " << (EmitCygwin ? "" : "%") << RI.get(*p).Name;
}
}
}
@@ -903,20 +911,22 @@
}
}
-bool Printer::doInitialization(Module &M)
-{
- // Tell gas we are outputting Intel syntax (not AT&T syntax)
- // assembly.
+bool Printer::doInitialization(Module &M) {
+ // Tell gas we are outputting Intel syntax (not AT&T syntax) assembly.
+ //
+ // Bug: gas in `intel_syntax noprefix' mode interprets the symbol `Sp' in an
+ // instruction as a reference to the register named sp, and if you try to
+ // reference a symbol `Sp' (e.g. `mov ECX, OFFSET Sp') then it gets lowercased
+ // before being looked up in the symbol table. This creates spurious
+ // `undefined symbol' errors when linking. Workaround: Do not use `noprefix'
+ // mode, and decorate all register names with percent signs.
+ //
+ // Cygwin presumably doesn't have this problem, so drop the %'s.
//
- // Bug: gas in `intel_syntax noprefix' mode interprets the symbol
- // `Sp' in an instruction as a reference to the register named sp,
- // and if you try to reference a symbol `Sp' (e.g. `mov ECX, OFFSET
- // Sp') then it gets lowercased before being looked up in the symbol
- // table. This creates spurious `undefined symbol' errors when
- // linking. Workaround: Do not use `noprefix' mode, and decorate all
- // register names with percent signs.
- O << "\t.intel_syntax\n";
- Mang = new Mangler(M);
+ O << "\t.intel_syntax";
+ if (EmitCygwin) O << " noprefix";
+ O << "\n";
+ Mang = new Mangler(M, EmitCygwin);
return false; // success
}
More information about the llvm-commits
mailing list