[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 23 11:09:05 PDT 2022
MaskRay added inline comments.
================
Comment at: clang/lib/Basic/Targets/LoongArch.h:24
+
+class LoongArchTargetInfo : public TargetInfo {
+protected:
----------------
LLVM_LIBRARY_VISIBILITY
================
Comment at: clang/lib/Basic/Targets/LoongArch.h:35
+ SuitableAlign = 128;
+ WIntType = UnsignedInt;
+ }
----------------
Define `WCharType`
================
Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.h:15
+#include "llvm/Option/Option.h"
+#include <string>
+#include <vector>
----------------
Delete unused `<string> <vector>`
================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:305
return "cskyelf_linux";
+ case llvm::Triple::loongarch32:
+ return "elf32loongarch";
----------------
Can be added before mips. Seems that some cases are unsorted. Just ignore them.
================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2226
+ static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
+ static const char *const LoongArch64Triples[] = {
----------------
I don't know which of /lib64, /lib has been used. For purity, I'd hope that we just have /lib, no multilib style /lib64
================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2478
+ // TODO: Handle loongarch32.
+ case llvm::Triple::loongarch64:
+ LibDirs.append(begin(LoongArch64LibDirs), end(LoongArch64LibDirs));
----------------
Just add loongarch32 in this patch. It is trivial
================
Comment at: clang/test/Driver/loongarch64-toolchain.c:20
+// C-LA64-LINUX-MULTI-LP64D: "-dynamic-linker" "/lib64/ld-linux-loongarch-lp64d.so.1"
+// C-LA64-LINUX-MULTI-LP64D: "{{.*}}/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o"
+// C-LA64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0"
----------------
Not using NEXT is somewhat brittle.
Perhaps add `loongarch-toolchain.c` instead. `riscv*-toolchain.c` are not good examples to follow. You may check out linux-cross.cpp
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130255/new/
https://reviews.llvm.org/D130255
More information about the cfe-commits
mailing list