return builder.createIntegerConstant(getLoc(), type, value);
}
+ /// Generate a logical/boolean constant of `value`
+ mlir::Value genBoolConstant(bool value) {
+ return builder.createBool(getLoc(), value);
+ }
+
ExtValue genval(Fortran::semantics::SymbolRef sym) {
TODO(getLoc(), "genval SymbolRef");
}
if constexpr (TC == Fortran::common::TypeCategory::Integer) {
return genIntegerConstant<KIND>(builder.getContext(), value.ToInt64());
} else if constexpr (TC == Fortran::common::TypeCategory::Logical) {
- TODO(getLoc(), "genval bool constant");
+ return genBoolConstant(value.IsTrue());
} else if constexpr (TC == Fortran::common::TypeCategory::Real) {
TODO(getLoc(), "genval real constant");
} else if constexpr (TC == Fortran::common::TypeCategory::Complex) {
loc, calleeType.getInput(operands.size()), isError));
// Third operand indicates QUIET (default to false).
- if (std::get<std::optional<Fortran::parser::ScalarLogicalExpr>>(stmt.t)) {
- TODO(loc, "STOP third operand not lowered yet");
+ if (const auto &quiet =
+ std::get<std::optional<Fortran::parser::ScalarLogicalExpr>>(stmt.t)) {
+ const SomeExpr *expr = Fortran::semantics::GetExpr(*quiet);
+ assert(expr && "failed getting typed expression");
+ mlir::Value q = fir::getBase(converter.genExprValue(*expr));
+ operands.push_back(
+ builder.createConvert(loc, calleeType.getInput(operands.size()), q));
} else {
operands.push_back(builder.createIntegerConstant(
loc, calleeType.getInput(operands.size()), 0));
! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c42]], %[[false]], %[[false]])
! CHECK-NEXT: fir.unreachable
end subroutine
+
+! CHECK-LABEL stop_quiet_constant
+subroutine stop_quiet_constant()
+ stop, quiet = .true.
+ ! CHECK-DAG: %[[true:.*]] = arith.constant true
+ ! CHECK-DAG: %[[false:.*]] = arith.constant false
+ ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : i32
+ ! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[true]])
+ ! CHECK-NEXT: fir.unreachable
+end subroutine