Merge branch 'master' into msp430
[llvm/msp430.git] / lib / Target / Mips / MipsTargetAsmInfo.cpp
blobc197b0c2981cce105fffc91bb6eacbc0882cdaa8
1 //===-- MipsTargetAsmInfo.cpp - Mips asm properties -------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declarations of the MipsTargetAsmInfo properties.
12 //===----------------------------------------------------------------------===//
14 #include "MipsTargetAsmInfo.h"
15 #include "MipsTargetMachine.h"
16 #include "llvm/GlobalVariable.h"
18 using namespace llvm;
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";
32 CommentString = "#";
33 ZeroDirective = "\t.space\t";
34 BSSSection = "\t.section\t.bss";
35 CStringSection = ".rodata.str";
37 if (!Subtarget->hasABICall()) {
38 JumpTableDirective = "\t.word\t";
39 SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable);
40 SmallBSSSection = getNamedSection("\t.sbss",
41 SectionFlags::Writeable |
42 SectionFlags::BSS);
43 } else
44 JumpTableDirective = "\t.gpword\t";
48 unsigned MipsTargetAsmInfo::
49 SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
50 unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
51 // Mask out Small Section flag bit, Mips doesnt support 's' section symbol
52 // for its small sections.
53 return (Flags & (~SectionFlags::Small));
56 SectionKind::Kind MipsTargetAsmInfo::
57 SectionKindForGlobal(const GlobalValue *GV) const {
58 SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
60 if (Subtarget->hasABICall())
61 return K;
63 if (K != SectionKind::Data && K != SectionKind::BSS &&
64 K != SectionKind::RODataMergeConst)
65 return K;
67 if (isa<GlobalVariable>(GV)) {
68 const TargetData *TD = TM.getTargetData();
69 unsigned Size = TD->getTypeAllocSize(GV->getType()->getElementType());
70 unsigned Threshold = Subtarget->getSSectionThreshold();
72 if (Size > 0 && Size <= Threshold) {
73 if (K == SectionKind::BSS)
74 return SectionKind::SmallBSS;
75 else
76 return SectionKind::SmallData;
80 return K;
83 const Section* MipsTargetAsmInfo::
84 SelectSectionForGlobal(const GlobalValue *GV) const {
85 SectionKind::Kind K = SectionKindForGlobal(GV);
86 const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
88 if (GVA && (!GVA->isWeakForLinker()))
89 switch (K) {
90 case SectionKind::SmallData:
91 return getSmallDataSection();
92 case SectionKind::SmallBSS:
93 return getSmallBSSSection();
94 default: break;
97 return ELFTargetAsmInfo::SelectSectionForGlobal(GV);