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 
1698bc25a0SMandeep Singh Grang /// This implementation is used for RISCV ELF targets.
1798bc25a0SMandeep Singh Grang class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF {
187cc03bd0SShiva Chen   MCSection *SmallDataSection;
197cc03bd0SShiva Chen   MCSection *SmallBSSSection;
207cc03bd0SShiva Chen   unsigned SSThreshold = 8;
217cc03bd0SShiva Chen 
227cc03bd0SShiva Chen public:
2398bc25a0SMandeep Singh Grang   void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
247cc03bd0SShiva Chen 
257cc03bd0SShiva Chen   /// Return true if this global address should be placed into small data/bss
267cc03bd0SShiva Chen   /// section.
277cc03bd0SShiva Chen   bool isGlobalInSmallSection(const GlobalObject *GO,
287cc03bd0SShiva Chen                               const TargetMachine &TM) const;
297cc03bd0SShiva Chen 
307cc03bd0SShiva Chen   MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
317cc03bd0SShiva Chen                                     const TargetMachine &TM) const override;
327cc03bd0SShiva Chen 
337cc03bd0SShiva Chen   /// Return true if this constant should be placed into small data section.
347cc03bd0SShiva Chen   bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const;
357cc03bd0SShiva Chen 
367cc03bd0SShiva Chen   MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
377cc03bd0SShiva Chen                                    const Constant *C,
38*f96a7706SCraig Topper                                    Align &Alignment) const override;
397cc03bd0SShiva Chen 
407cc03bd0SShiva Chen   void getModuleMetadata(Module &M) override;
417cc03bd0SShiva Chen 
427cc03bd0SShiva Chen   bool isInSmallSection(uint64_t Size) const;
4398bc25a0SMandeep Singh Grang };
4498bc25a0SMandeep Singh Grang 
4598bc25a0SMandeep Singh Grang } // end namespace llvm
4698bc25a0SMandeep Singh Grang 
4798bc25a0SMandeep Singh Grang #endif
48