Skip to content

Commit c8376a9

Browse files
author
Scott Manley
committed
[Flang] Fix options for FunctionAttr pass
For non-basic types GenericOptionParser::findArgStrForValue will return null when the specific values are not found. Add the enum, much like the debug-level option in AddDebugInfo to resolve this problem. Also change tuneCPU to be std::string or it will also have the same problem.
1 parent fd41393 commit c8376a9

File tree

1 file changed

+26
-23
lines changed
  • flang/include/flang/Optimizer/Transforms

1 file changed

+26
-23
lines changed

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -383,30 +383,33 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
383383
freeing up an additional register in numerous functions. However, this
384384
approach can make debugging unfeasible on certain machines.
385385
}];
386-
let options = [
387-
Option<"framePointerKind", "frame-pointer",
388-
"mlir::LLVM::framePointerKind::FramePointerKind",
389-
/*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
390-
"frame pointer">,
391-
Option<"noInfsFPMath", "no-infs-fp-math",
392-
"bool", /*default=*/"false",
393-
"Set the no-infs-fp-math attribute on functions in the module.">,
394-
Option<"noNaNsFPMath", "no-nans-fp-math",
395-
"bool", /*default=*/"false",
396-
"Set the no-nans-fp-math attribute on functions in the module.">,
397-
Option<"approxFuncFPMath", "approx-func-fp-math",
398-
"bool", /*default=*/"false",
386+
let options =
387+
[Option<"framePointerKind", "frame-pointer",
388+
"mlir::LLVM::framePointerKind::FramePointerKind",
389+
/*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
390+
"frame pointer", [{::llvm::cl::values(
391+
clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::None, "None", ""),
392+
clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::NonLeaf, "NonLeaf", ""),
393+
clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::All, "All", ""),
394+
clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::Reserved, "Reserved", "")
395+
)}]>,
396+
Option<"noInfsFPMath", "no-infs-fp-math", "bool", /*default=*/"false",
397+
"Set the no-infs-fp-math attribute on functions in the module.">,
398+
Option<"noNaNsFPMath", "no-nans-fp-math", "bool", /*default=*/"false",
399+
"Set the no-nans-fp-math attribute on functions in the module.">,
400+
Option<
401+
"approxFuncFPMath", "approx-func-fp-math", "bool",
402+
/*default=*/"false",
399403
"Set the approx-func-fp-math attribute on functions in the module.">,
400-
Option<"noSignedZerosFPMath", "no-signed-zeros-fp-math",
401-
"bool", /*default=*/"false",
402-
"Set the no-signed-zeros-fp-math attribute on functions in the module.">,
403-
Option<"unsafeFPMath", "unsafe-fp-math",
404-
"bool", /*default=*/"false",
405-
"Set the unsafe-fp-math attribute on functions in the module.">,
406-
Option<"tuneCPU", "tune-cpu",
407-
"llvm::StringRef", /*default=*/"llvm::StringRef{}",
408-
"Set the tune-cpu attribute on functions in the module.">,
409-
];
404+
Option<"noSignedZerosFPMath", "no-signed-zeros-fp-math", "bool",
405+
/*default=*/"false",
406+
"Set the no-signed-zeros-fp-math attribute on functions in the "
407+
"module.">,
408+
Option<"unsafeFPMath", "unsafe-fp-math", "bool", /*default=*/"false",
409+
"Set the unsafe-fp-math attribute on functions in the module.">,
410+
Option<"tuneCPU", "tune-cpu", "std::string", /*default=*/"",
411+
"Set the tune-cpu attribute on functions in the module.">,
412+
];
410413
}
411414

412415
def AssumedRankOpConversion : Pass<"fir-assumed-rank-op", "mlir::ModuleOp"> {

0 commit comments

Comments
 (0)