[Attributor] Add helper class to compose two structured deduction.
authorHideto Ueno <uenoku.tokotoko@gmail.com>
Tue, 8 Oct 2019 15:20:19 +0000 (15:20 +0000)
committerHideto Ueno <uenoku.tokotoko@gmail.com>
Tue, 8 Oct 2019 15:20:19 +0000 (15:20 +0000)
Summary: This patch introduces a generic way to compose two structured deductions.  This will be used for composing generic deduction with `MustBeExecutedExplorer` and other existing generic deduction.

Reviewers: jdoerfert, sstefan1

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 374060

llvm/lib/Transforms/IPO/Attributor.cpp

index 629be92..3a15622 100644 (file)
@@ -560,6 +560,21 @@ static void clampReturnedValueStates(Attributor &A, const AAType &QueryingAA,
     S ^= *T;
 }
 
+/// Helper class to compose two generic deduction
+template <typename AAType, typename Base, typename StateType,
+          template <typename...> class F, template <typename...> class G>
+struct AAComposeTwoGenericDeduction
+    : public F<AAType, G<AAType, Base, StateType>, StateType> {
+  AAComposeTwoGenericDeduction(const IRPosition &IRP)
+      : F<AAType, G<AAType, Base, StateType>, StateType>(IRP) {}
+
+  /// See AbstractAttribute::updateImpl(...).
+  ChangeStatus updateImpl(Attributor &A) override {
+    return F<AAType, G<AAType, Base, StateType>, StateType>::updateImpl(A) |
+           G<AAType, Base, StateType>::updateImpl(A);
+  }
+};
+
 /// Helper class for generic deduction: return value -> returned position.
 template <typename AAType, typename Base,
           typename StateType = typename AAType::StateType>