198bc25a0SMandeep Singh Grang //===-- RISCVTargetObjectFile.h - RISCV Object Info -*- C++ ---------*-===// 298bc25a0SMandeep Singh Grang // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 698bc25a0SMandeep Singh Grang // 798bc25a0SMandeep Singh Grang //===----------------------------------------------------------------------===// 898bc25a0SMandeep Singh Grang 998bc25a0SMandeep Singh Grang #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H 1098bc25a0SMandeep Singh Grang #define LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H 1198bc25a0SMandeep Singh Grang 1298bc25a0SMandeep Singh Grang #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" 1398bc25a0SMandeep Singh Grang 1498bc25a0SMandeep Singh Grang namespace llvm { 1598bc25a0SMandeep Singh Grang class RISCVTargetMachine; 1698bc25a0SMandeep Singh Grang 1798bc25a0SMandeep Singh Grang /// This implementation is used for RISCV ELF targets. 1898bc25a0SMandeep Singh Grang class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF { 19*7cc03bd0SShiva Chen MCSection *SmallDataSection; 20*7cc03bd0SShiva Chen MCSection *SmallBSSSection; 21*7cc03bd0SShiva Chen unsigned SSThreshold = 8; 22*7cc03bd0SShiva Chen 23*7cc03bd0SShiva Chen public: 2498bc25a0SMandeep Singh Grang void Initialize(MCContext &Ctx, const TargetMachine &TM) override; 25*7cc03bd0SShiva Chen 26*7cc03bd0SShiva Chen /// Return true if this global address should be placed into small data/bss 27*7cc03bd0SShiva Chen /// section. 28*7cc03bd0SShiva Chen bool isGlobalInSmallSection(const GlobalObject *GO, 29*7cc03bd0SShiva Chen const TargetMachine &TM) const; 30*7cc03bd0SShiva Chen 31*7cc03bd0SShiva Chen MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, 32*7cc03bd0SShiva Chen const TargetMachine &TM) const override; 33*7cc03bd0SShiva Chen 34*7cc03bd0SShiva Chen /// Return true if this constant should be placed into small data section. 35*7cc03bd0SShiva Chen bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const; 36*7cc03bd0SShiva Chen 37*7cc03bd0SShiva Chen MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind, 38*7cc03bd0SShiva Chen const Constant *C, 39*7cc03bd0SShiva Chen unsigned &Align) const override; 40*7cc03bd0SShiva Chen 41*7cc03bd0SShiva Chen void getModuleMetadata(Module &M) override; 42*7cc03bd0SShiva Chen 43*7cc03bd0SShiva Chen bool isInSmallSection(uint64_t Size) const; 4498bc25a0SMandeep Singh Grang }; 4598bc25a0SMandeep Singh Grang 4698bc25a0SMandeep Singh Grang } // end namespace llvm 4798bc25a0SMandeep Singh Grang 4898bc25a0SMandeep Singh Grang #endif 49