// nisps/core/perf.hpp โ€” RP2040/RP2350 memory section + inlining attributes. // // On firmware builds the macros expand to GCC/Pico-specific section attributes // so hot code/data lives in SRAM instead of XIP flash. On every other build // (host tests, Emscripten/WASM) they are inert โ€” the discipline of marking // audio-critical declarations is preserved syntactically without affecting // codegen. // // See architecture.md ยง3.4. #pragma once // NISPS_TARGET_EMBEDDED marks builds for the RP2350 hardware target. Code // that is allowed heap allocation at construction time on host/WASM targets // (e.g. nisps/ml/dynamic_storage.hpp) is compile-time excluded when this is // defined โ€” the zero-heap firmware contract is enforced structurally, not // just by lint. #if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) #define NISPS_TARGET_EMBEDDED 1 #endif #if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) // Pico SDK provides __not_in_flash and __not_in_flash_func. // __not_in_flash takes a section name string; __not_in_flash_func wraps the // declaration directly. #define NISPS_AUDIO_MEM __not_in_flash("audio") #define NISPS_AUDIO_FUNC __not_in_flash_func #define NISPS_APP_SRAM __not_in_flash("app") #define NISPS_FORCE_INLINE __attribute__((always_inline)) inline #define NISPS_HOT __attribute__((hot)) #define NISPS_NOINLINE __attribute__((noinline)) #else #define NISPS_AUDIO_MEM #define NISPS_AUDIO_FUNC(decl) decl #define NISPS_APP_SRAM #define NISPS_FORCE_INLINE inline #define NISPS_HOT #if defined(__GNUC__) || defined(__clang__) #define NISPS_NOINLINE __attribute__((noinline)) #else #define NISPS_NOINLINE #endif #endif