Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
RISCVMCAsmInfo.cpp
Go to the documentation of this file.
1//===-- RISCVMCAsmInfo.cpp - RISC-V 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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declarations of the RISCVMCAsmInfo properties.
10//
11//===----------------------------------------------------------------------===//
12
13#include "RISCVMCAsmInfo.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCStreamer.h"
19using namespace llvm;
20
21void RISCVMCAsmInfo::anchor() {}
22
24 IsLittleEndian = TT.isLittleEndian();
25 CodePointerSize = CalleeSaveStackSlotSize = TT.isArch64Bit() ? 8 : 4;
26 CommentString = "#";
27 AlignmentIsInBytes = false;
30 UseAtForSpecifier = false;
31 Data16bitsDirective = "\t.half\t";
32 Data32bitsDirective = "\t.word\t";
33}
34
36 unsigned Encoding,
37 MCStreamer &Streamer) const {
38 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
39 return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);
40
41 // The default symbol subtraction results in an ADD/SUB relocation pair.
42 // Processing this relocation pair is problematic when linker relaxation is
43 // enabled, so we follow binutils in using the R_RISCV_32_PCREL relocation
44 // for the FDE initial location.
45 MCContext &Ctx = Streamer.getContext();
46 const MCExpr *ME = MCSymbolRefExpr::create(Sym, Ctx);
47 assert(Encoding & dwarf::DW_EH_PE_sdata4 && "Unexpected encoding");
48 return MCSpecifierExpr::create(ME, ELF::R_RISCV_32_PCREL, Ctx);
49}
50
52 const MCSpecifierExpr &Expr) const {
53 auto S = Expr.getSpecifier();
54 bool HasSpecifier = S != 0 && S != ELF::R_RISCV_CALL_PLT;
55 if (HasSpecifier)
56 OS << '%' << RISCV::getSpecifierName(S) << '(';
57 printExpr(OS, *Expr.getSubExpr());
58 if (HasSpecifier)
59 OS << ')';
60}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains constants used for implementing Dwarf debug support.
const char * Data16bitsDirective
Definition MCAsmInfo.h:248
bool UseAtForSpecifier
True if target uses @ (expr@specifier) for relocation specifiers.
Definition MCAsmInfo.h:385
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition MCAsmInfo.h:359
const char * Data32bitsDirective
Definition MCAsmInfo.h:249
void printExpr(raw_ostream &, const MCExpr &) const
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:356
virtual const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition MCAsmInfo.cpp:86
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition MCAsmInfo.h:273
bool IsLittleEndian
True if target is little endian. Default is true.
Definition MCAsmInfo.h:94
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
Definition MCAsmInfo.h:87
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition MCAsmInfo.h:91
StringRef CommentString
This indicates the comment string used by the assembler.
Definition MCAsmInfo.h:135
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition MCExpr.h:495
const MCExpr * getSubExpr() const
Definition MCExpr.h:509
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Spec getSpecifier() const
Definition MCExpr.h:508
Streaming machine code generation interface.
Definition MCStreamer.h:220
MCContext & getContext() const
Definition MCStreamer.h:314
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:214
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
RISCVMCAsmInfo(const Triple &TargetTriple)
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const override
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
StringRef getSpecifierName(Specifier Kind)
@ DW_EH_PE_pcrel
Definition Dwarf.h:872
@ DW_EH_PE_sdata4
Definition Dwarf.h:869
This is an optimization pass for GlobalISel generic memory operations.
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55