2007-06-06 15:42:06 +08:00
|
|
|
//===-- MipsTargetAsmInfo.cpp - Mips asm properties -------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the declarations of the MipsTargetAsmInfo properties.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MipsTargetAsmInfo.h"
|
2007-11-13 03:49:57 +08:00
|
|
|
#include "MipsTargetMachine.h"
|
2008-08-05 23:32:23 +08:00
|
|
|
#include "llvm/GlobalVariable.h"
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2008-07-19 21:16:11 +08:00
|
|
|
MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
|
|
|
|
ELFTargetAsmInfo(TM) {
|
2008-07-14 22:42:54 +08:00
|
|
|
|
2008-07-24 00:01:50 +08:00
|
|
|
Subtarget = &TM.getSubtarget<MipsSubtarget>();
|
2008-07-22 23:34:27 +08:00
|
|
|
|
2008-07-14 22:42:54 +08:00
|
|
|
AlignmentIsInBytes = false;
|
|
|
|
COMMDirectiveTakesAlignment = true;
|
|
|
|
Data16bitsDirective = "\t.half\t";
|
|
|
|
Data32bitsDirective = "\t.word\t";
|
|
|
|
Data64bitsDirective = NULL;
|
|
|
|
PrivateGlobalPrefix = "$";
|
|
|
|
JumpTableDataSection = "\t.rdata";
|
|
|
|
CommentString = "#";
|
|
|
|
ReadOnlySection = "\t.rdata";
|
|
|
|
ZeroDirective = "\t.space\t";
|
|
|
|
BSSSection = "\t.section\t.bss";
|
2008-07-22 02:52:34 +08:00
|
|
|
CStringSection = ".rodata.str";
|
2007-11-13 03:49:57 +08:00
|
|
|
|
2008-07-24 00:01:50 +08:00
|
|
|
if (!Subtarget->hasABICall()) {
|
2007-11-13 03:49:57 +08:00
|
|
|
JumpTableDirective = "\t.word\t";
|
2008-07-24 00:01:50 +08:00
|
|
|
SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable);
|
|
|
|
SmallBSSSection = getNamedSection("\t.sbss", SectionFlags::Writeable |
|
|
|
|
SectionFlags::BSS);
|
|
|
|
} else
|
2007-11-13 03:49:57 +08:00
|
|
|
JumpTableDirective = "\t.gpword\t";
|
2008-07-24 00:01:50 +08:00
|
|
|
|
2008-07-22 23:34:27 +08:00
|
|
|
}
|
|
|
|
|
2008-07-31 01:04:04 +08:00
|
|
|
unsigned MipsTargetAsmInfo::
|
|
|
|
SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
|
|
|
|
unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
|
|
|
|
// Mask out Small Section flag bit, Mips doesnt support 's' section symbol
|
|
|
|
// for its small sections.
|
|
|
|
return (Flags & (~SectionFlags::Small));
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionKind::Kind MipsTargetAsmInfo::
|
|
|
|
SectionKindForGlobal(const GlobalValue *GV) const {
|
2008-07-23 00:24:21 +08:00
|
|
|
SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
|
|
|
|
|
2008-07-24 00:01:50 +08:00
|
|
|
if (Subtarget->hasABICall())
|
|
|
|
return K;
|
|
|
|
|
2008-08-07 17:51:54 +08:00
|
|
|
if (K != SectionKind::Data && K != SectionKind::BSS &&
|
2008-07-23 00:24:21 +08:00
|
|
|
K != SectionKind::RODataMergeConst)
|
|
|
|
return K;
|
|
|
|
|
|
|
|
if (isa<GlobalVariable>(GV)) {
|
|
|
|
const TargetData *TD = ETM->getTargetData();
|
|
|
|
unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
|
2008-07-24 00:01:50 +08:00
|
|
|
unsigned Threshold = Subtarget->getSSectionThreshold();
|
2008-08-07 17:51:54 +08:00
|
|
|
|
2008-07-23 00:24:21 +08:00
|
|
|
if (Size > 0 && Size <= Threshold) {
|
|
|
|
if (K == SectionKind::BSS)
|
|
|
|
return SectionKind::SmallBSS;
|
|
|
|
else
|
|
|
|
return SectionKind::SmallData;
|
|
|
|
}
|
2008-07-22 23:34:27 +08:00
|
|
|
}
|
|
|
|
|
2008-07-23 00:24:21 +08:00
|
|
|
return K;
|
2008-07-22 23:34:27 +08:00
|
|
|
}
|
|
|
|
|
2008-07-31 01:04:04 +08:00
|
|
|
const Section* MipsTargetAsmInfo::
|
2008-08-09 01:56:50 +08:00
|
|
|
SelectSectionForGlobal(const GlobalValue *GV) const {
|
2008-07-22 23:34:27 +08:00
|
|
|
SectionKind::Kind K = SectionKindForGlobal(GV);
|
|
|
|
const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
|
|
|
|
|
|
|
|
if (GVA && (!GVA->isWeakForLinker()))
|
|
|
|
switch (K) {
|
|
|
|
case SectionKind::SmallData:
|
|
|
|
return getSmallDataSection();
|
|
|
|
case SectionKind::SmallBSS:
|
|
|
|
return getSmallBSSSection();
|
|
|
|
default: break;
|
|
|
|
}
|
2007-11-13 03:49:57 +08:00
|
|
|
|
2008-07-22 23:34:27 +08:00
|
|
|
return ELFTargetAsmInfo::SelectSectionForGlobal(GV);
|
2007-06-06 15:42:06 +08:00
|
|
|
}
|