82 lines · cpp
1//===-- CSKYMCAsmInfo.cpp - CSKY Asm properties ---------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file contains the declarations of the CSKYMCAsmInfo properties.10//11//===----------------------------------------------------------------------===//12 13#include "CSKYMCAsmInfo.h"14#include "MCTargetDesc/CSKYMCAsmInfo.h"15#include "llvm/BinaryFormat/Dwarf.h"16#include "llvm/MC/MCExpr.h"17#include "llvm/MC/MCStreamer.h"18 19using namespace llvm;20 21const MCAsmInfo::AtSpecifier atSpecifiers[] = {22 {CSKY::S_GOT, "GOT"}, {CSKY::S_GOTOFF, "GOTOFF"},23 {CSKY::S_PLT, "PLT"}, {CSKY::S_TLSGD, "TLSGD"},24 {CSKY::S_TLSLDM, "TLSLDM"}, {CSKY::S_TPOFF, "TPOFF"},25};26 27void CSKYMCAsmInfo::anchor() {}28 29CSKYMCAsmInfo::CSKYMCAsmInfo(const Triple &TargetTriple) {30 AlignmentIsInBytes = false;31 SupportsDebugInformation = true;32 CommentString = "#";33 34 // Uses '.section' before '.bss' directive35 UsesELFSectionDirectiveForBSS = true;36 37 ExceptionsType = ExceptionHandling::DwarfCFI;38 39 initializeAtSpecifiers(atSpecifiers);40}41 42static StringRef getVariantKindName(uint8_t Kind) {43 using namespace CSKY;44 switch (Kind) {45 default:46 llvm_unreachable("Invalid ELF symbol kind");47 case S_None:48 case S_ADDR:49 return "";50 case S_ADDR_HI16:51 return "@HI16";52 case S_ADDR_LO16:53 return "@LO16";54 case S_GOT_IMM18_BY4:55 case S_GOT:56 return "@GOT";57 case S_GOTPC:58 return "@GOTPC";59 case S_GOTOFF:60 return "@GOTOFF";61 case S_PLT_IMM18_BY4:62 case S_PLT:63 return "@PLT";64 case S_TLSLE:65 return "@TPOFF";66 case S_TLSIE:67 return "@GOTTPOFF";68 case S_TLSGD:69 return "@TLSGD32";70 case S_TLSLDO:71 return "@TLSLDO32";72 case S_TLSLDM:73 return "@TLSLDM32";74 }75}76 77void CSKYMCAsmInfo::printSpecifierExpr(raw_ostream &OS,78 const MCSpecifierExpr &Expr) const {79 printExpr(OS, *Expr.getSubExpr());80 OS << getVariantKindName(Expr.getSpecifier());81}82