@@ -238,6 +238,9 @@ class SPIRVInstructionSelector : public InstructionSelector {
238
238
bool selectLog10 (Register ResVReg, const SPIRVType *ResType,
239
239
MachineInstr &I) const ;
240
240
241
+ bool selectNormalize (Register ResVReg, const SPIRVType *ResType,
242
+ MachineInstr &I) const ;
243
+
241
244
bool selectSpvThreadId (Register ResVReg, const SPIRVType *ResType,
242
245
MachineInstr &I) const ;
243
246
@@ -1349,6 +1352,23 @@ bool SPIRVInstructionSelector::selectFrac(Register ResVReg,
1349
1352
.constrainAllUses (TII, TRI, RBI);
1350
1353
}
1351
1354
1355
+ bool SPIRVInstructionSelector::selectNormalize (Register ResVReg,
1356
+ const SPIRVType *ResType,
1357
+ MachineInstr &I) const {
1358
+
1359
+ assert (I.getNumOperands () == 3 );
1360
+ assert (I.getOperand (2 ).isReg ());
1361
+ MachineBasicBlock &BB = *I.getParent ();
1362
+
1363
+ return BuildMI (BB, I, I.getDebugLoc (), TII.get (SPIRV::OpExtInst))
1364
+ .addDef (ResVReg)
1365
+ .addUse (GR.getSPIRVTypeID (ResType))
1366
+ .addImm (static_cast <uint32_t >(SPIRV::InstructionSet::GLSL_std_450))
1367
+ .addImm (GL::Normalize)
1368
+ .addUse (I.getOperand (2 ).getReg ())
1369
+ .constrainAllUses (TII, TRI, RBI);
1370
+ }
1371
+
1352
1372
bool SPIRVInstructionSelector::selectRsqrt (Register ResVReg,
1353
1373
const SPIRVType *ResType,
1354
1374
MachineInstr &I) const {
@@ -2080,6 +2100,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
2080
2100
return selectFmix (ResVReg, ResType, I);
2081
2101
case Intrinsic::spv_frac:
2082
2102
return selectFrac (ResVReg, ResType, I);
2103
+ case Intrinsic::spv_normalize:
2104
+ return selectNormalize (ResVReg, ResType, I);
2083
2105
case Intrinsic::spv_rsqrt:
2084
2106
return selectRsqrt (ResVReg, ResType, I);
2085
2107
case Intrinsic::spv_lifetime_start:
0 commit comments