summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
diff options
context:
space:
mode:
authorShiva Chen <shiva0217@gmail.com>2019-04-11 04:59:13 +0000
committerShiva Chen <shiva0217@gmail.com>2019-04-11 04:59:13 +0000
commit7cc03bd06487313575c82264abf018098060f795 (patch)
tree0d3801115161a47c0a0dd1f996c738032e967248 /llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
parent98da442b6d77a20e45013e9df6c7480bea2f56e0 (diff)
downloadbcm5719-llvm-7cc03bd06487313575c82264abf018098060f795.tar.gz
bcm5719-llvm-7cc03bd06487313575c82264abf018098060f795.zip
[RISCV] Put data smaller than eight bytes to small data section
Because of gp = sdata_start_address + 0x800, gp with signed twelve-bit offset could covert most of the small data section. Linker relaxation could transfer the multiple data accessing instructions to a gp base with signed twelve-bit offset instruction. Differential Revision: https://reviews.llvm.org/D57493 llvm-svn: 358150
Diffstat (limited to 'llvm/lib/Target/RISCV/RISCVTargetObjectFile.h')
-rw-r--r--llvm/lib/Target/RISCV/RISCVTargetObjectFile.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
index e622c5a6c1a..b2daaaa9d36 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
@@ -16,7 +16,31 @@ class RISCVTargetMachine;
/// This implementation is used for RISCV ELF targets.
class RISCVELFTargetObjectFile : public TargetLoweringObjectFileELF {
+ MCSection *SmallDataSection;
+ MCSection *SmallBSSSection;
+ unsigned SSThreshold = 8;
+
+public:
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
+
+ /// Return true if this global address should be placed into small data/bss
+ /// section.
+ bool isGlobalInSmallSection(const GlobalObject *GO,
+ const TargetMachine &TM) const;
+
+ MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
+ const TargetMachine &TM) const override;
+
+ /// Return true if this constant should be placed into small data section.
+ bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const;
+
+ MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
+ const Constant *C,
+ unsigned &Align) const override;
+
+ void getModuleMetadata(Module &M) override;
+
+ bool isInSmallSection(uint64_t Size) const;
};
} // end namespace llvm
OpenPOWER on IntegriCloud