@@ -1326,7 +1326,7 @@ bool SPIRVInstructionSelector::selectAtomicRMW(Register ResVReg,
13261326 Register ValueReg = I.getOperand (2 ).getReg ();
13271327 if (NegateOpcode != 0 ) {
13281328 // Translation with negative value operand is requested
1329- Register TmpReg = MRI-> createVirtualRegister (&SPIRV::iIDRegClass );
1329+ Register TmpReg = createVirtualRegister (ResType, &GR, MRI, MRI-> getMF () );
13301330 Result &= selectOpWithSrcs (TmpReg, ResType, I, {ValueReg}, NegateOpcode);
13311331 ValueReg = TmpReg;
13321332 }
@@ -1504,7 +1504,6 @@ bool SPIRVInstructionSelector::selectAtomicCmpXchg(Register ResVReg,
15041504 Register Val = I.getOperand (4 ).getReg ();
15051505 SPIRVType *SpvValTy = GR.getSPIRVTypeForVReg (Val);
15061506 Register ACmpRes = createVirtualRegister (SpvValTy, &GR, MRI, *I.getMF ());
1507- // MRI->createVirtualRegister(&SPIRV::iIDRegClass);
15081507 const DebugLoc &DL = I.getDebugLoc ();
15091508 Result &=
15101509 BuildMI (*I.getParent (), I, DL, TII.get (SPIRV::OpAtomicCompareExchange))
@@ -1517,15 +1516,15 @@ bool SPIRVInstructionSelector::selectAtomicCmpXchg(Register ResVReg,
15171516 .addUse (Val)
15181517 .addUse (Cmp)
15191518 .constrainAllUses (TII, TRI, RBI);
1520- Register CmpSuccReg = MRI->createVirtualRegister (&SPIRV::iIDRegClass);
15211519 SPIRVType *BoolTy = GR.getOrCreateSPIRVBoolType (I, TII);
1520+ Register CmpSuccReg = createVirtualRegister (BoolTy, &GR, MRI, *I.getMF ());
15221521 Result &= BuildMI (*I.getParent (), I, DL, TII.get (SPIRV::OpIEqual))
15231522 .addDef (CmpSuccReg)
15241523 .addUse (GR.getSPIRVTypeID (BoolTy))
15251524 .addUse (ACmpRes)
15261525 .addUse (Cmp)
15271526 .constrainAllUses (TII, TRI, RBI);
1528- Register TmpReg = MRI-> createVirtualRegister (&SPIRV::iIDRegClass );
1527+ Register TmpReg = createVirtualRegister (ResType, &GR, MRI, *I. getMF () );
15291528 Result &= BuildMI (*I.getParent (), I, DL, TII.get (SPIRV::OpCompositeInsert))
15301529 .addDef (TmpReg)
15311530 .addUse (GR.getSPIRVTypeID (ResType))
@@ -1687,9 +1686,9 @@ bool SPIRVInstructionSelector::selectAddrSpaceCast(Register ResVReg,
16871686 return selectUnOp (ResVReg, ResType, I, SPIRV::OpGenericCastToPtr);
16881687 // Casting between 2 eligible pointers using Generic as an intermediary.
16891688 if (isGenericCastablePtr (SrcSC) && isGenericCastablePtr (DstSC)) {
1690- Register Tmp = MRI->createVirtualRegister (&SPIRV::iIDRegClass);
16911689 SPIRVType *GenericPtrTy = GR.getOrCreateSPIRVPointerType (
16921690 GR.getPointeeType (SrcPtrTy), I, TII, SPIRV::StorageClass::Generic);
1691+ Register Tmp = createVirtualRegister (GenericPtrTy, &GR, MRI, MRI->getMF ());
16931692 bool Result = BuildMI (BB, I, DL, TII.get (SPIRV::OpPtrCastToGeneric))
16941693 .addDef (Tmp)
16951694 .addUse (GR.getSPIRVTypeID (GenericPtrTy))
@@ -1863,8 +1862,9 @@ bool SPIRVInstructionSelector::selectAnyOrAll(Register ResVReg,
18631862 Register NotEqualReg = ResVReg;
18641863
18651864 if (IsVectorTy) {
1866- NotEqualReg = IsBoolTy ? InputRegister
1867- : MRI->createVirtualRegister (&SPIRV::iIDRegClass);
1865+ NotEqualReg =
1866+ IsBoolTy ? InputRegister
1867+ : createVirtualRegister (SpvBoolTy, &GR, MRI, MRI->getMF ());
18681868 const unsigned NumElts = InputType->getOperand (2 ).getImm ();
18691869 SpvBoolTy = GR.getOrCreateSPIRVVectorType (SpvBoolTy, NumElts, I, TII);
18701870 }
@@ -2574,7 +2574,7 @@ bool SPIRVInstructionSelector::selectIToF(Register ResVReg,
25742574 const unsigned NumElts = ResType->getOperand (2 ).getImm ();
25752575 TmpType = GR.getOrCreateSPIRVVectorType (TmpType, NumElts, I, TII);
25762576 }
2577- SrcReg = MRI-> createVirtualRegister (&SPIRV::iIDRegClass );
2577+ SrcReg = createVirtualRegister (TmpType, &GR, MRI, MRI-> getMF () );
25782578 selectSelect (SrcReg, TmpType, I, false );
25792579 }
25802580 return selectOpWithSrcs (ResVReg, ResType, I, {SrcReg}, Opcode);
@@ -2662,7 +2662,7 @@ bool SPIRVInstructionSelector::selectIntToBool(Register IntReg,
26622662 const SPIRVType *IntTy,
26632663 const SPIRVType *BoolTy) const {
26642664 // To truncate to a bool, we use OpBitwiseAnd 1 and OpINotEqual to zero.
2665- Register BitIntReg = MRI-> createVirtualRegister (&SPIRV::iIDRegClass );
2665+ Register BitIntReg = createVirtualRegister (IntTy, &GR, MRI, MRI-> getMF () );
26662666 bool IsVectorTy = IntTy->getOpcode () == SPIRV::OpTypeVector;
26672667 unsigned Opcode = IsVectorTy ? SPIRV::OpBitwiseAndV : SPIRV::OpBitwiseAndS;
26682668 Register Zero = buildZerosVal (IntTy, I);
0 commit comments