base,arch-arm: Add GEM5_NO_OPTIMIZE; use in ARM's vfp.hh (#1834)
GCC and CLANG have different annotations for declaring code should not be optimized. Adding GEM5_NO_OPTIMZE provides gem5 developers a MACRO that works in both cases. This change replaces the GCC pragmas in vfp.hh with GEM5_NO_OPTIMIZE as this solution didn't work with clang.
This commit is contained in:
@@ -266,6 +266,7 @@ setFPExceptions(int exceptions) {
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
T
|
||||
GEM5_NO_OPTIMIZE
|
||||
vfpFpRint(T val, bool exact, bool defaultNan, bool useRmode = true,
|
||||
VfpRoundingMode roundMode = VfpRoundZero)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user