Page MenuHomePhabricator

[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

Unit TestsFailed

TimeTest
60,050 msx64 debian > MLIR.Examples/standalone::test.toy
Script: -- : 'RUN: at line 1'; /usr/bin/cmake /var/lib/buildkite-agent/builds/llvm-project/mlir/examples/standalone -G "Ninja" -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/var/lib/buildkite-agent/builds/llvm-project/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld

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
28

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.