This is an archive of the discontinued LLVM Phabricator instance.

[CSKY 1/n] Add basic stub or infra of csky backend
ClosedPublic

Authored by zixuan-wu on Sep 28 2020, 9:52 PM.

Details

Summary

This patch introduce files that just enough for lib/Target/CSKY to compile.
Notably a basic CSKYTargetMachine and CSKYTargetInfo.

Diff Detail

Event Timeline

zixuan-wu created this revision.Sep 28 2020, 9:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2020, 9:52 PM
zixuan-wu requested review of this revision.Sep 28 2020, 9:52 PM
zixuan-wu added a reviewer: craig.topper.

Gentle ping...
BTW, @lattner would you know who is the decision maker that can approve a new target and review related commit?

The general process is here: https://llvm.org/docs/DeveloperPolicy.html#adding-a-new-target

I'm sorry that I'm preoccupied with the devmtg this week, but please ping me next week if you're not getting traction, thanks!

Mostly boilerplate that looks fine, a few minor nits.

llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
32

Minor nit, but hopefully anyone reading this knows what e means from reading the LangRef. It would be more useful for this comment to give a summary of what is happening here specifically, for example 'CSky is always little endian with a 4-byte aligned stack'

36

If the endian and stack alignment are the same for every instance of this back end, you don't need to add them separately. The same is true for all of the things after the mangling flag.

38

Does CSky really support all of the manglings that this can return? Including Windows x86 mangling? If not, please add some asserts to validate that it's a sane value.

71

Why make this a separate function instead of just writing this on line 84:

(RM.hasValue() ? *RM : Reloc::Static),

The general process is here: https://llvm.org/docs/DeveloperPolicy.html#adding-a-new-target

I'm sorry that I'm preoccupied with the devmtg this week, but please ping me next week if you're not getting traction, thanks!

The general process is clear but there is not info about who is main reviewer can approve threading patches.

zixuan-wu updated this revision to Diff 297119.Oct 8 2020, 8:57 PM

Address comments.

zixuan-wu marked 4 inline comments as done.Oct 8 2020, 8:57 PM
theraven accepted this revision.Oct 9 2020, 1:06 AM

I lost track of the mailing list discussions, but assuming that there is consensus to accept this back end I am happy with the structure of the initial code, the size of the contributed diffs, and the engagement from the maintainer.

This revision is now accepted and ready to land.Oct 9 2020, 1:06 AM

I lost track of the mailing list discussions, but assuming that there is consensus to accept this back end I am happy with the structure of the initial code, the size of the contributed diffs, and the engagement from the maintainer.

Thank you!

zixuan-wu edited the summary of this revision. (Show Details)Oct 9 2020, 7:44 PM
This revision was automatically updated to reflect the committed changes.
Arfrever added inline comments.
llvm/lib/Target/CSKY/TargetInfo/CSKYTargetInfo.cpp
18

This needs LLVM_EXTERNAL_VISIBILITY:

extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTargetInfo() {

To avoid error:

FAILED: lib/libLTO.so.12 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -fPIC -march=native -O2  -pipe -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections  -fuse-ld=bfd -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--gc-sections -Wl,--sort-common -Wl,-z,now -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/var/tmp/portage/sys-devel/llvm-12.0.0.9999/work/llvm_build-abi_x86_32.x86/./lib  -Wl,-O3 -Wl,--gc-sections  -Wl,--version-script,"/var/tmp/portage/sys-devel/llvm-12.0.0.9999/work/llvm_build-abi_x86_32.x86/tools/lto/LTO.exports" -shared -Wl,-soname,libLTO.so.12 -o lib/libLTO.so.12 tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o tools/lto/CMakeFiles/LTO.dir/lto.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVM-12git.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: tools/lto/CMakeFiles/LTO.dir/lto.cpp.o: in function `lto_initialize()':
lto.cpp:(.text._ZL14lto_initializev+0x7e): undefined reference to `LLVMInitializeCSKYTargetInfo'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: lto.cpp:(.text._ZL14lto_initializev+0xe2): undefined reference to `LLVMInitializeCSKYTargetInfo'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o: in function `lto_initialize_disassembler':
LTODisassembler.cpp:(.text.lto_initialize_disassembler+0x49): undefined reference to `LLVMInitializeCSKYTargetInfo'
collect2: error: ld returned 1 exit status
zixuan-wu added inline comments.Jan 11 2021, 12:27 AM
llvm/lib/Target/CSKY/TargetInfo/CSKYTargetInfo.cpp
18

This needs LLVM_EXTERNAL_VISIBILITY:

extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTargetInfo() {

To avoid error:

FAILED: lib/libLTO.so.12 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -fPIC -march=native -O2  -pipe -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections  -fuse-ld=bfd -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--gc-sections -Wl,--sort-common -Wl,-z,now -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/var/tmp/portage/sys-devel/llvm-12.0.0.9999/work/llvm_build-abi_x86_32.x86/./lib  -Wl,-O3 -Wl,--gc-sections  -Wl,--version-script,"/var/tmp/portage/sys-devel/llvm-12.0.0.9999/work/llvm_build-abi_x86_32.x86/tools/lto/LTO.exports" -shared -Wl,-soname,libLTO.so.12 -o lib/libLTO.so.12 tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o tools/lto/CMakeFiles/LTO.dir/lto.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVM-12git.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: tools/lto/CMakeFiles/LTO.dir/lto.cpp.o: in function `lto_initialize()':
lto.cpp:(.text._ZL14lto_initializev+0x7e): undefined reference to `LLVMInitializeCSKYTargetInfo'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: lto.cpp:(.text._ZL14lto_initializev+0xe2): undefined reference to `LLVMInitializeCSKYTargetInfo'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o: in function `lto_initialize_disassembler':
LTODisassembler.cpp:(.text.lto_initialize_disassembler+0x49): undefined reference to `LLVMInitializeCSKYTargetInfo'
collect2: error: ld returned 1 exit status

Sorry to miss the notify.
It's fixed at https://reviews.llvm.org/rGcddd3faf5debdfd2c09bb5b723f579fa8c8d5027.