LLVM API Documentation
00001 //===-- MipsTargetAsmInfo.cpp - Mips asm properties -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the declarations of the MipsTargetAsmInfo properties. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "MipsTargetAsmInfo.h" 00015 #include "MipsTargetMachine.h" 00016 #include "llvm/GlobalVariable.h" 00017 00018 using namespace llvm; 00019 00020 MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM): 00021 ELFTargetAsmInfo(TM) { 00022 00023 Subtarget = &TM.getSubtarget<MipsSubtarget>(); 00024 00025 AlignmentIsInBytes = false; 00026 COMMDirectiveTakesAlignment = true; 00027 Data16bitsDirective = "\t.half\t"; 00028 Data32bitsDirective = "\t.word\t"; 00029 Data64bitsDirective = NULL; 00030 PrivateGlobalPrefix = "$"; 00031 JumpTableDataSection = "\t.rdata"; 00032 CommentString = "#"; 00033 ZeroDirective = "\t.space\t"; 00034 BSSSection = "\t.section\t.bss"; 00035 CStringSection = ".rodata.str"; 00036 00037 if (!Subtarget->hasABICall()) { 00038 JumpTableDirective = "\t.word\t"; 00039 SmallDataSection = getNamedSection("\t.sdata", SectionFlags::Writeable); 00040 SmallBSSSection = getNamedSection("\t.sbss", 00041 SectionFlags::Writeable | 00042 SectionFlags::BSS); 00043 } else 00044 JumpTableDirective = "\t.gpword\t"; 00045 00046 } 00047 00048 unsigned MipsTargetAsmInfo:: 00049 SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const { 00050 unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name); 00051 // Mask out Small Section flag bit, Mips doesnt support 's' section symbol 00052 // for its small sections. 00053 return (Flags & (~SectionFlags::Small)); 00054 } 00055 00056 SectionKind::Kind MipsTargetAsmInfo:: 00057 SectionKindForGlobal(const GlobalValue *GV) const { 00058 SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV); 00059 00060 if (Subtarget->hasABICall()) 00061 return K; 00062 00063 if (K != SectionKind::Data && K != SectionKind::BSS && 00064 K != SectionKind::RODataMergeConst) 00065 return K; 00066 00067 if (isa<GlobalVariable>(GV)) { 00068 const TargetData *TD = TM.getTargetData(); 00069 unsigned Size = TD->getTypePaddedSize(GV->getType()->getElementType()); 00070 unsigned Threshold = Subtarget->getSSectionThreshold(); 00071 00072 if (Size > 0 && Size <= Threshold) { 00073 if (K == SectionKind::BSS) 00074 return SectionKind::SmallBSS; 00075 else 00076 return SectionKind::SmallData; 00077 } 00078 } 00079 00080 return K; 00081 } 00082 00083 const Section* MipsTargetAsmInfo:: 00084 SelectSectionForGlobal(const GlobalValue *GV) const { 00085 SectionKind::Kind K = SectionKindForGlobal(GV); 00086 const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV); 00087 00088 if (GVA && (!GVA->mayBeOverridden())) 00089 switch (K) { 00090 case SectionKind::SmallData: 00091 return getSmallDataSection(); 00092 case SectionKind::SmallBSS: 00093 return getSmallBSSSection(); 00094 default: break; 00095 } 00096 00097 return ELFTargetAsmInfo::SelectSectionForGlobal(GV); 00098 }