Don't use yield opcode if unsupported.

This is an enhancement to the previous `yield` work:

* Don't enforce `-march=armv8-a` for aarch64 builds, because it is the
  initial ARMv8 revision and compilers will either use that or something
  newer.
* Refine preprocessor guards around `asm("yield");` so the code isn't
  compiled in if unsupported by the current `-march='.

Submitted by @smcv in #535.
This commit is contained in:
Yamagi 2020-04-03 08:24:40 +02:00
parent 98cbb17bb4
commit 5b327c0417
3 changed files with 3 additions and 9 deletions

View file

@ -168,8 +168,6 @@ endif()
if ("${ARCH}" STREQUAL "arm")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6k")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a")
endif()
endif()

View file

@ -152,16 +152,12 @@ endif
# is also the first Raspberry PI generation and older hardware
# is likely too slow to run the game. We're not enforcing the
# minimum architecture, but if you're build for something older
# like arm5 you need to remove the `yield` opcode. It's set in
# Qcommon_Mainloop() in frame.c via inline assmebly.
# like arm5 the `yield` opcode isn't compiled in and the game
# (especially q2ded) will consume more CPU time than necessary.
ifeq ($(YQ2_ARCH), arm)
CFLAGS += -march=armv6k
endif
ifeq ($(YQ2_ARCH), aarch64)
CFLAGS += -march=armv8.0-a
endif
# ----------
# Switch of some annoying warnings.

View file

@ -146,7 +146,7 @@ Qcommon_Mainloop(void)
a Kaby Lake laptop. */
#if defined (__GNUC__) && (__i386 || __x86_64__)
asm("pause");
#elif defined(__arm__) || defined(__aarch64__)
#elif defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__ARM_ARCH_6K__)
asm("yield");
#endif