[llvm-commits] [llvm] r54448 - in /llvm/trunk: include/llvm/Target/ELFTargetAsmInfo.h include/llvm/Target/TargetAsmInfo.h lib/Target/ELFTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp
Anton Korobeynikov
asl at math.spbu.ru
Thu Aug 7 02:50:35 PDT 2008
Author: asl
Date: Thu Aug 7 04:50:34 2008
New Revision: 54448
URL: http://llvm.org/viewvc/llvm-project?rev=54448&view=rev
Log:
Select section for constant pool entries
Modified:
llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
llvm/trunk/include/llvm/Target/TargetAsmInfo.h
llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
Modified: llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h?rev=54448&r1=54447&r2=54448&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Thu Aug 7 04:50:34 2008
@@ -21,6 +21,7 @@
namespace llvm {
class GlobalValue;
class GlobalVariable;
+ class Type;
struct ELFTargetAsmInfo: public virtual TargetAsmInfo {
explicit ELFTargetAsmInfo(const TargetMachine &TM);
@@ -28,7 +29,10 @@
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
virtual std::string PrintSectionFlags(unsigned flags) const;
const Section* MergeableConstSection(const GlobalVariable *GV) const;
+ inline const Section* MergeableConstSection(const Type *Ty) const;
const Section* MergeableStringSection(const GlobalVariable *GV) const;
+ virtual const Section*
+ SelectSectionForMachineConst(const Type *Ty) const;
protected:
const TargetMachine* ETM;
};
Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=54448&r1=54447&r2=54448&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Aug 7 04:50:34 2008
@@ -76,6 +76,7 @@
class TargetMachine;
class CallInst;
class GlobalValue;
+ class Type;
class Section {
friend class TargetAsmInfo;
@@ -542,6 +543,8 @@
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
+ virtual const Section* SelectSectionForMachineConst(const Type *Ty) const;
+
// Accessors.
//
const char *getTextSection() const {
Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=54448&r1=54447&r2=54448&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Thu Aug 7 04:50:34 2008
@@ -17,6 +17,7 @@
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Target/ELFTargetAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetData.h"
@@ -90,15 +91,27 @@
}
const Section*
+ELFTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+ // FIXME: Support data.rel stuff someday
+ return MergeableConstSection(Ty);
+}
+
+const Section*
ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
- const TargetData *TD = ETM->getTargetData();
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
- const Type *Type = C->getType();
+ const Type *Ty = C->getType();
+
+ return MergeableConstSection(Ty);
+}
+
+inline const Section*
+ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
+ const TargetData *TD = ETM->getTargetData();
// FIXME: string here is temporary, until stuff will fully land in.
// We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's
// currently directly used by asmprinter.
- unsigned Size = TD->getABITypeSize(Type);
+ unsigned Size = TD->getABITypeSize(Ty);
if (Size == 4 || Size == 8 || Size == 16) {
std::string Name = ".rodata.cst" + utostr(Size);
Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=54448&r1=54447&r2=54448&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Aug 7 04:50:34 2008
@@ -321,6 +321,13 @@
return getDataSection_();
}
+// Lame default implementation. Calculate the section name for machine const.
+const Section*
+TargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+ // FIXME: Support data.rel stuff someday
+ return getDataSection_();
+}
+
std::string
TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind Kind) const {
More information about the llvm-commits
mailing list