Skip to content

Conversation

@jurahul
Copy link
Contributor

@jurahul jurahul commented Feb 7, 2025

  • Remove a redundant LegalityQuery constructor by using a default value for MMODescrs and remove const for ArrayRef arguments.
  • Use a delegating constructor for MemDesc constructor that takes MachineMemOperand.

- 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`.
@jurahul jurahul marked this pull request as ready for review February 7, 2025 20:37
@jurahul jurahul requested a review from arsenm February 7, 2025 20:37
@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-llvm-globalisel

Author: Rahul Joshi (jurahul)

Changes
  • Remove a redundant LegalityQuery constructor by using a default value for MMODescrs and remove const for ArrayRef arguments.
  • Use a delegating constructor for MemDesc constructor that takes MachineMemOperand.

Full diff: https://github.com/llvm/llvm-project/pull/126285.diff

1 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h (+4-7)
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;
 };

@jurahul jurahul requested a review from topperc February 7, 2025 20:56
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jurahul jurahul merged commit fb1216e into llvm:main Feb 7, 2025
12 checks passed
@jurahul jurahul deleted the nfc_LegalityQuery_ctor branch February 7, 2025 21:07
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…26285)

- Remove a redundant LegalityQuery constructor by using a default value
for `MMODescrs` and remove const for ArrayRef arguments.
- Use a delegating constructor for `MemDesc` constructor that takes
`MachineMemOperand`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants