[llvm] [NFC][GlobalISel] Minor cleanup in LegalityQuery constructors (PR #126285)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 10:36:45 PST 2025


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/126285

- Remove a redundant LegalityQuert constructor by using a default value for `MMODescrs`, and remove const for ArrayRef arguments.
- Use a delegating constructor for `MemDesc` constructor that takes `MachineMemOperand`.

>From 17aeaa2d27fbbe5ba0b028361cef196271d30f72 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Fri, 7 Feb 2025 10:32:34 -0800
Subject: [PATCH] [NFC][GlobalISel] Minor cleanup in LegalityQuery constructors

- Remove a redundant LegalityQuert constructor by using a default
  value for `MMODescrs`, and remove const for ArrayRef arguments.
- Use a delegating constructor for `MemDesc` constructor that takes
  `MachineMemOperand`.
---
 llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
index 5d7e03bbaeb7dc2..9472aa196f9b4f8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -119,20 +119,17 @@ struct LegalityQuery {
     MemDesc(LLT MemoryTy, uint64_t AlignInBits, AtomicOrdering Ordering)
         : MemoryTy(MemoryTy), AlignInBits(AlignInBits), Ordering(Ordering) {}
     MemDesc(const MachineMemOperand &MMO)
-        : MemoryTy(MMO.getMemoryType()),
-          AlignInBits(MMO.getAlign().value() * 8),
-          Ordering(MMO.getSuccessOrdering()) {}
+        : MemDesc(MMO.getMemoryType(), MMO.getAlign().value() * 8,
+                  MMO.getSuccessOrdering()) {}
   };
 
   /// Operations which require memory can use this to place requirements on the
   /// memory type for each MMO.
   ArrayRef<MemDesc> MMODescrs;
 
-  constexpr LegalityQuery(unsigned Opcode, const ArrayRef<LLT> Types,
-                          const ArrayRef<MemDesc> MMODescrs)
+  constexpr LegalityQuery(unsigned Opcode, ArrayRef<LLT> Types,
+                          ArrayRef<MemDesc> MMODescrs = {})
       : Opcode(Opcode), Types(Types), MMODescrs(MMODescrs) {}
-  constexpr LegalityQuery(unsigned Opcode, const ArrayRef<LLT> Types)
-      : LegalityQuery(Opcode, Types, {}) {}
 
   raw_ostream &print(raw_ostream &OS) const;
 };



More information about the llvm-commits mailing list