RISCVTargetObjectFile.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===-- RISCVTargetObjectFile.h - RISCV 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. #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
  9. #define LLVM_LIB_TARGET_RISCV_RISCVTARGETOBJECTFILE_H
  10. #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
  11. namespace llvm {
  12. /// This implementation is used for RISCV ELF targets.
  13. class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF {
  14. MCSection *SmallDataSection;
  15. MCSection *SmallBSSSection;
  16. unsigned SSThreshold = 8;
  17. public:
  18. void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
  19. /// Return true if this global address should be placed into small data/bss
  20. /// section.
  21. bool isGlobalInSmallSection(const GlobalObject *GO,
  22. const TargetMachine &TM) const;
  23. MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
  24. const TargetMachine &TM) const override;
  25. /// Return true if this constant should be placed into small data section.
  26. bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const;
  27. MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
  28. const Constant *C,
  29. Align &Alignment) const override;
  30. void getModuleMetadata(Module &M) override;
  31. bool isInSmallSection(uint64_t Size) const;
  32. };
  33. } // end namespace llvm
  34. #endif