LLVM 24.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
25 IsLittleEndian = TT.isLittleEndian();
26 CodePointerSize = CalleeSaveStackSlotSize = TT.isArch64Bit() ? 8 : 4;
27 CommentString = "#";
28 AlignmentIsInBytes = false;
30 Data16bitsDirective = "\t.half\t";
31 Data32bitsDirective = "\t.word\t";
32 // The default symbol subtraction results in an ADD/SUB relocation pair.
33 // Processing this relocation pair is problematic when linker relaxation is
34 // enabled, so we follow binutils in using the R_RISCV_32_PCREL relocation
35 // for the FDE initial location.
36 DwarfFDERelSymbolSpec = ELF::R_RISCV_32_PCREL;
37}
38
40 const MCSpecifierExpr &Expr) const {
41 auto S = Expr.getSpecifier();
42 bool HasSpecifier = S != RISCV::S_None && S != RISCV::S_CALL_PLT;
43 if (HasSpecifier)
44 OS << '%' << RISCV::getSpecifierName(S) << '(';
45 printExpr(OS, *Expr.getSubExpr());
46 if (HasSpecifier)
47 OS << ')';
48}
49
62
64 raw_ostream &OS, const MCSpecifierExpr &Expr) const {
65 auto S = Expr.getSpecifier();
66 bool HasSpecifier = S != RISCV::S_None && S != RISCV::S_CALL_PLT;
67 if (HasSpecifier)
68 OS << '%' << RISCV::getSpecifierName(S) << '(';
69 printExpr(OS, *Expr.getSubExpr());
70 if (HasSpecifier)
71 OS << ')';
72}
This file contains constants used for implementing Dwarf debug support.
static LVOptions Options
Definition LVOptions.cpp:25
MCAsmInfoDarwin(const MCTargetOptions &Options)
MCAsmInfoELF(const MCTargetOptions &Options)
StringRef InternalSymbolPrefix
For internal use by compiler and assembler, not meant to be visible externally.
Definition MCAsmInfo.h:159
const char * Data16bitsDirective
Definition MCAsmInfo.h:243
const char * Data32bitsDirective
Definition MCAsmInfo.h:244
void printExpr(raw_ostream &, const MCExpr &) const
uint16_t DwarfFDERelSymbolSpec
The optional specifier to use for the relative FDE symbol references.
Definition MCAsmInfo.h:373
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:354
const char * SeparatorString
This string, if specified, is used to separate instructions from each other when on the same line.
Definition MCAsmInfo.h:130
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition MCAsmInfo.h:268
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives.
Definition MCAsmInfo.h:207
bool IsLittleEndian
True if target is little endian. Default is true.
Definition MCAsmInfo.h:93
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
Definition MCAsmInfo.h:86
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition MCAsmInfo.h:90
StringRef CommentString
This indicates the comment string used by the assembler.
Definition MCAsmInfo.h:134
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition MCExpr.h:494
const MCExpr * getSubExpr() const
Definition MCExpr.h:508
Spec getSpecifier() const
Definition MCExpr.h:507
RISCVMCAsmInfoDarwin(const MCTargetOptions &Options)
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
RISCVMCAsmInfo(const Triple &TargetTriple, const MCTargetOptions &Options)
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
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)
This is an optimization pass for GlobalISel generic memory operations.