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