From d7d7091636e9cf612258efeb72324ab0096aca6f Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sun, 24 Mar 2024 19:10:13 -0700 Subject: [PATCH] AMREX_FLATTEN (#3840) This could be used to force inline calls in a function. --- Src/Base/AMReX_Extension.H | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Src/Base/AMReX_Extension.H b/Src/Base/AMReX_Extension.H index e75aaffe671..065d23e1086 100644 --- a/Src/Base/AMReX_Extension.H +++ b/Src/Base/AMReX_Extension.H @@ -112,6 +112,9 @@ #elif defined(__GNUC__) #define AMREX_FORCE_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define AMREX_FORCE_INLINE inline __forceinline + #else #define AMREX_FORCE_INLINE inline @@ -133,6 +136,15 @@ #define AMREX_NO_INLINE #endif +// flatten +#if defined(_MSC_VER) +#define AMREX_FLATTEN [[msvc::flatten]] +#elif defined(__clang__) || defined(__GNUC__) +#define AMREX_FLATTEN __attribute__((flatten)) +#else +#define AMREX_FLATTEN +#endif + // unroll loop #define AMREX_TO_STRING_HELPER(X) #X #define AMREX_TO_STRING(X) AMREX_TO_STRING_HELPER(X)