@@ -1289,6 +1289,38 @@ static mlir::Value buildPointerArithmetic(CIRGenFunction &CGF,
1289
1289
}
1290
1290
1291
1291
mlir::Value ScalarExprEmitter::buildMul (const BinOpInfo &Ops) {
1292
+ if (Ops.CompType ->isSignedIntegerOrEnumerationType ()) {
1293
+ switch (CGF.getLangOpts ().getSignedOverflowBehavior ()) {
1294
+ case LangOptions::SOB_Defined:
1295
+ if (!CGF.SanOpts .has (SanitizerKind::SignedIntegerOverflow))
1296
+ return Builder.createMul (Ops.LHS , Ops.RHS );
1297
+ [[fallthrough]];
1298
+ case LangOptions::SOB_Undefined:
1299
+ if (!CGF.SanOpts .has (SanitizerKind::SignedIntegerOverflow))
1300
+ return Builder.createNSWMul (Ops.LHS , Ops.RHS );
1301
+ [[fallthrough]];
1302
+ case LangOptions::SOB_Trapping:
1303
+ if (CanElideOverflowCheck (CGF.getContext (), Ops))
1304
+ return Builder.createNSWMul (Ops.LHS , Ops.RHS );
1305
+ llvm_unreachable (" NYI" );
1306
+ }
1307
+ }
1308
+ if (Ops.FullType ->isConstantMatrixType ()) {
1309
+ llvm_unreachable (" NYI" );
1310
+ }
1311
+ if (Ops.CompType ->isUnsignedIntegerType () &&
1312
+ CGF.SanOpts .has (SanitizerKind::UnsignedIntegerOverflow) &&
1313
+ !CanElideOverflowCheck (CGF.getContext (), Ops))
1314
+ llvm_unreachable (" NYI" );
1315
+
1316
+ if (mlir::cir::isFPOrFPVectorTy (Ops.LHS .getType ())) {
1317
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII (CGF, Ops.FPFeatures );
1318
+ return Builder.createFMul (Ops.LHS , Ops.RHS );
1319
+ }
1320
+
1321
+ if (Ops.isFixedPointOp ())
1322
+ llvm_unreachable (" NYI" );
1323
+
1292
1324
return Builder.create <mlir::cir::BinOp>(
1293
1325
CGF.getLoc (Ops.Loc ), CGF.getCIRType (Ops.FullType ),
1294
1326
mlir::cir::BinOpKind::Mul, Ops.LHS , Ops.RHS );
@@ -1308,6 +1340,39 @@ mlir::Value ScalarExprEmitter::buildAdd(const BinOpInfo &Ops) {
1308
1340
if (Ops.LHS .getType ().isa <mlir::cir::PointerType>() ||
1309
1341
Ops.RHS .getType ().isa <mlir::cir::PointerType>())
1310
1342
return buildPointerArithmetic (CGF, Ops, /* isSubtraction=*/ false );
1343
+ if (Ops.CompType ->isSignedIntegerOrEnumerationType ()) {
1344
+ switch (CGF.getLangOpts ().getSignedOverflowBehavior ()) {
1345
+ case LangOptions::SOB_Defined:
1346
+ if (!CGF.SanOpts .has (SanitizerKind::SignedIntegerOverflow))
1347
+ return Builder.createAdd (Ops.LHS , Ops.RHS );
1348
+ [[fallthrough]];
1349
+ case LangOptions::SOB_Undefined:
1350
+ if (!CGF.SanOpts .has (SanitizerKind::SignedIntegerOverflow))
1351
+ return Builder.createNSWAdd (Ops.LHS , Ops.RHS );
1352
+ [[fallthrough]];
1353
+ case LangOptions::SOB_Trapping:
1354
+ if (CanElideOverflowCheck (CGF.getContext (), Ops))
1355
+ return Builder.createNSWAdd (Ops.LHS , Ops.RHS );
1356
+
1357
+ llvm_unreachable (" NYI" );
1358
+ }
1359
+ }
1360
+ if (Ops.FullType ->isConstantMatrixType ()) {
1361
+ llvm_unreachable (" NYI" );
1362
+ }
1363
+
1364
+ if (Ops.CompType ->isUnsignedIntegerType () &&
1365
+ CGF.SanOpts .has (SanitizerKind::UnsignedIntegerOverflow) &&
1366
+ !CanElideOverflowCheck (CGF.getContext (), Ops))
1367
+ llvm_unreachable (" NYI" );
1368
+
1369
+ if (mlir::cir::isFPOrFPVectorTy (Ops.LHS .getType ())) {
1370
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII (CGF, Ops.FPFeatures );
1371
+ return Builder.createFAdd (Ops.LHS , Ops.RHS );
1372
+ }
1373
+
1374
+ if (Ops.isFixedPointOp ())
1375
+ llvm_unreachable (" NYI" );
1311
1376
1312
1377
return Builder.create <mlir::cir::BinOp>(
1313
1378
CGF.getLoc (Ops.Loc ), CGF.getCIRType (Ops.FullType ),
@@ -1344,7 +1409,7 @@ mlir::Value ScalarExprEmitter::buildSub(const BinOpInfo &Ops) {
1344
1409
!CanElideOverflowCheck (CGF.getContext (), Ops))
1345
1410
llvm_unreachable (" NYI" );
1346
1411
1347
- if (Ops.CompType -> isFloatingType ( )) {
1412
+ if (mlir::cir::isFPOrFPVectorTy ( Ops.LHS . getType () )) {
1348
1413
CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII (CGF, Ops.FPFeatures );
1349
1414
return Builder.createFSub (Ops.LHS , Ops.RHS );
1350
1415
}
0 commit comments