aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp
blob: 803b75332f7b02b6bd49a4c41fcc548e1bab3a20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//===-- CSKYMCAsmInfo.cpp - CSKY Asm properties ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the CSKYMCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "CSKYMCAsmInfo.h"
#include "MCTargetDesc/CSKYMCAsmInfo.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCStreamer.h"

using namespace llvm;

const MCAsmInfo::AtSpecifier atSpecifiers[] = {
    {CSKY::S_GOT, "GOT"},       {CSKY::S_GOTOFF, "GOTOFF"},
    {CSKY::S_PLT, "PLT"},       {CSKY::S_TLSGD, "TLSGD"},
    {CSKY::S_TLSLDM, "TLSLDM"}, {CSKY::S_TPOFF, "TPOFF"},
};

void CSKYMCAsmInfo::anchor() {}

CSKYMCAsmInfo::CSKYMCAsmInfo(const Triple &TargetTriple) {
  AlignmentIsInBytes = false;
  SupportsDebugInformation = true;
  CommentString = "#";

  // Uses '.section' before '.bss' directive
  UsesELFSectionDirectiveForBSS = true;

  ExceptionsType = ExceptionHandling::DwarfCFI;

  initializeAtSpecifiers(atSpecifiers);
}

static StringRef getVariantKindName(uint8_t Kind) {
  using namespace CSKY;
  switch (Kind) {
  default:
    llvm_unreachable("Invalid ELF symbol kind");
  case S_None:
  case S_ADDR:
    return "";
  case S_ADDR_HI16:
    return "@HI16";
  case S_ADDR_LO16:
    return "@LO16";
  case S_GOT_IMM18_BY4:
  case S_GOT:
    return "@GOT";
  case S_GOTPC:
    return "@GOTPC";
  case S_GOTOFF:
    return "@GOTOFF";
  case S_PLT_IMM18_BY4:
  case S_PLT:
    return "@PLT";
  case S_TLSLE:
    return "@TPOFF";
  case S_TLSIE:
    return "@GOTTPOFF";
  case S_TLSGD:
    return "@TLSGD32";
  case S_TLSLDO:
    return "@TLSLDO32";
  case S_TLSLDM:
    return "@TLSLDM32";
  }
}

void CSKYMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
                                       const MCSpecifierExpr &Expr) const {
  printExpr(OS, *Expr.getSubExpr());
  OS << getVariantKindName(Expr.getSpecifier());
}