Added floating point lowering for select.
[oota-llvm.git] / lib / Target / Mips / MipsTargetAsmInfo.cpp
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.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MipsTargetAsmInfo.h"
15 #include "MipsTargetMachine.h"
16
17 using namespace llvm;
18
19 MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
20   ELFTargetAsmInfo(TM) {
21
22   Subtarget = &TM.getSubtarget<MipsSubtarget>();
23
24   AlignmentIsInBytes          = false;
25   COMMDirectiveTakesAlignment = true;
26   Data16bitsDirective         = "\t.half\t";
27   Data32bitsDirective         = "\t.word\t";
28   Data64bitsDirective         = NULL;
29   PrivateGlobalPrefix         = "$";
30   JumpTableDataSection        = "\t.rdata";
31   CommentString               = "#";
32   ReadOnlySection             = "\t.rdata";
33   ZeroDirective               = "\t.space\t";
34   BSSSection                  = "\t.section\t.bss";
35   CStringSection              = ".rodata.str";
36   FourByteConstantSection     = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
37
38   if (!Subtarget->hasABICall()) {
39     JumpTableDirective = "\t.word\t";
40     SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable);
41     SmallBSSSection = getNamedSection("\t.sbss", SectionFlags::Writeable | 
42                                       SectionFlags::BSS);
43   } else 
44     JumpTableDirective = "\t.gpword\t";
45
46 }
47
48 SectionKind::Kind
49 MipsTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
50   SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
51
52   if (Subtarget->hasABICall())
53     return K;
54
55   if (K != SectionKind::Data && K != SectionKind::BSS && 
56       K != SectionKind::RODataMergeConst)
57     return K;
58
59   if (isa<GlobalVariable>(GV)) {
60     const TargetData *TD = ETM->getTargetData();
61     unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
62     unsigned Threshold = Subtarget->getSSectionThreshold();
63      
64     if (Size > 0 && Size <= Threshold) {
65       if (K == SectionKind::BSS)
66         return SectionKind::SmallBSS;
67       else
68         return SectionKind::SmallData;
69     }
70   }
71
72   return K;
73 }
74
75 const Section*
76 MipsTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
77   SectionKind::Kind K = SectionKindForGlobal(GV);
78   const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
79
80   if (GVA && (!GVA->isWeakForLinker()))
81     switch (K) {
82       case SectionKind::SmallData:
83         return getSmallDataSection();
84       case SectionKind::SmallBSS:
85         return getSmallBSSSection();
86       default: break;
87     }
88
89   return ELFTargetAsmInfo::SelectSectionForGlobal(GV);
90 }