Initial support for Hexagon target.
ClosedPublic

Authored by sidneym on Jun 5 2018, 11:05 AM.

Details

Summary

Support B22_PCREL relocation along with a simple test.

I'm also working on a llvmSupport patch that will detail the instruction set encoding. Many of Hexagon's instructions have immediates that are peppered throughout the word makeing application of fixups tedious since the same relocation fixup may need to be placed in different bits depending on the instruction. That change will be made in llvmSupport so that both lld and llvm-rtdyld can share encoding information.

Diff Detail

Repository
rL LLVM
sidneym created this revision.Jun 5 2018, 11:05 AM
ruiu added inline comments.Jun 5 2018, 11:09 AM
ELF/Arch/Hexagon.cpp
46 ↗(On Diff #149991)

sizeof(uint32_t) * 8 is always 32.

77 ↗(On Diff #149991)

Remove extraneous blank line. If you take a look at other files in lld, you'd notice that we normally don't add a blank line before "default:".

test/ELF/Inputs/hexagon.s
1 ↗(On Diff #149991)

Remove a leading empty line.

test/ELF/hexagon.s
2 ↗(On Diff #149991)

Remove extranesous space between "mc" and "-filetype"

9 ↗(On Diff #149991)

Remove extraneous space characters.

sidneym updated this revision to Diff 150013.Jun 5 2018, 11:23 AM

Made the changes Rui suggested.

ruiu added inline comments.Jun 5 2018, 11:27 AM
ELF/Arch/Hexagon.cpp
47 ↗(On Diff #150013)

We normally don't add const if the variable's scope is narrow.

72 ↗(On Diff #150013)

We usually use much shorter variable name for a variable whose scope is very narrow. Just V would be enough for this.

74 ↗(On Diff #150013)

I believe we have or32le.

sidneym updated this revision to Diff 150150.Jun 6 2018, 9:01 AM

Adopted more of Rui's suggestions.

ruiu added inline comments.Jun 6 2018, 11:27 AM
ELF/Arch/Hexagon.cpp
26 ↗(On Diff #150150)

Please read other files in the same directory and follow the same naming convention. This should be named just Hexagon.

38 ↗(On Diff #150150)

You don't need this assert as you are not depending on it.

50 ↗(On Diff #150150)

I believe ValBit (which is bool) is promoted to int because of the usual integer promotion before << is applied, but this is perhaps a bit confusing. It is better to make their types uint32_t.

73 ↗(On Diff #150150)

You don't need {} if you do not define a new variable inside {}.

sidneym updated this revision to Diff 150429.Jun 7 2018, 4:26 PM

Integrated suggested changes.

ruiu added inline comments.Jun 7 2018, 4:34 PM
ELF/Arch/Hexagon.cpp
46–47 ↗(On Diff #150429)

Please do not use auto as well. As I said, if you read other code in this directory or other directories in lld, you'd notice that we normally don't use auto unless its type is obvious (i.e. to avoid a repetition like Foo *X = dyn_cast<Foo>(Y)). I'd be more careful to follow the convention by reading code first.

sidneym updated this revision to Diff 151139.Jun 13 2018, 6:10 AM

Use type instead of auto.

ruiu accepted this revision.Jun 13 2018, 10:54 AM
ruiu added inline comments.
ELF/Arch/Hexagon.cpp
41 ↗(On Diff #151139)

I think it needs a comment, but I'll do that in a follow-up patch.

This revision is now accepted and ready to land.Jun 13 2018, 10:54 AM
Closed by commit rL334637: Add Hexagon Support (authored by sidneym, committed by ). · Explain WhyJun 13 2018, 11:49 AM
This revision was automatically updated to reflect the committed changes.