-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[DAG] Add SDPatternMatch::m_Load
#145481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DAG] Add SDPatternMatch::m_Load
#145481
Conversation
template <typename T0_P, typename T1_P, typename T2_P> | ||
inline TernaryOpc_match<T0_P, T1_P, T2_P> | ||
m_Load(const T0_P &Ch, const T1_P &Ptr, const T2_P &Offset) { | ||
return TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::LOAD, Ch, Ptr, Offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this match for both Load.getValue(0) (the loaded value) and Load.getValue(1) (the out chain)? Or should we have a template/run arg to match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a way to distinguish which (SDValue) result to match would indeed be helpful. For instance, to match a SDNode with optional input chain, we can't tell if operand 0 is a chain or not, other than something like m_AllOf(m_SpecificVT(MVT::Other), <matcher for operand 0>)
or using a matching class that uses EffectiveOperand
, which skips over chains and glues (but not every matching classes use it).
Not necessary for this patch, but we might want a more general solution, for instance m_Result<0>(m_Load(...))
for matching the first result of a load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - for now let's just match against ResNo == 0 as that's what most people will expect from m_Load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When #145775 lands this will need to be:
return m_Result<0>(TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::LOAD, Ch, Ptr, Offset));
The failed test looks unrelated to this @RKSimon @mshockwave are there any changes required here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please add a patch description though
template <typename T0_P, typename T1_P, typename T2_P> | ||
inline TernaryOpc_match<T0_P, T1_P, T2_P> | ||
m_Load(const T0_P &Ch, const T1_P &Ptr, const T2_P &Offset) { | ||
return TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::LOAD, Ch, Ptr, Offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When #145775 lands this will need to be:
return m_Result<0>(TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::LOAD, Ch, Ptr, Offset));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
…llvm#145775) `m_Result<N>` matches a SDValue that is the N-th result of the defining SDNode. This is useful for creating a more fine-grained matching on SDNode with multiple results. ----- Inspired by llvm#145481
Add SDPatternMatch matcher and unit test coverage for `ISD::LOAD` opcode. This only matches the loaded value i.e. ResNo 0 and not the output chain. e.g. ``` m_Load(m_Value(), m_Value(), m_Value()) ``` The first value is the input chain, the second is the base pointer, and the last value is the offset.
…llvm#145775) `m_Result<N>` matches a SDValue that is the N-th result of the defining SDNode. This is useful for creating a more fine-grained matching on SDNode with multiple results. ----- Inspired by llvm#145481
Add SDPatternMatch matcher and unit test coverage for `ISD::LOAD` opcode. This only matches the loaded value i.e. ResNo 0 and not the output chain. e.g. ``` m_Load(m_Value(), m_Value(), m_Value()) ``` The first value is the input chain, the second is the base pointer, and the last value is the offset.
Add SDPatternMatch matcher and unit test coverage for
ISD::LOAD
opcode.This only matches the loaded value i.e. ResNo 0 and not the output chain.
e.g.
The first value is the input chain, the second is the base pointer, and the last value is the offset.