[llvm-commits] [llvm] r78498 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/Sparc/SparcISelLowering.cpp lib/Target/Sparc/SparcTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/TargetLoweringObjectFile.cpp
Chris Lattner
sabre at nondot.org
Sat Aug 8 13:43:12 PDT 2009
Author: lattner
Date: Sat Aug 8 15:43:12 2009
New Revision: 78498
URL: http://llvm.org/viewvc/llvm-project?rev=78498&view=rev
Log:
eliminate TargetLoweringObjectFileSparc in favor of a TAI hook.
A TAI hook is appropriate in this case because this is just an
asm syntax issue, not a semantic difference. TLOF should model
the semantics of the section.
Modified:
llvm/trunk/include/llvm/Target/TargetAsmInfo.h
llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Sat Aug 8 15:43:12 2009
@@ -158,6 +158,11 @@
return NULL;
}
+ /// SunStyleELFSectionSwitchSyntax - This is true if this target uses "Sun
+ /// Style" syntax for section switching ("#alloc,#write" etc) instead of the
+ /// normal ELF syntax (,"a,w") in .section directives.
+ bool SunStyleELFSectionSwitchSyntax; // Defaults to false.
+
//===--- Alignment Information ----------------------------------------===//
/// AlignDirective - The directive used to emit round up to an alignment
@@ -326,6 +331,11 @@
return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
}
+
+ bool usesSunStyleELFSectionSwitchSyntax() const {
+ return SunStyleELFSectionSwitchSyntax;
+ }
+
// Accessors.
//
Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Sat Aug 8 15:43:12 2009
@@ -25,6 +25,7 @@
class GlobalValue;
class Mangler;
class TargetMachine;
+ class TargetAsmInfo;
class TargetLoweringObjectFile {
MCContext *Ctx;
@@ -172,7 +173,8 @@
/// into a string that can be printed to the assembly file after the
/// ".section foo" part of a section directive.
virtual void getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const {
+ SmallVectorImpl<char> &Str,
+ const TargetAsmInfo &TAI) const {
}
protected:
@@ -229,7 +231,8 @@
Mangler *Mang, const TargetMachine &TM) const;
void getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const;
+ SmallVectorImpl<char> &Str,
+ const TargetAsmInfo &TAI) const;
virtual const MCSection *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
@@ -286,7 +289,8 @@
Mangler *Mang, const TargetMachine &TM) const;
virtual void getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const;
+ SmallVectorImpl<char> &Str,
+ const TargetAsmInfo &TAI) const;
virtual const MCSection *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Aug 8 15:43:12 2009
@@ -99,7 +99,7 @@
// some magic assembler directive.
if (!NS->isDirective()) {
SmallString<32> FlagsStr;
- getObjFileLowering().getSectionFlagsAsString(NS->getKind(), FlagsStr);
+ getObjFileLowering().getSectionFlagsAsString(NS->getKind(), FlagsStr, *TAI);
O << TAI->getSwitchToSectionDirective()
<< CurrentSection->getName() << FlagsStr.c_str() << '\n';
Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Sat Aug 8 15:43:12 2009
@@ -549,34 +549,8 @@
}
}
-namespace {
-
-class TargetLoweringObjectFileSparc : public TargetLoweringObjectFileELF {
-public:
- void getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const {
- if (Kind.isMergeableConst() || Kind.isMergeableCString())
- return TargetLoweringObjectFileELF::getSectionFlagsAsString(Kind, Str);
-
- // FIXME: Inefficient.
- std::string Res;
- if (!Kind.isMetadata())
- Res += ",#alloc";
- if (Kind.isText())
- Res += ",#execinstr";
- if (Kind.isWriteable())
- Res += ",#write";
- if (Kind.isThreadLocal())
- Res += ",#tls";
-
- Str.append(Res.begin(), Res.end());
- }
-};
-
-}
-
SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
- : TargetLowering(TM, new TargetLoweringObjectFileSparc()) {
+ : TargetLowering(TM, new TargetLoweringObjectFileELF()) {
// Set up the register classes.
addRegisterClass(MVT::i32, SP::IntRegsRegisterClass);
Modified: llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcTargetAsmInfo.cpp Sat Aug 8 15:43:12 2009
@@ -22,6 +22,8 @@
ZeroDirective = "\t.skip\t";
CommentString = "!";
COMMDirectiveTakesAlignment = true;
+
+ SunStyleELFSectionSwitchSyntax = true;
}
Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Sat Aug 8 15:43:12 2009
@@ -49,6 +49,7 @@
Data16bitsDirective = "\t.short\t";
Data32bitsDirective = "\t.long\t";
Data64bitsDirective = "\t.quad\t";
+ SunStyleELFSectionSwitchSyntax = false;
AlignDirective = "\t.align\t";
AlignmentIsInBytes = true;
TextAlignFillValue = 0;
Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78498&r1=78497&r2=78498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Aug 8 15:43:12 2009
@@ -18,8 +18,9 @@
#include "llvm/GlobalVariable.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSection.h"
-#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/StringExtras.h"
@@ -407,7 +408,25 @@
void TargetLoweringObjectFileELF::
-getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str) const {
+getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str,
+ const TargetAsmInfo &TAI) const {
+ // Handle the weird solaris syntax if desired.
+ if (TAI.usesSunStyleELFSectionSwitchSyntax() &&
+ !Kind.isMergeableConst() && !Kind.isMergeableCString()) {
+ // FIXME: Inefficient.
+ std::string Res;
+ if (!Kind.isMetadata())
+ Res += ",#alloc";
+ if (Kind.isText())
+ Res += ",#execinstr";
+ if (Kind.isWriteable())
+ Res += ",#write";
+ if (Kind.isThreadLocal())
+ Res += ",#tls";
+ Str.append(Res.begin(), Res.end());
+ return;
+ }
+
Str.push_back(',');
Str.push_back('"');
@@ -848,7 +867,8 @@
void TargetLoweringObjectFileCOFF::
-getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str) const {
+getSectionFlagsAsString(SectionKind Kind, SmallVectorImpl<char> &Str,
+ const TargetAsmInfo &TAI) const {
// FIXME: Inefficient.
std::string Res = ",\"";
if (Kind.isText())
More information about the llvm-commits
mailing list