diff --git a/src/arch/arm/insts/vfp.hh b/src/arch/arm/insts/vfp.hh index 1fccba3253..29f7547021 100644 --- a/src/arch/arm/insts/vfp.hh +++ b/src/arch/arm/insts/vfp.hh @@ -266,6 +266,7 @@ setFPExceptions(int exceptions) { template uint64_t +GEM5_NO_OPTIMIZE vfpFpToFixed(T val, bool isSigned, uint8_t width, uint8_t imm, bool useRmode = true, VfpRoundingMode roundMode = VfpRoundZero, bool aarch64 = false) @@ -437,6 +438,7 @@ vfpFpToFixed(T val, bool isSigned, uint8_t width, uint8_t imm, bool template T +GEM5_NO_OPTIMIZE vfpFpRint(T val, bool exact, bool defaultNan, bool useRmode = true, VfpRoundingMode roundMode = VfpRoundZero) { diff --git a/src/base/compiler.hh b/src/base/compiler.hh index 9c80c3ef09..f31478081a 100644 --- a/src/base/compiler.hh +++ b/src/base/compiler.hh @@ -131,6 +131,16 @@ do { [[maybe_unused]] int i[] = { 0, ((void)(__VA_ARGS__), 0)... }; } while (0) # error "Don't know what to do for your compiler." #endif + +// GEM5_NO_OPTIMIZE can be used to prevent the compiler from optimizing a +// function. Clang and GCC have different ways of doing this, so we need to +// check which compiler is being used. +#if defined(__clang__) +# define GEM5_NO_OPTIMIZE __attribute__((optnone)) +#else +# define GEM5_NO_OPTIMIZE __attribute__((optimize("O0"))) +#endif + // When a member variable may be unused, mark it with GEM5_CLASS_VAR_USED. This // needs to be limitted to clang only since clang warns on these unused // variables, and g++ will actually warn if you use this attribute since it