1//===-- RISCVTargetObjectFile.h - RISC-V Object 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#ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
10#define LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
11
12#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
13
14namespace llvm {
15
16/// This implementation is used for RISC-V ELF targets.
17class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF {
18 MCSection *SmallDataSection;
19 MCSection *SmallRODataSection;
20 MCSection *SmallROData4Section;
21 MCSection *SmallROData8Section;
22 MCSection *SmallROData16Section;
23 MCSection *SmallROData32Section;
24 MCSection *SmallBSSSection;
25 unsigned SSThreshold = 0;
26
27public:
28 unsigned getTextSectionAlignment() const override;
29
30 void initialize(MCContext &Ctx, const TargetMachine &TM,
31 const Module &M) override;
32
33 /// Return true if this global address should be placed into small data/bss
34 /// section.
35 bool isGlobalInSmallSection(const GlobalObject *GO,
36 const TargetMachine &TM) const;
37
38 MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
39 const TargetMachine &TM) const override;
40
41 /// Return true if this constant should be placed into small data section.
42 bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const;
43
44 MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
45 const Constant *C, Align &Alignment,
46 const Function *F) const override;
47
48 bool isInSmallSection(uint64_t Size) const;
49
50 bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
51 const Function &F) const override;
52
53 const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV,
54 const MCSymbol *Sym,
55 const MCValue &MV, int64_t Offset,
56 MachineModuleInfo *MMI,
57 MCStreamer &Streamer) const override;
58};
59
60class RISCVMachOTargetObjectFile : public TargetLoweringObjectFileMachO {
61public:
62 RISCVMachOTargetObjectFile() {};
63
64 void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
65 const TargetMachine &TM) const override;
66};
67
68} // end namespace llvm
69
70#endif
71