|
||||
File indexing completed on 2025-01-30 09:33:57
0001 /* 0002 * Distributed under the Boost Software License, Version 1.0. 0003 * (See accompanying file LICENSE_1_0.txt or copy at 0004 * http://www.boost.org/LICENSE_1_0.txt) 0005 * 0006 * Copyright (c) 2009 Helge Bahmann 0007 * Copyright (c) 2013 Tim Blechmann 0008 * Copyright (c) 2014, 2020 Andrey Semashev 0009 */ 0010 /*! 0011 * \file atomic/detail/gcc_arm_asm_common.hpp 0012 * 0013 * This header contains basic utilities for gcc asm-based ARM backend. 0014 */ 0015 0016 #ifndef BOOST_ATOMIC_DETAIL_GCC_ARM_ASM_COMMON_HPP_INCLUDED_ 0017 #define BOOST_ATOMIC_DETAIL_GCC_ARM_ASM_COMMON_HPP_INCLUDED_ 0018 0019 #include <boost/atomic/detail/config.hpp> 0020 #include <boost/atomic/detail/capabilities.hpp> 0021 0022 #ifdef BOOST_HAS_PRAGMA_ONCE 0023 #pragma once 0024 #endif 0025 0026 // A memory barrier is effected using a "co-processor 15" instruction, 0027 // though a separate assembler mnemonic is available for it in v7. 0028 // 0029 // "Thumb 1" is a subset of the ARM instruction set that uses a 16-bit encoding. It 0030 // doesn't include all instructions and in particular it doesn't include the co-processor 0031 // instruction used for the memory barrier or the load-locked/store-conditional 0032 // instructions. So, if we're compiling in "Thumb 1" mode, we need to wrap all of our 0033 // asm blocks with code to temporarily change to ARM mode. 0034 // 0035 // You can only change between ARM and Thumb modes when branching using the bx instruction. 0036 // bx takes an address specified in a register. The least significant bit of the address 0037 // indicates the mode, so 1 is added to indicate that the destination code is Thumb. 0038 // A temporary register is needed for the address and is passed as an argument to these 0039 // macros. It must be one of the "low" registers accessible to Thumb code, specified 0040 // using the "l" attribute in the asm statement. 0041 // 0042 // Architecture v7 introduces "Thumb 2", which does include (almost?) all of the ARM 0043 // instruction set. (Actually, there was an extension of v6 called v6T2 which supported 0044 // "Thumb 2" mode, but its architecture manual is no longer available, referring to v7.) 0045 // So in v7 we don't need to change to ARM mode; we can write "universal 0046 // assembler" which will assemble to Thumb 2 or ARM code as appropriate. The only thing 0047 // we need to do to make this "universal" assembler mode work is to insert "IT" instructions 0048 // to annotate the conditional instructions. These are ignored in other modes (e.g. v6), 0049 // so they can always be present. 0050 0051 // A note about memory_order_consume. Technically, this architecture allows to avoid 0052 // unnecessary memory barrier after consume load since it supports data dependency ordering. 0053 // However, some compiler optimizations may break a seemingly valid code relying on data 0054 // dependency tracking by injecting bogus branches to aid out of order execution. 0055 // This may happen not only in Boost.Atomic code but also in user's code, which we have no 0056 // control of. See this thread: http://lists.boost.org/Archives/boost/2014/06/213890.php. 0057 // For this reason we promote memory_order_consume to memory_order_acquire. 0058 0059 #if defined(__thumb__) && !defined(__thumb2__) 0060 #define BOOST_ATOMIC_DETAIL_ARM_ASM_START(TMPREG) "adr " #TMPREG ", 8f\n\t" "bx " #TMPREG "\n\t" ".arm\n\t" ".align 4\n\t" "8:\n\t" 0061 #define BOOST_ATOMIC_DETAIL_ARM_ASM_END(TMPREG) "adr " #TMPREG ", 9f + 1\n\t" "bx " #TMPREG "\n\t" ".thumb\n\t" ".align 2\n\t" "9:\n\t" 0062 #define BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(var) "=&l" (var) 0063 #else 0064 // Indicate that start/end macros are empty and the tmpreg is not needed 0065 #define BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_UNUSED 0066 #define BOOST_ATOMIC_DETAIL_ARM_ASM_START(TMPREG) 0067 #define BOOST_ATOMIC_DETAIL_ARM_ASM_END(TMPREG) 0068 #define BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(var) "=&l" (var) 0069 #endif 0070 0071 #if defined(BOOST_ATOMIC_DETAIL_ARM_LITTLE_ENDIAN) 0072 #define BOOST_ATOMIC_DETAIL_ARM_ASM_ARG_LO(arg) "%" BOOST_STRINGIZE(arg) 0073 #define BOOST_ATOMIC_DETAIL_ARM_ASM_ARG_HI(arg) "%H" BOOST_STRINGIZE(arg) 0074 #else 0075 #define BOOST_ATOMIC_DETAIL_ARM_ASM_ARG_LO(arg) "%H" BOOST_STRINGIZE(arg) 0076 #define BOOST_ATOMIC_DETAIL_ARM_ASM_ARG_HI(arg) "%" BOOST_STRINGIZE(arg) 0077 #endif 0078 0079 #endif // BOOST_ATOMIC_DETAIL_GCC_ARM_ASM_COMMON_HPP_INCLUDED_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |