LLVM API Documentation

SparcMCAsmInfo.cpp
Go to the documentation of this file.
00001 //===-- SparcMCAsmInfo.cpp - Sparc asm properties -------------------------===//
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 SparcMCAsmInfo properties.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "SparcMCAsmInfo.h"
00015 #include "SparcMCExpr.h"
00016 #include "llvm/ADT/Triple.h"
00017 #include "llvm/MC/MCStreamer.h"
00018 
00019 using namespace llvm;
00020 
00021 void SparcELFMCAsmInfo::anchor() { }
00022 
00023 SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) {
00024   IsLittleEndian = false;
00025   Triple TheTriple(TT);
00026   bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
00027 
00028   if (isV9) {
00029     PointerSize = CalleeSaveStackSlotSize = 8;
00030   }
00031 
00032   Data16bitsDirective = "\t.half\t";
00033   Data32bitsDirective = "\t.word\t";
00034   // .xword is only supported by V9.
00035   Data64bitsDirective = (isV9) ? "\t.xword\t" : nullptr;
00036   ZeroDirective = "\t.skip\t";
00037   CommentString = "!";
00038   SupportsDebugInformation = true;
00039 
00040   ExceptionsType = ExceptionHandling::DwarfCFI;
00041 
00042   SunStyleELFSectionSwitchSyntax = true;
00043   UsesELFSectionDirectiveForBSS = true;
00044 
00045   if (TheTriple.getOS() == llvm::Triple::Solaris ||
00046       TheTriple.getOS() == llvm::Triple::OpenBSD)
00047     UseIntegratedAssembler = true;
00048 }
00049 
00050 const MCExpr*
00051 SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
00052                                                unsigned Encoding,
00053                                                MCStreamer &Streamer) const {
00054   if (Encoding & dwarf::DW_EH_PE_pcrel) {
00055     MCContext &Ctx = Streamer.getContext();
00056     return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
00057                                MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
00058   }
00059 
00060   return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer);
00061 }
00062 
00063 const MCExpr*
00064 SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
00065                                        unsigned Encoding,
00066                                        MCStreamer &Streamer) const {
00067   if (Encoding & dwarf::DW_EH_PE_pcrel) {
00068     MCContext &Ctx = Streamer.getContext();
00069     return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
00070                                MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
00071   }
00072   return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);
00073 }