106c3fb27SDimitry Andric //===-- RISCVTargetObjectFile.h - RISC-V Object Info ------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H 100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric namespace llvm { 150b57cec5SDimitry Andric 1606c3fb27SDimitry Andric /// This implementation is used for RISC-V ELF targets. 170b57cec5SDimitry Andric class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF { 180b57cec5SDimitry Andric MCSection *SmallDataSection; 19*0fca6ea1SDimitry Andric MCSection *SmallRODataSection; 20*0fca6ea1SDimitry Andric MCSection *SmallROData4Section; 21*0fca6ea1SDimitry Andric MCSection *SmallROData8Section; 22*0fca6ea1SDimitry Andric MCSection *SmallROData16Section; 23*0fca6ea1SDimitry Andric MCSection *SmallROData32Section; 240b57cec5SDimitry Andric MCSection *SmallBSSSection; 250b57cec5SDimitry Andric unsigned SSThreshold = 8; 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric public: 2806c3fb27SDimitry Andric unsigned getTextSectionAlignment() const override; 2906c3fb27SDimitry Andric 300b57cec5SDimitry Andric void Initialize(MCContext &Ctx, const TargetMachine &TM) override; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric /// Return true if this global address should be placed into small data/bss 330b57cec5SDimitry Andric /// section. 340b57cec5SDimitry Andric bool isGlobalInSmallSection(const GlobalObject *GO, 350b57cec5SDimitry Andric const TargetMachine &TM) const; 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, 380b57cec5SDimitry Andric const TargetMachine &TM) const override; 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric /// Return true if this constant should be placed into small data section. 410b57cec5SDimitry Andric bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind, 440b57cec5SDimitry Andric const Constant *C, 455ffd83dbSDimitry Andric Align &Alignment) const override; 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric void getModuleMetadata(Module &M) override; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric bool isInSmallSection(uint64_t Size) const; 507a6dacacSDimitry Andric 517a6dacacSDimitry Andric const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV, 527a6dacacSDimitry Andric const MCSymbol *Sym, 537a6dacacSDimitry Andric const MCValue &MV, int64_t Offset, 547a6dacacSDimitry Andric MachineModuleInfo *MMI, 557a6dacacSDimitry Andric MCStreamer &Streamer) const override; 560b57cec5SDimitry Andric }; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric } // end namespace llvm 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric #endif 61