Skip to content

Part 1: use the correct floating point op for unsupported floating po… #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions flang/lib/Lower/ConvertExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "flang/Lower/IntrinsicCall.h"
#include "flang/Lower/Runtime.h"
#include "flang/Lower/Todo.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
Expand Down Expand Up @@ -152,16 +153,21 @@ class ExprLowering {
mlir::Value genBoolConstant(mlir::MLIRContext *context, bool value) {
auto i1Type = builder.getI1Type();
auto attr = builder.getIntegerAttr(i1Type, value ? 1 : 0);
return builder.create<mlir::ConstantOp>(getLoc(), i1Type, attr).getResult();
return builder.create<mlir::ConstantOp>(getLoc(), i1Type, attr);
}

/// Generate a real constant with of `value`.
template <int KIND>
mlir::Value genRealConstant(mlir::MLIRContext *context,
const llvm::APFloat &value) {
auto fltTy = Fortran::lower::convertReal(context, KIND);
auto attr = builder.getFloatAttr(fltTy, value);
auto res = builder.create<mlir::ConstantOp>(getLoc(), fltTy, attr);
return res.getResult();
if (fltTy.isa<mlir::FloatType>()) {
auto attr = builder.getFloatAttr(fltTy, value);
return builder.create<mlir::ConstantOp>(getLoc(), fltTy, attr);
}
// MLIR standard dialect doesn't support floating point larger than double.
auto attr = fir::RealAttr::get(context, {KIND, value});
return builder.create<fir::ConstfOp>(getLoc(), fltTy, attr);
}

mlir::Type getSomeKindInteger() { return builder.getIndexType(); }
Expand Down