This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Add more fixups and relocations
ClosedPublic

Authored by wangleiat on Aug 24 2022, 10:20 PM.

Details

Summary

This patch makes the assembler support all modifiers defined in gnu-as.
Also changes some diagnostic information.

Diff Detail

Event Timeline

wangleiat created this revision.Aug 24 2022, 10:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 10:20 PM
wangleiat requested review of this revision.Aug 24 2022, 10:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 10:20 PM
xen0n accepted this revision.Aug 25 2022, 12:19 AM

So it seems we're restricting the applicable instructions for each fixup kind, for example even if both lu12i.w and lu32i.d take a 20-bit signed immediate, the xxx64_LO20 fixups still cannot be used with lu12i.w and the xxx_HI20 ones cannot be used with lu32i.d.

Is this the same behavior as in binutils? I don't know if this is an artificial limitation to assembly expressiveness, but since I know the reloc types are deliberately designed with effectively only the linker implementation in mind, this might as well just be expected. I didn't find any other major problem though...

This revision is now accepted and ready to land.Aug 25 2022, 12:19 AM

So it seems we're restricting the applicable instructions for each fixup kind, for example even if both lu12i.w and lu32i.d take a 20-bit signed immediate, the xxx64_LO20 fixups still cannot be used with lu12i.w and the xxx_HI20 ones cannot be used with lu32i.d.

Is this the same behavior as in binutils? I don't know if this is an artificial limitation to assembly expressiveness, but since I know the reloc types are deliberately designed with effectively only the linker implementation in mind, this might as well just be expected. I didn't find any other major problem though...

(test results)
The behavior is different with binutils. Probably the current implementation of binutils doesn't care if the relocation conforms to the instruction.

wangleiat updated this revision to Diff 456886.Aug 31 2022, 1:14 AM

Address @MaskRay's comment in D132818.

Use FirstLiteralRelocationKind + ... instead some force relocations kind.

wangleiat updated this revision to Diff 456910.Aug 31 2022, 2:54 AM

Small modification: extract FirstLiteralRelocationKind

wangleiat added inline comments.Aug 31 2022, 5:48 AM
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
162

Using the relocation numbers directly looks weird. It's better to define in a header file.

wangleiat updated this revision to Diff 456940.Aug 31 2022, 5:59 AM

Move FirstLiteralRelocationKind+Type fixups to LoongArchFixupKinds.h.

MaskRay accepted this revision.Sep 1 2022, 8:44 PM
MaskRay added inline comments.
llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
174

place 12 before 14

190

The common style doesn't add parentheses in the rhs of assignments or in ? :

wangleiat added inline comments.Sep 1 2022, 11:14 PM
llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
174

place 12 before 14

Thanks, i will reorder them.
sort( (signed)Max(Shifted{U}Int<N, S>))

190

The common style doesn't add parentheses in the rhs of assignments or in ? :

Thanks.

wangleiat updated this revision to Diff 457509.Sep 1 2022, 11:31 PM

Address @MaskRay's comments.

This revision was landed with ongoing or failed builds.Sep 4 2022, 11:57 PM
This revision was automatically updated to reflect the committed changes.