-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[flang] Add -fcomplex-arithmetic= option and select complex division algorithm #146641
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
Changes from all commits
baf87a6
60e0cd9
bddb2d3
65c522c
528e1de
eea4a5f
e94dad2
af90b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,31 @@ class CodeGenOptions : public CodeGenOptionsBase { | |
return getProfileUse() == llvm::driver::ProfileCSIRInstr; | ||
} | ||
|
||
/// Controls the various implementations for complex division. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is exactly the same as the enum in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for providing the example! I understand that your example is about moving Clang's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it should be moved, but since it is in |
||
enum ComplexRangeKind { | ||
/// Implementation of complex division using a call to runtime library | ||
/// functions. Overflow and non-finite values are handled by the library | ||
/// implementation. This is the default value. | ||
CX_Full, | ||
|
||
/// Implementation of complex division offering an improved handling | ||
/// for overflow in intermediate calculations. Overflow and non-finite | ||
/// values are handled by MLIR's implementation of "complex.div", but this | ||
/// may change in the future. | ||
CX_Improved, | ||
|
||
/// Implementation of complex division using algebraic formulas at source | ||
/// precision. No special handling to avoid overflow. NaN and infinite | ||
/// values are not handled. | ||
CX_Basic, | ||
|
||
/// No range rule is enabled. | ||
CX_None | ||
|
||
/// TODO: Implemention of other values as needed. In Clang, "CX_Promoted" | ||
/// is implemented. (See clang/Basic/LangOptions.h) | ||
}; | ||
|
||
// Define accessors/mutators for code generation options of enumeration type. | ||
#define CODEGENOPT(Name, Bits, Default) | ||
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#ifndef FORTRAN_OPTIMIZER_CODEGEN_CODEGEN_H | ||
#define FORTRAN_OPTIMIZER_CODEGEN_CODEGEN_H | ||
|
||
#include "flang/Frontend/CodeGenOptions.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not requesting to do that here, but I feel the CodeGenOptions should be defined in Codegen and used/set in Frontend rather than having Codegen depends on Frontend things I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the reviews!
Does this mean that
Yes, I'm including |
||
#include "mlir/IR/BuiltinOps.h" | ||
#include "mlir/Pass/Pass.h" | ||
#include "mlir/Pass/PassRegistry.h" | ||
|
@@ -58,6 +59,11 @@ struct FIRToLLVMPassOptions { | |
// the name of the global variable corresponding to a derived | ||
// type's descriptor. | ||
bool typeDescriptorsRenamedForAssembly = false; | ||
|
||
// Specify the calculation method for complex number division used by the | ||
// Conversion pass of the MLIR complex dialect. | ||
Fortran::frontend::CodeGenOptions::ComplexRangeKind ComplexRange = | ||
Fortran::frontend::CodeGenOptions::ComplexRangeKind::CX_Full; | ||
}; | ||
|
||
/// Convert FIR to the LLVM IR dialect with default options. | ||
|
Uh oh!
There was an error while loading. Please reload this page.