[flang-commits] [flang] [llvm] [flang][PPC] Implement ieee_set_status and ieee_get_status for AIX (PR #215618)

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Thu Aug 20 18:47:14 PDT 2026


================
@@ -5210,11 +5210,80 @@ template <bool isGet, bool isModes>
 void IntrinsicLibrary::genIeeeGetOrSetModesOrStatus(
     llvm::ArrayRef<fir::ExtendedValue> args) {
   assert(args.size() == 1);
+  if constexpr (!isModes) {
+    llvm::Triple triple = fir::getTargetTriple(builder.getModule());
+    mlir::Type i32Ty = builder.getIntegerType(32);
+    mlir::Type i32PtrTy = builder.getRefType(i32Ty);
+    if (triple.isOSAIX()) {
+      // On AIX, fegetenv/fesetenv does not round-trip the FPSCR trap-enable
+      // bits [7:3].
+      //
+      // ieee_status_type.__data layout:
+      //   bytes  [0, 20) - fenv_t saved by fegetenv / restored by fesetenv
+      //   bytes [20, 28) - raw FPSCR double from mffs (trap-enable bits [7:3])
+      static constexpr int kAIXFenvTSize = 20; // sizeof(fenv_t) on AIX
----------------
kkwli wrote:

Currently, flang on AIX does not support 32-bit compile, hence the `powerpc-ibm-aix` target is basically not supported. There is no need to add `powerpc-ibm-aix` RUN line in the test.

FYI. `sizeof(fenv_t)` is always 20 on both 32-bit and 64-bit on AIX.

https://github.com/llvm/llvm-project/pull/215618


More information about the flang-commits mailing list