[PATCH] D98464: [GlobalISel] Add G_SBFX + G_UBFX (bitfield extraction opcodes)

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 11:02:18 PST 2021


paquette added a comment.

I think something like this would work post-legalization:

  // We'd need these functions...
  if (isBeforeLegalizer() || !isLegal(...))
    return false;
  
  Register LshrLHS, LshrRHS;
  int64_t Mask;
  if (!mi_match(Reg, MRI,
                m_GAnd(m_GLShr(m_Reg(LshrLHS), m_Reg(LshrRHS)), m_ICst(Mask))))
    return false;
  if (/*Mask isn't a mask...*/)
    return false;
  
  if (TLI.allowsRegisterExtractOps(/*...*/)) {
    // ... Do stuff ...
    return true;
  }
  
  // Need immediates for LSB + width.
  int64_t LshrImm;
  if (!mi_match(LshrRHS, MRI, m_ICst(LshrImm)))
    return false;
  
  // ... Do stuff ...
  return true;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98464/new/

https://reviews.llvm.org/D98464



More information about the llvm-commits mailing list