[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86ATTAsmPrinter.h X86IntelAsmPrinter.cpp X86IntelAsmPrinter.h X86TargetAsmInfo.cpp X86TargetAsmInfo.h
Chris Lattner
sabre at nondot.org
Wed Oct 4 19:44:06 PDT 2006
Changes in directory llvm/lib/Target/X86:
X86ATTAsmPrinter.cpp updated: 1.65 -> 1.66
X86ATTAsmPrinter.h updated: 1.16 -> 1.17
X86IntelAsmPrinter.cpp updated: 1.58 -> 1.59
X86IntelAsmPrinter.h updated: 1.24 -> 1.25
X86TargetAsmInfo.cpp updated: 1.3 -> 1.4
X86TargetAsmInfo.h updated: 1.1 -> 1.2
---
Log message:
Implement getSectionForFunction, use it when printing function body.
---
Diffs of the changes: (+42 -16)
X86ATTAsmPrinter.cpp | 34 ++++++++++++++++++++++++----------
X86ATTAsmPrinter.h | 4 ++++
X86IntelAsmPrinter.cpp | 9 +++++++--
X86IntelAsmPrinter.h | 4 ++++
X86TargetAsmInfo.cpp | 5 +++--
X86TargetAsmInfo.h | 2 --
6 files changed, 42 insertions(+), 16 deletions(-)
Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.65 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.66
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.65 Mon Sep 25 22:57:53 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Wed Oct 4 21:43:52 2006
@@ -26,6 +26,28 @@
#include <iostream>
using namespace llvm;
+/// getSectionForFunction - Return the section that we should emit the
+/// specified function body into.
+std::string X86ATTAsmPrinter::getSectionForFunction(const Function &F) const {
+ switch (F.getLinkage()) {
+ default: assert(0 && "Unknown linkage type!");
+ case Function::InternalLinkage:
+ case Function::DLLExportLinkage:
+ case Function::ExternalLinkage:
+ return TAI->getTextSection();
+ case Function::WeakLinkage:
+ case Function::LinkOnceLinkage:
+ if (Subtarget->isTargetDarwin()) {
+ return ".section __TEXT,__textcoal_nt,coalesced,pure_instructions";
+ } else if (Subtarget->isTargetCygwin()) {
+ return "\t.section\t.llvm.linkonce.t." + CurrentFnName + ",\"ax\"\n";
+ } else {
+ return "\t.section\t.llvm.linkonce.t." + CurrentFnName +
+ ",\"ax\", at progbits\n";
+ }
+ }
+}
+
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
///
@@ -53,38 +75,30 @@
X86SharedAsmPrinter::decorateName(CurrentFnName, F);
+ SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
- SwitchToTextSection(TAI->getTextSection(), F);
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
break;
case Function::DLLExportLinkage:
DLLExportedFns.insert(Mang->makeNameProper(F->getName(), ""));
//FALLS THROUGH
case Function::ExternalLinkage:
- SwitchToTextSection(TAI->getTextSection(), F);
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
O << "\t.globl\t" << CurrentFnName << "\n";
break;
case Function::WeakLinkage:
case Function::LinkOnceLinkage:
if (Subtarget->isTargetDarwin()) {
- SwitchToTextSection(
- ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.weak_definition\t" << CurrentFnName << "\n";
} else if (Subtarget->isTargetCygwin()) {
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
- O << "\t.section\t.llvm.linkonce.t." << CurrentFnName
- << ",\"ax\"\n";
- SwitchToTextSection("", F);
O << "\t.weak " << CurrentFnName << "\n";
} else {
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
- O << "\t.section\t.llvm.linkonce.t." << CurrentFnName
- << ",\"ax\", at progbits\n";
- SwitchToTextSection("", F);
O << "\t.weak " << CurrentFnName << "\n";
}
break;
Index: llvm/lib/Target/X86/X86ATTAsmPrinter.h
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.16 llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.17
--- llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.16 Fri Sep 8 01:48:29 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.h Wed Oct 4 21:43:52 2006
@@ -76,6 +76,10 @@
const char *Modifier=NULL);
void printPICLabel(const MachineInstr *MI, unsigned Op);
bool runOnMachineFunction(MachineFunction &F);
+
+ /// getSectionForFunction - Return the section that we should emit the
+ /// specified function body into.
+ virtual std::string getSectionForFunction(const Function &F) const;
};
} // end namespace llvm
Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.58 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.59
--- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.58 Mon Sep 25 22:57:53 2006
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Wed Oct 4 21:43:52 2006
@@ -25,6 +25,11 @@
#include "llvm/Target/TargetOptions.h"
using namespace llvm;
+std::string X86IntelAsmPrinter::getSectionForFunction(const Function &F) const {
+ // Intel asm always emits functions to _text.
+ return "_text";
+}
+
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
///
@@ -46,10 +51,11 @@
X86SharedAsmPrinter::decorateName(CurrentFnName, F);
+ SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+
switch (F->getLinkage()) {
default: assert(0 && "Unsupported linkage type!");
case Function::InternalLinkage:
- SwitchToTextSection("_text", F);
EmitAlignment(4);
break;
case Function::DLLExportLinkage:
@@ -57,7 +63,6 @@
//FALLS THROUGH
case Function::ExternalLinkage:
O << "\tpublic " << CurrentFnName << "\n";
- SwitchToTextSection("_text", F);
EmitAlignment(4);
break;
}
Index: llvm/lib/Target/X86/X86IntelAsmPrinter.h
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.24 llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.25
--- llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.24 Fri Sep 8 01:48:29 2006
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.h Wed Oct 4 21:43:52 2006
@@ -99,6 +99,10 @@
bool runOnMachineFunction(MachineFunction &F);
bool doInitialization(Module &M);
bool doFinalization(Module &M);
+
+ /// getSectionForFunction - Return the section that we should emit the
+ /// specified function body into.
+ virtual std::string getSectionForFunction(const Function &F) const;
virtual void EmitString(const ConstantArray *CVA) const;
};
Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp
diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.3 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.4
--- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.3 Mon Sep 25 22:39:53 2006
+++ llvm/lib/Target/X86/X86TargetAsmInfo.cpp Wed Oct 4 21:43:52 2006
@@ -20,7 +20,7 @@
X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
- //FIXME - Should to be simplified.
+ // FIXME - Should be simplified.
switch (Subtarget->TargetType) {
case X86Subtarget::isDarwin:
@@ -31,7 +31,7 @@
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
ConstantPoolSection = "\t.const\n";
- JumpTableDataSection = "\t.const\n"; // FIXME: depends on PIC mode
+ JumpTableDataSection = "\t.const\n";
FourByteConstantSection = "\t.literal4\n";
EightByteConstantSection = "\t.literal8\n";
if (Subtarget->is64Bit())
@@ -97,3 +97,4 @@
SectionEndDirectiveSuffix = "\tends\n";
}
}
+
Index: llvm/lib/Target/X86/X86TargetAsmInfo.h
diff -u llvm/lib/Target/X86/X86TargetAsmInfo.h:1.1 llvm/lib/Target/X86/X86TargetAsmInfo.h:1.2
--- llvm/lib/Target/X86/X86TargetAsmInfo.h:1.1 Thu Sep 7 17:05:02 2006
+++ llvm/lib/Target/X86/X86TargetAsmInfo.h Wed Oct 4 21:43:52 2006
@@ -24,8 +24,6 @@
struct X86TargetAsmInfo : public TargetAsmInfo {
X86TargetAsmInfo(const X86TargetMachine &TM);
};
-
-
} // namespace llvm
#endif
More information about the llvm-commits
mailing list