diff options
author | Jessica Paquette <jpaquette@apple.com> | 2021-03-11 15:36:01 -0800 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2021-03-19 14:37:19 -0700 |
commit | 4773dd5ba9993e127586a5e5b1993d431a47372c (patch) | |
tree | 9d27b8eeed9b30089592705880f39ac83577f5e2 /llvm/lib/CodeGen/MachineVerifier.cpp | |
parent | cde203e0f9438a4bba3b9b50bd437444852b9909 (diff) | |
download | llvm-4773dd5ba9993e127586a5e5b1993d431a47372c.zip llvm-4773dd5ba9993e127586a5e5b1993d431a47372c.tar.gz llvm-4773dd5ba9993e127586a5e5b1993d431a47372c.tar.bz2 |
[GlobalISel] Add G_SBFX + G_UBFX (bitfield extraction opcodes)
There is a bunch of similar bitfield extraction code throughout *ISelDAGToDAG.
E.g, ARMISelDAGToDAG, AArch64ISelDAGToDAG, and AMDGPUISelDAGToDAG all contain
code that matches a bitfield extract from an and + right shift.
Rather than duplicating code in the same way, this adds two opcodes:
- G_UBFX (unsigned bitfield extract)
- G_SBFX (signed bitfield extract)
They work like this
```
%x = G_UBFX %y, %lsb, %width
```
Where `lsb` and `width` are
- The least-significant bit of the extraction
- The width of the extraction
This will extract `width` bits from `%y`, starting at `lsb`. G_UBFX zero-extends
the result, while G_SBFX sign-extends the result.
This should allow us to use the combiner to match the bitfield extraction
patterns rather than duplicating pattern-matching code in each target.
Differential Revision: https://reviews.llvm.org/D98464
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 57eb944..af8b84e 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1566,6 +1566,17 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { report("Vector reduction requires vector source=", MI); break; } + + case TargetOpcode::G_SBFX: + case TargetOpcode::G_UBFX: { + LLT DstTy = MRI->getType(MI->getOperand(0).getReg()); + if (DstTy.isVector()) { + report("Bitfield extraction is not supported on vectors", MI); + break; + } + break; + } + default: break; } |