[llvm] [TargetParser][NFC] Move Triple comparators out of line (PR #206032)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 04:03:13 PDT 2026
https://github.com/aengelke created https://github.com/llvm/llvm-project/pull/206032
These are not performance-critical and especially operator< is expensive
to compile due to the std::tie template instantiation.
>From 27c0f5befcbe03d7b2a5d884450c46cab287524a Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Fri, 26 Jun 2026 11:02:33 +0000
Subject: [PATCH] [spr] initial version
Created using spr 1.3.8-wip
---
llvm/include/llvm/TargetParser/Triple.h | 15 ++-------------
llvm/lib/TargetParser/Triple.cpp | 12 ++++++++++++
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 2fb28cfda053f..2540e5ab96d4b 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -387,21 +387,10 @@ class Triple {
LLVM_ABI Triple(ArchType A, SubArchType SA, VendorType V, OSType OS,
EnvironmentType E, ObjectFormatType OF);
- bool operator==(const Triple &Other) const {
- return Arch == Other.Arch && SubArch == Other.SubArch &&
- Vendor == Other.Vendor && OS == Other.OS &&
- Environment == Other.Environment &&
- ObjectFormat == Other.ObjectFormat;
- }
-
+ bool operator==(const Triple &Other) const;
bool operator!=(const Triple &Other) const { return !(*this == Other); }
- bool operator<(const Triple &Other) const {
- return std::tie(Arch, SubArch, Vendor, OS, Environment, ObjectFormat,
- Data) < std::tie(Other.Arch, Other.SubArch, Other.Vendor,
- Other.OS, Other.Environment,
- Other.ObjectFormat, Other.Data);
- }
+ bool operator<(const Triple &Other) const;
/// @}
/// @name Normalization
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 4cca24b52af94..501cf81c1b031 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -21,6 +21,18 @@
#include <cstring>
using namespace llvm;
+bool Triple::operator==(const Triple &Other) const {
+ return Arch == Other.Arch && SubArch == Other.SubArch &&
+ Vendor == Other.Vendor && OS == Other.OS &&
+ Environment == Other.Environment && ObjectFormat == Other.ObjectFormat;
+}
+
+bool Triple::operator<(const Triple &Other) const {
+ return std::tie(Arch, SubArch, Vendor, OS, Environment, ObjectFormat, Data) <
+ std::tie(Other.Arch, Other.SubArch, Other.Vendor, Other.OS,
+ Other.Environment, Other.ObjectFormat, Other.Data);
+}
+
StringRef Triple::getArchTypeName(ArchType Kind) {
switch (Kind) {
case UnknownArch:
More information about the llvm-commits
mailing list