From c5f936ea9a6ba63591eda35d2859755eb935fa55 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 25 Jul 2020 11:12:29 -0400 Subject: [PATCH] GlobalISel: Add typeIsNot LegalityPredicate This allows sorting the legal/custom rules first as is recommended --- include/llvm/CodeGen/GlobalISel/LegalizerInfo.h | 10 +++++++++- lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h index b50d7cd7a5f..7123aff36cd 100644 --- a/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h +++ b/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h @@ -218,11 +218,19 @@ Predicate any(Predicate P0, Predicate P1, Args... args) { return any(any(P0, P1), args...); } -/// True iff the given type index is the specified types. +/// True iff the given type index is the specified type. LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit); /// True iff the given type index is one of the specified types. LegalityPredicate typeInSet(unsigned TypeIdx, std::initializer_list TypesInit); + +/// True iff the given type index is not the specified type. +inline LegalityPredicate typeIsNot(unsigned TypeIdx, LLT Type) { + return [=](const LegalityQuery &Query) { + return Query.Types[TypeIdx] != Type; + }; +} + /// True iff the given types for the given pair of type indexes is one of the /// specified type pairs. LegalityPredicate diff --git a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index e14623e650d..27031d789aa 100644 --- a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -551,8 +551,8 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_, .legalFor({{PrivatePtr, S32}}); getActionDefinitionsBuilder(G_GLOBAL_VALUE) - .unsupportedFor({PrivatePtr}) - .custom(); + .customIf(typeIsNot(0, PrivatePtr)); + setAction({G_BLOCK_ADDR, CodePtr}, Legal); auto &FPOpActions = getActionDefinitionsBuilder(