This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Add some fixups and relocations
ClosedPublic

Authored by wangleiat on Aug 18 2022, 12:34 AM.

Details

Summary

This patch only add %pc_hi20/%pc_lo12/%plt relocations in order
to be able to generate gnu ld linkable relocation file for the
hello world IR :

@.str = private unnamed_addr constant [14 x i8] c"Hello world!\0A\00", align 1

define dso_local signext i32 @main() nounwind {
entry:
  %call = call signext i32 (ptr, ...) @printf(ptr noundef @.str)
  ret i32 0
}

declare dso_local signext i32 @printf(ptr noundef, ...)

This patch also updated some test cases due to new modifiers.
New test: test/MC/LoongArch/Relocations/relocations.s

Diff Detail

Event Timeline

wangleiat created this revision.Aug 18 2022, 12:34 AM
wangleiat requested review of this revision.Aug 18 2022, 12:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 12:34 AM
xen0n added a comment.Aug 18 2022, 1:49 AM

This is something we all have been longing for. I'm still studying the other targets for the current coding practices in this area but at least the test case changes seem very sane. Many thanks.

Can't wait to run some native tests with this applied ;-)

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
27

From a quick grep, the middle part should be spelled the same as the target name, i.e. the names should look like VK_LoongArch_XXX instead. Don't use the binutils convention ("LARCH") as the "larch" abbreviation is in fact not seen anywhere outside binutils.

wangleiat updated this revision to Diff 453588.Aug 18 2022, 2:30 AM

Address @xen0n's comment.

xen0n accepted this revision.Aug 18 2022, 2:32 AM

LGTM with the nit resolved. Others, opinions?

This revision is now accepted and ready to land.Aug 18 2022, 2:32 AM
wangleiat updated this revision to Diff 453591.Aug 18 2022, 2:34 AM

test case change larch to loongarch

SixWeining accepted this revision.Aug 19 2022, 7:06 PM
This revision was landed with ongoing or failed builds.Aug 19 2022, 8:46 PM
This revision was automatically updated to reflect the committed changes.