namespace llvm {
class GlobalValue;
class GlobalVariable;
+ class Type;
struct ELFTargetAsmInfo: public virtual TargetAsmInfo {
explicit ELFTargetAsmInfo(const TargetMachine &TM);
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;
};
#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"
assert(0 && "Unsupported global");
}
+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);
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 {