@@ -1248,12 +1248,28 @@ class CIRUnreachableOpLowering
1248
1248
mlir::LogicalResult
1249
1249
matchAndRewrite (cir::UnreachableOp op, OpAdaptor adaptor,
1250
1250
mlir::ConversionPatternRewriter &rewriter) const override {
1251
- // match and rewrite.
1252
1251
rewriter.replaceOpWithNewOp <mlir::LLVM::UnreachableOp>(op);
1253
1252
return mlir::success ();
1254
1253
}
1255
1254
};
1256
1255
1256
+ class CIRTrapOpLowering : public mlir ::OpConversionPattern<cir::TrapOp> {
1257
+ public:
1258
+ using OpConversionPattern<cir::TrapOp>::OpConversionPattern;
1259
+
1260
+ mlir::LogicalResult
1261
+ matchAndRewrite (cir::TrapOp op, OpAdaptor adaptor,
1262
+ mlir::ConversionPatternRewriter &rewriter) const override {
1263
+ rewriter.setInsertionPointAfter (op);
1264
+ auto trapIntrinsicName = rewriter.getStringAttr (" llvm.trap" );
1265
+ rewriter.create <mlir::LLVM::CallIntrinsicOp>(op.getLoc (), trapIntrinsicName,
1266
+ /* args=*/ mlir::ValueRange ());
1267
+ rewriter.create <mlir::LLVM::UnreachableOp>(op.getLoc ());
1268
+ rewriter.eraseOp (op);
1269
+ return mlir::success ();
1270
+ }
1271
+ };
1272
+
1257
1273
void populateCIRToMLIRConversionPatterns (mlir::RewritePatternSet &patterns,
1258
1274
mlir::TypeConverter &converter) {
1259
1275
patterns.add <CIRReturnLowering, CIRBrOpLowering>(patterns.getContext ());
@@ -1274,8 +1290,8 @@ void populateCIRToMLIRConversionPatterns(mlir::RewritePatternSet &patterns,
1274
1290
CIRBitClrsbOpLowering, CIRBitFfsOpLowering, CIRBitParityOpLowering,
1275
1291
CIRIfOpLowering, CIRVectorCreateLowering, CIRVectorInsertLowering,
1276
1292
CIRVectorExtractLowering, CIRVectorCmpOpLowering, CIRACosOpLowering,
1277
- CIRASinOpLowering, CIRUnreachableOpLowering, CIRTanOpLowering>(
1278
- converter, patterns.getContext ());
1293
+ CIRASinOpLowering, CIRUnreachableOpLowering, CIRTanOpLowering,
1294
+ CIRTrapOpLowering>( converter, patterns.getContext ());
1279
1295
}
1280
1296
1281
1297
static mlir::TypeConverter prepareTypeConverter () {
0 commit comments