1 //===-- MipsTargetAsmInfo.cpp - Mips asm properties -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declarations of the MipsTargetAsmInfo properties.
12 //===----------------------------------------------------------------------===//
14 #include "MipsTargetAsmInfo.h"
15 #include "MipsTargetMachine.h"
16 #include "llvm/GlobalVariable.h"
20 MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
21 ELFTargetAsmInfo(TM) {
23 Subtarget = &TM.getSubtarget<MipsSubtarget>();
25 AlignmentIsInBytes = false;
26 COMMDirectiveTakesAlignment = true;
27 Data16bitsDirective = "\t.half\t";
28 Data32bitsDirective = "\t.word\t";
29 Data64bitsDirective = NULL;
30 PrivateGlobalPrefix = "$";
31 JumpTableDataSection = "\t.rdata";
33 ReadOnlySection = "\t.rdata";
34 ZeroDirective = "\t.space\t";
35 BSSSection = "\t.section\t.bss";
36 CStringSection = ".rodata.str";
37 FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
39 if (!Subtarget->hasABICall()) {
40 JumpTableDirective = "\t.word\t";
41 SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable);
42 SmallBSSSection = getNamedSection("\t.sbss", SectionFlags::Writeable |
45 JumpTableDirective = "\t.gpword\t";
49 unsigned MipsTargetAsmInfo::
50 SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
51 unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
52 // Mask out Small Section flag bit, Mips doesnt support 's' section symbol
53 // for its small sections.
54 return (Flags & (~SectionFlags::Small));
57 SectionKind::Kind MipsTargetAsmInfo::
58 SectionKindForGlobal(const GlobalValue *GV) const {
59 SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
61 if (Subtarget->hasABICall())
64 if (K != SectionKind::Data && K != SectionKind::BSS &&
65 K != SectionKind::RODataMergeConst)
68 if (isa<GlobalVariable>(GV)) {
69 const TargetData *TD = ETM->getTargetData();
70 unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
71 unsigned Threshold = Subtarget->getSSectionThreshold();
73 if (Size > 0 && Size <= Threshold) {
74 if (K == SectionKind::BSS)
75 return SectionKind::SmallBSS;
77 return SectionKind::SmallData;
84 const Section* MipsTargetAsmInfo::
85 SelectSectionForGlobal(const GlobalValue *GV) const {
86 SectionKind::Kind K = SectionKindForGlobal(GV);
87 const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
89 if (GVA && (!GVA->isWeakForLinker()))
91 case SectionKind::SmallData:
92 return getSmallDataSection();
93 case SectionKind::SmallBSS:
94 return getSmallBSSSection();
98 return ELFTargetAsmInfo::SelectSectionForGlobal(GV);