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