[PATCH] D46674: [RISCV] Define FeatureRelax and shouldForceRelocation for RISCV linker relaxation
Shiva Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 23:41:25 PDT 2018
shiva0217 created this revision.
shiva0217 added reviewers: asb, apazos.
Herald added subscribers: mgrang, edward-jones, zzheng, kito-cheng, niosHD, sabuasal, jordy.potman.lists, simoncook, johnrusso, rbar.
1. Deine FeatureRelax to enable/disable linker relaxation
2. Define shouldForceRelocation to preserve relocation types when linker relaxation enabled. So then linker could fixup branches offsets while relaxation.
Repository:
rL LLVM
https://reviews.llvm.org/D46674
Files:
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
lib/Target/RISCV/RISCV.td
lib/Target/RISCV/RISCVSubtarget.h
Index: lib/Target/RISCV/RISCVSubtarget.h
===================================================================
--- lib/Target/RISCV/RISCVSubtarget.h
+++ lib/Target/RISCV/RISCVSubtarget.h
@@ -36,6 +36,7 @@
bool HasStdExtD = false;
bool HasStdExtC = false;
bool HasRV64 = false;
+ bool EnableLinkerRelax = false;
unsigned XLen = 32;
MVT XLenVT = MVT::i32;
RISCVFrameLowering FrameLowering;
@@ -77,6 +78,7 @@
bool hasStdExtD() const { return HasStdExtD; }
bool hasStdExtC() const { return HasStdExtC; }
bool is64Bit() const { return HasRV64; }
+ bool enableLinkerRelax() const { return EnableLinkerRelax; }
MVT getXLenVT() const { return XLenVT; }
unsigned getXLen() const { return XLen; }
};
Index: lib/Target/RISCV/RISCV.td
===================================================================
--- lib/Target/RISCV/RISCV.td
+++ lib/Target/RISCV/RISCV.td
@@ -55,6 +55,10 @@
def RV64 : HwMode<"+64bit">;
def RV32 : HwMode<"-64bit">;
+def FeatureRelax
+ : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
+ "Enable Linker relaxation.">;
+
//===----------------------------------------------------------------------===//
// Registers, calling conventions, instruction descriptions.
//===----------------------------------------------------------------------===//
Index: lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
===================================================================
--- lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -43,6 +43,13 @@
std::unique_ptr<MCObjectWriter>
createObjectWriter(raw_pwrite_stream &OS) const override;
+ // Preserve relocation types if the linker relaxation enabled. So then
+ // linker could has information to fixup offsets while relaxation.
+ bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
+ const MCValue &Target) override {
+ return STI.getFeatureBits()[RISCV::FeatureRelax];
+ }
+
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
const MCRelaxableFragment *DF,
const MCAsmLayout &Layout) const override;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46674.146070.patch
Type: text/x-patch
Size: 2243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180510/c74ead39/attachment.bin>
More information about the llvm-commits
mailing list