[PATCH] D138016: [Object] Add some more LoongArch support
WÁNG Xuěruì via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 26 00:49:39 PST 2022
xen0n updated this revision to Diff 478048.
xen0n added a comment.
rebase and add to unit test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138016/new/
https://reviews.llvm.org/D138016
Files:
llvm/include/llvm/Object/ELFObjectFile.h
llvm/lib/Object/ELF.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/unittests/Object/ELFTest.cpp
Index: llvm/unittests/Object/ELFTest.cpp
===================================================================
--- llvm/unittests/Object/ELFTest.cpp
+++ llvm/unittests/Object/ELFTest.cpp
@@ -237,6 +237,7 @@
TEST(ELFTest, getELFRelativeRelocationType) {
EXPECT_EQ(ELF::R_VE_RELATIVE, getELFRelativeRelocationType(EM_VE));
+ EXPECT_EQ(ELF::R_LARCH_RELATIVE, getELFRelativeRelocationType(EM_LOONGARCH));
}
// This is a test for the DataRegion helper struct, defined in ELF.h header.
Index: llvm/lib/Object/ELFObjectFile.cpp
===================================================================
--- llvm/lib/Object/ELFObjectFile.cpp
+++ llvm/lib/Object/ELFObjectFile.cpp
@@ -342,6 +342,26 @@
return Features;
}
+SubtargetFeatures ELFObjectFileBase::getLoongArchFeatures() const {
+ SubtargetFeatures Features;
+
+ switch (getPlatformFlags() & ELF::EF_LOONGARCH_ABI_MODIFIER_MASK) {
+ case ELF::EF_LOONGARCH_ABI_SOFT_FLOAT:
+ break;
+ case ELF::EF_LOONGARCH_ABI_DOUBLE_FLOAT:
+ Features.AddFeature("d");
+ // D implies F according to LoongArch ISA spec.
+ // It's only two features so don't bother with [[fallthrough]] at present.
+ Features.AddFeature("f");
+ break;
+ case ELF::EF_LOONGARCH_ABI_SINGLE_FLOAT:
+ Features.AddFeature("f");
+ break;
+ }
+
+ return Features;
+}
+
SubtargetFeatures ELFObjectFileBase::getFeatures() const {
switch (getEMachine()) {
case ELF::EM_MIPS:
@@ -350,6 +370,8 @@
return getARMFeatures();
case ELF::EM_RISCV:
return getRISCVFeatures();
+ case ELF::EM_LOONGARCH:
+ return getLoongArchFeatures();
default:
return SubtargetFeatures();
}
Index: llvm/lib/Object/ELF.cpp
===================================================================
--- llvm/lib/Object/ELF.cpp
+++ llvm/lib/Object/ELF.cpp
@@ -223,6 +223,8 @@
break;
case ELF::EM_BPF:
break;
+ case ELF::EM_LOONGARCH:
+ return ELF::R_LARCH_RELATIVE;
default:
break;
}
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -56,6 +56,7 @@
SubtargetFeatures getMIPSFeatures() const;
SubtargetFeatures getARMFeatures() const;
SubtargetFeatures getRISCVFeatures() const;
+ SubtargetFeatures getLoongArchFeatures() const;
StringRef getAMDGPUCPUName() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138016.478048.patch
Type: text/x-patch
Size: 2412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221126/a2a888ca/attachment.bin>
More information about the llvm-commits
mailing list