SparcMCAsmInfo.cpp revision 263763
1//===-- SparcMCAsmInfo.cpp - Sparc asm properties -------------------------===//
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 SparcMCAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "SparcMCAsmInfo.h"
15#include "SparcMCExpr.h"
16#include "llvm/ADT/Triple.h"
17#include "llvm/MC/MCStreamer.h"
18
19using namespace llvm;
20
21void SparcELFMCAsmInfo::anchor() { }
22
23SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) {
24  IsLittleEndian = false;
25  Triple TheTriple(TT);
26  bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
27
28  if (isV9) {
29    PointerSize = CalleeSaveStackSlotSize = 8;
30  }
31
32  Data16bitsDirective = "\t.half\t";
33  Data32bitsDirective = "\t.word\t";
34  // .xword is only supported by V9.
35  Data64bitsDirective = (isV9) ? "\t.xword\t" : 0;
36  ZeroDirective = "\t.skip\t";
37  CommentString = "!";
38  HasLEB128 = true;
39  SupportsDebugInformation = true;
40
41  ExceptionsType = ExceptionHandling::DwarfCFI;
42
43  SunStyleELFSectionSwitchSyntax = true;
44  UsesELFSectionDirectiveForBSS = true;
45
46  PrivateGlobalPrefix = ".L";
47}
48
49const MCExpr*
50SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
51                                               unsigned Encoding,
52                                               MCStreamer &Streamer) const {
53  if (Encoding & dwarf::DW_EH_PE_pcrel) {
54    MCContext &Ctx = Streamer.getContext();
55    return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
56                               MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
57  }
58
59  return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer);
60}
61
62const MCExpr*
63SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
64                                       unsigned Encoding,
65                                       MCStreamer &Streamer) const {
66  if (Encoding & dwarf::DW_EH_PE_pcrel) {
67    MCContext &Ctx = Streamer.getContext();
68    return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
69                               MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
70  }
71  return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);
72}
73