================
@@ -501,6 +515,31 @@ static llvm::LogicalResult convertFortranSourceToMLIR(
loweringOptions.setNoPPCNativeVecElemOrder(enableNoPPCNativeVecElemOrder);
loweringOptions.setIntegerWrapAround(integerWrapAround);
loweringOptions.setInitGlobalZero(initGlobalZero);
+ // -finit-local-zero (alias for -finit-local=zero)
+ if (initLocalZero)
+ loweringOptions.setInitLocalMode(Fortran::lower::InitLocalKind::Zero);
+
+ // -finit-local=
+ if (!initLocalMode.empty()) {
+ llvm::StringRef val = initLocalMode;
+ if (val == "zero") {
+ loweringOptions.setInitLocalMode(Fortran::lower::InitLocalKind::Zero);
+ } else if (val == "nan") {
+ loweringOptions.setInitLocalMode(Fortran::lower::InitLocalKind::QNaN);
+ } else if (val == "snan") {
+ loweringOptions.setInitLocalMode(Fortran::lower::InitLocalKind::SNaN);
+ } else if (val.starts_with("0x") || val.starts_with("0X")) {
+ unsigned long long hexVal = 0;
+ if (!val.drop_front(2).getAsInteger(16, hexVal) && hexVal <= 0xFF) {
+ loweringOptions.setInitLocalMode(Fortran::lower::InitLocalKind::Hex);
+ loweringOptions.setInitLocalPattern(static_cast<uint8_t>(hexVal));
+ } else {
+ llvm::errs() << "bbc: invalid -finit-local= value: " << val << "\n";
----------------
DanielCChen wrote:
> An isolated empty value is now rejected. The last-option-wins behavior
> remains inconsistent when the overridden value is invalid. Both `bbc
> -finit-local= -finit-local-zero` and `bbc -finit-local=bogus
> -finit-local-zero` exit with status 1. The `flang -fc1` frontend accepts both
> option sequences and selects zero.
>
> Could `bbc` select the last occurrence before validating its value? Could you
> also add tests for both listed option sequences?
Fixed by evaluating `getPosition()` before validation so that `-finit-local=
-finit-local-zero` and `-finit-local=bogus -finit-local-zero` both select zero
without failing on the overridden value; added regression tests for both
sequences.
https://github.com/llvm/llvm-project/pull/216164
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits