aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2024-04-08 08:44:13 +0100
committerGitHub <noreply@github.com>2024-04-08 08:44:13 +0100
commitac321cbb0350996ceef4e6d9e8a1035880609288 (patch)
treec149af9ab20749b9ba69df92d705ab33b3745df1 /llvm/lib/CodeGen/MachineVerifier.cpp
parent2084a07087a55b55bb3c2a8aafbe1c4464fdf796 (diff)
downloadllvm-ac321cbb0350996ceef4e6d9e8a1035880609288.zip
llvm-ac321cbb0350996ceef4e6d9e8a1035880609288.tar.gz
llvm-ac321cbb0350996ceef4e6d9e8a1035880609288.tar.bz2
[AArch64][GlobalISel] Legalize Insert vector element (#81453)
This attempts to standardize and extend some of the insert vector element lowering. Most notably: - More types are handled by splitting illegal vectors. - The index type for G_INSERT_VECTOR_ELT is canonicalized to TLI.getVectorIdxTy(), similar to extact_vector_element. - Some of the existing patterns now have the index type specified to make sure they can apply to GISel too. - The C++ selection code has been removed, relying on tablegen patterns. - G_INSERT_VECTOR_ELT with small GPR input elements are pre-selected to use a i32 type, allowing the existing patterns to apply. - Variable index inserts are lowered in post-legalizer lowering, expanding into a stack store and reload.
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index fd7ea284..0744089 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -55,6 +55,7 @@
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
@@ -1788,6 +1789,60 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
break;
}
+ case TargetOpcode::G_EXTRACT_VECTOR_ELT: {
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ LLT SrcTy = MRI->getType(MI->getOperand(1).getReg());
+ LLT IdxTy = MRI->getType(MI->getOperand(2).getReg());
+
+ if (!DstTy.isScalar() && !DstTy.isPointer()) {
+ report("Destination type must be a scalar or pointer", MI);
+ break;
+ }
+
+ if (!SrcTy.isVector()) {
+ report("First source must be a vector", MI);
+ break;
+ }
+
+ auto TLI = MF->getSubtarget().getTargetLowering();
+ if (IdxTy.getSizeInBits() !=
+ TLI->getVectorIdxTy(MF->getDataLayout()).getFixedSizeInBits()) {
+ report("Index type must match VectorIdxTy", MI);
+ break;
+ }
+
+ break;
+ }
+ case TargetOpcode::G_INSERT_VECTOR_ELT: {
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ LLT VecTy = MRI->getType(MI->getOperand(1).getReg());
+ LLT ScaTy = MRI->getType(MI->getOperand(2).getReg());
+ LLT IdxTy = MRI->getType(MI->getOperand(3).getReg());
+
+ if (!DstTy.isVector()) {
+ report("Destination type must be a vector", MI);
+ break;
+ }
+
+ if (VecTy != DstTy) {
+ report("Destination type and vector type must match", MI);
+ break;
+ }
+
+ if (!ScaTy.isScalar() && !ScaTy.isPointer()) {
+ report("Inserted element must be a scalar or pointer", MI);
+ break;
+ }
+
+ auto TLI = MF->getSubtarget().getTargetLowering();
+ if (IdxTy.getSizeInBits() !=
+ TLI->getVectorIdxTy(MF->getDataLayout()).getFixedSizeInBits()) {
+ report("Index type must match VectorIdxTy", MI);
+ break;
+ }
+
+ break;
+ }
case TargetOpcode::G_DYN_STACKALLOC: {
const MachineOperand &DstOp = MI->getOperand(0);
const MachineOperand &AllocOp = MI->getOperand(1);