[BPF] Triple::isBPF() utility method
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 7 Jan 2023 06:35:25 +0000 (22:35 -0800)
committerYonghong Song <yhs@fb.com>
Sat, 7 Jan 2023 06:36:52 +0000 (22:36 -0800)
Adds a utility method llvm::Triple::isBPF() aggregating Triple::bpfel
and Triple::bpfeb architectures. Similar to other predicates in this class.

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

llvm/include/llvm/TargetParser/Triple.h

index 3db4194..8d60098 100644 (file)
@@ -939,6 +939,11 @@ public:
     return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests whether the target is eBPF.
+  bool isBPF() const {
+    return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
+  }
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
     return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||