Add architecture specific target option macros
These macros are defined in target.hpp. This commit adds the macros: NOINLINE - Never inline the function ALWAYS_INLINE - Force the function to be inlined (also adds the inline attribute to the function) TARGET_ARM_MODE - Compile all future functions in ARM mode until TARGET_END_MODE is reached. No-op if not compiling for ARM. TARGET_THUMB_MODE - Compile all future functions in thumb mode until TARGET_END_MODE is reached. No-op if not compiling for ARM. TARGET_END_MODE - Undo the last TARGET_*_MODE option. ARM_MODE - Compile this function in ARM mode. THUMB_MODE - Compile this function in thumb mode.
This commit is contained in:
parent
1af4b652b8
commit
4778b477ec
27
include/mtl/target.hpp
Normal file
27
include/mtl/target.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
#error Failed to create target macros. Compiler is not GCC.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NOINLINE [[gnu::noinline]]
|
||||||
|
#define ALWAYS_INLINE [[gnu::always_inline]] inline
|
||||||
|
|
||||||
|
#ifdef __arm__
|
||||||
|
|
||||||
|
#define TARGET_ARM_MODE _Pragma("GCC push_options") _Pragma("GCC target(\"arm\")")
|
||||||
|
#define TARGET_THUMB_MODE _Pragma("GCC push_options") _Pragma("GCC target(\"thumb\")")
|
||||||
|
#define TARGET_END_MODE _Pragma("GCC pop_options")
|
||||||
|
#define ARM_MODE [[gnu::target("arm")]]
|
||||||
|
#define THUMB_MODE [[gnu::target("thumb")]]
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define TARGET_ARM_MODE
|
||||||
|
#define TARGET_THUMB_MODE
|
||||||
|
#define TARGET_END_MODE
|
||||||
|
#define ARM_MODE
|
||||||
|
#define THUMB_MODE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user