@@ -109,13 +109,10 @@ class SPIRVInstructionSelector : public InstructionSelector {
109
109
bool selectGlobalValue (Register ResVReg, MachineInstr &I,
110
110
const MachineInstr *Init = nullptr ) const ;
111
111
112
- bool selectNAryOpWithSrcs (Register ResVReg, const SPIRVType *ResType,
113
- MachineInstr &I, std::vector<Register> SrcRegs,
114
- unsigned Opcode) const ;
112
+ bool selectOpWithSrcs (Register ResVReg, const SPIRVType *ResType,
113
+ MachineInstr &I, std::vector<Register> SrcRegs,
114
+ unsigned Opcode) const ;
115
115
116
- bool selectUnOpWithSrc (Register ResVReg, const SPIRVType *ResType,
117
- MachineInstr &I, Register SrcReg,
118
- unsigned Opcode) const ;
119
116
bool selectUnOp (Register ResVReg, const SPIRVType *ResType, MachineInstr &I,
120
117
unsigned Opcode) const ;
121
118
@@ -859,11 +856,11 @@ bool SPIRVInstructionSelector::selectExtInst(Register ResVReg,
859
856
return false ;
860
857
}
861
858
862
- bool SPIRVInstructionSelector::selectNAryOpWithSrcs (Register ResVReg,
863
- const SPIRVType *ResType,
864
- MachineInstr &I,
865
- std::vector<Register> Srcs,
866
- unsigned Opcode) const {
859
+ bool SPIRVInstructionSelector::selectOpWithSrcs (Register ResVReg,
860
+ const SPIRVType *ResType,
861
+ MachineInstr &I,
862
+ std::vector<Register> Srcs,
863
+ unsigned Opcode) const {
867
864
auto MIB = BuildMI (*I.getParent (), I, I.getDebugLoc (), TII.get (Opcode))
868
865
.addDef (ResVReg)
869
866
.addUse (GR.getSPIRVTypeID (ResType));
@@ -873,18 +870,6 @@ bool SPIRVInstructionSelector::selectNAryOpWithSrcs(Register ResVReg,
873
870
return MIB.constrainAllUses (TII, TRI, RBI);
874
871
}
875
872
876
- bool SPIRVInstructionSelector::selectUnOpWithSrc (Register ResVReg,
877
- const SPIRVType *ResType,
878
- MachineInstr &I,
879
- Register SrcReg,
880
- unsigned Opcode) const {
881
- return BuildMI (*I.getParent (), I, I.getDebugLoc (), TII.get (Opcode))
882
- .addDef (ResVReg)
883
- .addUse (GR.getSPIRVTypeID (ResType))
884
- .addUse (SrcReg)
885
- .constrainAllUses (TII, TRI, RBI);
886
- }
887
-
888
873
bool SPIRVInstructionSelector::selectUnOp (Register ResVReg,
889
874
const SPIRVType *ResType,
890
875
MachineInstr &I,
@@ -920,8 +905,8 @@ bool SPIRVInstructionSelector::selectUnOp(Register ResVReg,
920
905
.constrainAllUses (TII, TRI, RBI);
921
906
}
922
907
}
923
- return selectUnOpWithSrc (ResVReg, ResType, I, I.getOperand (1 ).getReg (),
924
- Opcode);
908
+ return selectOpWithSrcs (ResVReg, ResType, I, { I.getOperand (1 ).getReg ()} ,
909
+ Opcode);
925
910
}
926
911
927
912
bool SPIRVInstructionSelector::selectBitcast (Register ResVReg,
@@ -1066,7 +1051,7 @@ bool SPIRVInstructionSelector::selectMemOperation(Register ResVReg,
1066
1051
SPIRVType *SourceTy = GR.getOrCreateSPIRVPointerType (
1067
1052
ValTy, I, TII, SPIRV::StorageClass::UniformConstant);
1068
1053
SrcReg = MRI->createGenericVirtualRegister (LLT::scalar (64 ));
1069
- selectUnOpWithSrc (SrcReg, SourceTy, I, VarReg, SPIRV::OpBitcast);
1054
+ selectOpWithSrcs (SrcReg, SourceTy, I, { VarReg} , SPIRV::OpBitcast);
1070
1055
}
1071
1056
auto MIB = BuildMI (BB, I, I.getDebugLoc (), TII.get (SPIRV::OpCopyMemorySized))
1072
1057
.addUse (I.getOperand (0 ).getReg ())
@@ -1111,7 +1096,7 @@ bool SPIRVInstructionSelector::selectAtomicRMW(Register ResVReg,
1111
1096
if (NegateOpcode != 0 ) {
1112
1097
// Translation with negative value operand is requested
1113
1098
Register TmpReg = MRI->createVirtualRegister (&SPIRV::iIDRegClass);
1114
- Result &= selectUnOpWithSrc (TmpReg, ResType, I, ValueReg, NegateOpcode);
1099
+ Result &= selectOpWithSrcs (TmpReg, ResType, I, { ValueReg} , NegateOpcode);
1115
1100
ValueReg = TmpReg;
1116
1101
}
1117
1102
@@ -2374,7 +2359,7 @@ bool SPIRVInstructionSelector::selectIToF(Register ResVReg,
2374
2359
SrcReg = MRI->createVirtualRegister (&SPIRV::iIDRegClass);
2375
2360
selectSelect (SrcReg, TmpType, I, false );
2376
2361
}
2377
- return selectUnOpWithSrc (ResVReg, ResType, I, SrcReg, Opcode);
2362
+ return selectOpWithSrcs (ResVReg, ResType, I, { SrcReg} , Opcode);
2378
2363
}
2379
2364
2380
2365
bool SPIRVInstructionSelector::selectExt (Register ResVReg,
@@ -3068,7 +3053,7 @@ bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg,
3068
3053
// zero or sign extend
3069
3054
Register ExtReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
3070
3055
bool Result =
3071
- selectUnOpWithSrc (ExtReg, ResType, I, I.getOperand (2 ).getReg (), Opcode);
3056
+ selectOpWithSrcs (ExtReg, ResType, I, { I.getOperand (2 ).getReg ()} , Opcode);
3072
3057
return Result && selectFirstBitHigh32 (ResVReg, ResType, I, ExtReg, IsSigned);
3073
3058
}
3074
3059
@@ -3100,7 +3085,7 @@ bool SPIRVInstructionSelector::selectFirstBitHigh64(Register ResVReg,
3100
3085
GR.getOrCreateSPIRVVectorType (baseType, 2 * count, MIRBuilder);
3101
3086
Register bitcastReg = MRI->createVirtualRegister (GR.getRegClass (postCastT));
3102
3087
bool Result =
3103
- selectUnOpWithSrc (bitcastReg, postCastT, I, OpReg, SPIRV::OpBitcast);
3088
+ selectOpWithSrcs (bitcastReg, postCastT, I, { OpReg} , SPIRV::OpBitcast);
3104
3089
3105
3090
// 2. call firstbithigh
3106
3091
Register FBHReg = MRI->createVirtualRegister (GR.getRegClass (postCastT));
@@ -3114,11 +3099,11 @@ bool SPIRVInstructionSelector::selectFirstBitHigh64(Register ResVReg,
3114
3099
bool isScalarRes = ResType->getOpcode () != SPIRV::OpTypeVector;
3115
3100
if (isScalarRes) {
3116
3101
// if scalar do a vector extract
3117
- Result &= selectNAryOpWithSrcs (
3102
+ Result &= selectOpWithSrcs (
3118
3103
HighReg, ResType, I,
3119
3104
{FBHReg, GR.getOrCreateConstInt (0 , I, ResType, TII, ZeroAsNull)},
3120
3105
SPIRV::OpVectorExtractDynamic);
3121
- Result &= selectNAryOpWithSrcs (
3106
+ Result &= selectOpWithSrcs (
3122
3107
LowReg, ResType, I,
3123
3108
{FBHReg, GR.getOrCreateConstInt (1 , I, ResType, TII, ZeroAsNull)},
3124
3109
SPIRV::OpVectorExtractDynamic);
@@ -3176,21 +3161,20 @@ bool SPIRVInstructionSelector::selectFirstBitHigh64(Register ResVReg,
3176
3161
3177
3162
// check if the high bits are == -1; true if -1
3178
3163
Register BReg = MRI->createVirtualRegister (GR.getRegClass (BoolType));
3179
- Result &= selectNAryOpWithSrcs (BReg, BoolType, I, {HighReg, NegOneReg},
3180
- SPIRV::OpIEqual);
3164
+ Result &= selectOpWithSrcs (BReg, BoolType, I, {HighReg, NegOneReg},
3165
+ SPIRV::OpIEqual);
3181
3166
3182
3167
// Select low bits if true in BReg, otherwise high bits
3183
3168
Register TmpReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
3184
- Result &= selectNAryOpWithSrcs (TmpReg, ResType, I, {BReg, LowReg, HighReg},
3185
- selectOp);
3169
+ Result &=
3170
+ selectOpWithSrcs (TmpReg, ResType, I, {BReg, LowReg, HighReg}, selectOp);
3186
3171
3187
3172
// Add 32 for high bits, 0 for low bits
3188
3173
Register ValReg = MRI->createVirtualRegister (GR.getRegClass (ResType));
3189
- Result &=
3190
- selectNAryOpWithSrcs (ValReg, ResType, I, {BReg, Reg0, Reg32}, selectOp);
3174
+ Result &= selectOpWithSrcs (ValReg, ResType, I, {BReg, Reg0, Reg32}, selectOp);
3191
3175
3192
3176
return Result &&
3193
- selectNAryOpWithSrcs (ResVReg, ResType, I, {ValReg, TmpReg}, addOp);
3177
+ selectOpWithSrcs (ResVReg, ResType, I, {ValReg, TmpReg}, addOp);
3194
3178
}
3195
3179
3196
3180
bool SPIRVInstructionSelector::selectFirstBitHigh (Register ResVReg,
0 commit comments