38 mlir::FlatSymbolRefAttr badCastFuncRef) {
39 builder.
createCallOp(loc, badCastFuncRef, cir::VoidType(),
43 cir::UnreachableOp::create(builder, loc);
44 builder.clearInsertionPoint();
49 cir::DynamicCastOp op) {
50 mlir::Location loc = op->getLoc();
51 mlir::Value srcValue = op.getSrc();
52 cir::DynamicCastInfoAttr castInfo = op.getInfo().value();
58 cir::ConstantOp srcRtti = builder.
getConstant(loc, castInfo.getSrcRtti());
59 cir::ConstantOp destRtti = builder.
getConstant(loc, castInfo.getDestRtti());
60 cir::ConstantOp offsetHint =
63 mlir::FlatSymbolRefAttr dynCastFuncRef = castInfo.getRuntimeFunc();
64 mlir::Value dynCastFuncArgs[4] = {srcPtr, srcRtti, destRtti, offsetHint};
66 mlir::Value castedPtr =
72 assert(mlir::isa<cir::PointerType>(castedPtr.getType()) &&
73 "the return value of __dynamic_cast should be a ptr");
80 builder.create<cir::IfOp>(
81 loc, castedValueIsNull,
false, [&](mlir::OpBuilder &, mlir::Location) {
101 cir::DynamicCastOp op) {
102 mlir::Location loc = op->getLoc();
103 mlir::Value srcValue = op.getSrc();
112 .create<cir::TernaryOp>(
113 loc, srcValueIsNotNull,
114 [&](mlir::OpBuilder &, mlir::Location) {
115 mlir::Value castedValue =
121 [&](mlir::OpBuilder &, mlir::Location) {
123 loc, builder.
getNullPtr(op.getType(), loc).getResult());
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...