[PATCH] D140872: [LoongArch] Add "32bit" target feature
Xiaodong Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 00:31:30 PST 2023
XiaodongLoong updated this revision to Diff 486182.
XiaodongLoong added a comment.
rebase code and improve error message.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140872/new/
https://reviews.llvm.org/D140872
Files:
llvm/lib/Target/LoongArch/LoongArch.td
llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
llvm/lib/Target/LoongArch/LoongArchSubtarget.h
llvm/test/CodeGen/LoongArch/feature-32bit.ll
Index: llvm/test/CodeGen/LoongArch/feature-32bit.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/feature-32bit.ll
@@ -0,0 +1,5 @@
+; RUN: llc --mtriple=loongarch64 --mattr=help 2>&1 | FileCheck %s
+; RUN: llc --mtriple=loongarch32 --mattr=help 2>&1 | FileCheck %s
+
+; CHECK: Available features for this target:
+; CHECK: 32bit - LA32 Basic Integer and Privilege Instruction Set.
Index: llvm/lib/Target/LoongArch/LoongArchSubtarget.h
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchSubtarget.h
+++ llvm/lib/Target/LoongArch/LoongArchSubtarget.h
@@ -31,6 +31,7 @@
class LoongArchSubtarget : public LoongArchGenSubtargetInfo {
virtual void anchor();
+ bool HasLA32 = false;
bool HasLA64 = false;
bool HasBasicF = false;
bool HasBasicD = false;
Index: llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
+++ llvm/lib/Target/LoongArch/LoongArchSubtarget.cpp
@@ -39,6 +39,15 @@
GRLen = 64;
}
+ if (HasLA32 == HasLA64)
+ report_fatal_error("Please use one feature of 32bit and 64bit.");
+
+ if (Is64Bit && HasLA32)
+ report_fatal_error("Feature 32bit should be used for loongarch32 target.");
+
+ if (!Is64Bit && HasLA64)
+ report_fatal_error("Feature 64bit should be used for loongarch64 target.");
+
// TODO: ILP32{S,F} LP64{S,F}
TargetABI = Is64Bit ? LoongArchABI::ABI_LP64D : LoongArchABI::ABI_ILP32D;
return *this;
Index: llvm/lib/Target/LoongArch/LoongArch.td
===================================================================
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -17,6 +17,9 @@
def Feature64Bit
: SubtargetFeature<"64bit", "HasLA64", "true",
"LA64 Basic Integer and Privilege Instruction Set">;
+def Feature32Bit
+ : SubtargetFeature<"32bit", "HasLA32", "true",
+ "LA32 Basic Integer and Privilege Instruction Set">;
def IsLA64
: Predicate<"Subtarget->is64Bit()">,
AssemblerPredicate<(all_of Feature64Bit),
@@ -124,7 +127,7 @@
// LoongArch processors supported.
//===----------------------------------------------------------------------===//
-def : ProcessorModel<"generic-la32", NoSchedModel, []>;
+def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit]>;
// Support generic for compatibility with other targets. The triple will be used
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140872.486182.patch
Type: text/x-patch
Size: 2641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230104/131cdf3c/attachment.bin>
More information about the llvm-commits
mailing list