1//===-- RISCVMCAsmInfo.h - RISC-V Asm Info ---------------------*- C++ -*--===//
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 declaration of the RISCVMCAsmInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H
14#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H
15
16#include "llvm/MC/MCAsmInfoDarwin.h"
17#include "llvm/MC/MCAsmInfoELF.h"
18#include "llvm/MC/MCFixup.h"
19
20namespace llvm {
21class Triple;
22
23class RISCVMCAsmInfo : public MCAsmInfoELF {
24 void anchor() override;
25
26public:
27 explicit RISCVMCAsmInfo(const Triple &TargetTriple,
28 const MCTargetOptions &Options);
29
30 const MCExpr *getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding,
31 MCStreamer &Streamer) const override;
32 void printSpecifierExpr(raw_ostream &OS,
33 const MCSpecifierExpr &Expr) const override;
34};
35
36namespace RISCV {
37using Specifier = uint16_t;
38// Specifiers mapping to relocation types below FirstTargetFixupKind are
39// encoded literally, with these exceptions:
40enum {
41 S_None,
42 // Specifiers mapping to distinct relocation types.
43 S_LO = FirstTargetFixupKind,
44 S_PCREL_LO,
45 S_PCREL_HI,
46 S_TPREL_LO,
47 S_CALL_PLT,
48 S_GOT_HI,
49 // Vendor-specific relocation types might conflict across vendors.
50 // Refer to them using Specifier constants.
51 S_QC_ABS20,
52 S_QC_ACCESS,
53};
54
55Specifier parseSpecifierName(StringRef name);
56StringRef getSpecifierName(Specifier Kind);
57} // namespace RISCV
58
59class RISCVMCAsmInfoDarwin : public MCAsmInfoDarwin {
60public:
61 explicit RISCVMCAsmInfoDarwin(const MCTargetOptions &Options);
62 void printSpecifierExpr(raw_ostream &OS,
63 const MCSpecifierExpr &Expr) const override;
64};
65
66} // namespace llvm
67
68#endif
69