This is an archive of the discontinued LLVM Phabricator instance.

ELF/AArch64: Refactor R_AARCH64_LDST{8,15,32,64,128}_ABS_LO12_NC Relocations
ClosedPublic

Authored by zatrazz on Dec 6 2016, 1:03 PM.

Details

Summary

This patch refactor how to apply the R_AARCH64_LDST{8,16,32,64,128}_ABS_NC
relocations by adding a new function to correct extract the bits expected
by each relocation. This make is explicit which are the bits range expected
and simplify the code to mask and shift the deriable values.

It also fixes the R_AARCH64_LDST128_ABS_LO12_NC mask, although in pratice
the mask/shift always returns a 16 bytes aligned value.

Checked on AArch64 and with test-suite.

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 80466.Dec 6 2016, 1:03 PM
zatrazz retitled this revision from to ELF/AArch64: Refactor R_AARCH64_LDST{8,15,32,64,128}_ABS_LO12_NC Relocations.
zatrazz updated this object.
zatrazz added reviewers: rafael, ruiu, rengolin.
zatrazz set the repository for this revision to rL LLVM.
zatrazz added a project: lld.
zatrazz added a subscriber: llvm-commits.
ruiu added inline comments.Dec 6 2016, 1:27 PM
ELF/Target.cpp
1329–1338

Maybe we should add this to llvm/Support/MathExtras.h? We have a bunch of bit manipulation functions there.

I don't see a reason to make it a template. Start and End can be passed as arguments.

Please run clang-format-diff to format in the LLVM style.

You don't need a parentheses around (End + 1) because End - Start + 1 is the same as (End + 1) - Start.

ruiu added inline comments.Dec 6 2016, 1:28 PM
ELF/Target.cpp
1360

This code is not the same as before. Was the previous code wrong?

zatrazz added inline comments.Dec 7 2016, 4:05 AM
ELF/Target.cpp
1329–1338

I do not have a strong preference where to add it, although I see this implementation kinda specialized as it extracts some bits and also shift to a value (not only apply a mask).

And I made it a template so compiler have a better time optimizing it depending of the mask. For instance on x86_64, getBits<0, 11> could optimized to just:

movq    %rdi, %rax
andl    $4095, %eax

While the argument passing counterpart would have much more instructions.

I will rerun clang-format-diff and remove the parentheses.

1360

Just the function name changed for this snippet, from updateAArch64Add to updateAArch64LdStrAdd (since I am now using it to update the immediate field to load/store instructions as well).

zatrazz updated this revision to Diff 80580.Dec 7 2016, 5:24 AM
zatrazz removed rL LLVM as the repository for this revision.

Updated patch based on previous comments.

ruiu accepted this revision.Dec 7 2016, 8:52 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 7 2016, 8:52 AM
zatrazz closed this revision.Dec 7 2016, 9:42 AM