[Triple] Add llvm::Triple::isSPARC{,32,64}
authorXiaodong Liu <liuxiaodong@loongson.cn>
Fri, 25 Feb 2022 21:50:34 +0000 (21:50 +0000)
committerFangrui Song <i@maskray.me>
Fri, 25 Feb 2022 21:50:34 +0000 (21:50 +0000)
Reviewed By: ro, MaskRay

Differential Revision: https://reviews.llvm.org/D120381

llvm/include/llvm/ADT/Triple.h

index 6cf90fd..5e989d5 100644 (file)
@@ -824,6 +824,17 @@ public:
     return getArch() == Triple::riscv32 || getArch() == Triple::riscv64;
   }
 
+  /// Tests whether the target is 32-bit SPARC (little and big endian).
+  bool isSPARC32() const {
+    return getArch() == Triple::sparc || getArch() == Triple::sparcel;
+  }
+
+  /// Tests whether the target is 64-bit SPARC (big endian).
+  bool isSPARC64() const { return getArch() == Triple::sparcv9; }
+
+  /// Tests whether the target is SPARC.
+  bool isSPARC() const { return isSPARC32() || isSPARC64(); }
+
   /// Tests whether the target is SystemZ.
   bool isSystemZ() const {
     return getArch() == Triple::systemz;