2015-04-11 07:44:37 +08:00
|
|
|
/* toolchain/common.h - common toolchain abstraction */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2014 Wind River Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1) Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 3) Neither the name of Wind River Systems nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
DESCRIPTION
|
|
|
|
Macros to abstract compiler capabilities (common to all toolchains).
|
|
|
|
|
|
|
|
\NOMANUAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generate a reference to an external symbol.
|
|
|
|
* The reference indicates to the linker that the symbol is required
|
|
|
|
* by the module containing the reference and should be included
|
|
|
|
* in the image if the module is in the image.
|
|
|
|
*
|
|
|
|
* The assembler directive ".set" is used to define a local symbol.
|
|
|
|
* No memory is allocated, and the local symbol does not appear in
|
|
|
|
* the symbol table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
#define REQUIRES(sym) .set sym ## _Requires, sym
|
|
|
|
#else
|
|
|
|
#define REQUIRES(sym) __asm__ (".set " # sym "_Requires, " # sym "\n\t");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
#define SECTION .section
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following definitions are used for symbol name compatibility.
|
|
|
|
*
|
|
|
|
* When #if 1, sources are assembled assuming the compiler
|
|
|
|
* you are using does not generate global symbols prefixed by "_".
|
|
|
|
* (e.g. elf/dwarf)
|
|
|
|
*
|
|
|
|
* When #if 0, sources are assembled assuming the compiler
|
|
|
|
* you are using generates global symbols prefixed by "_".
|
|
|
|
* (e.g. coff/stabs)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
#ifndef TOOL_PREPENDS_UNDERSCORE
|
|
|
|
#define FUNC(sym) sym
|
|
|
|
#else
|
|
|
|
#define FUNC(sym) _##sym
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the project is being built for speed (i.e. not for minimum size) then
|
|
|
|
* align functions and branches in executable sections to improve performance.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
|
|
|
|
#ifdef VXMICRO_ARCH_x86
|
|
|
|
|
|
|
|
#ifdef PERF_OPT
|
|
|
|
#define PERFOPT_ALIGN .balign 16
|
|
|
|
#else
|
|
|
|
#define PERFOPT_ALIGN .balign 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(VXMICRO_ARCH_arm)
|
|
|
|
|
|
|
|
#ifdef CONFIG_ISA_THUMB
|
|
|
|
#define PERFOPT_ALIGN .balign 2
|
|
|
|
#else
|
|
|
|
#define PERFOPT_ALIGN .balign 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(VXMICRO_ARCH_arc)
|
|
|
|
|
|
|
|
#define PERFOPT_ALIGN .balign 4
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-04-24 01:36:50 +08:00
|
|
|
#define GC_SECTION(sym) SECTION .text.FUNC(sym), "ax"
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#define BRANCH_LABEL(sym) FUNC(sym):
|
|
|
|
#define VAR(sym) FUNC(sym)
|
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
|
|
|
/* force inlining a function */
|
|
|
|
|
|
|
|
#if !defined(_ASMLANGUAGE)
|
|
|
|
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_UNALIGNED_WRITE_UNSUPPORTED
|
2015-05-12 23:12:36 +08:00
|
|
|
extern void _Unaligned32Write(unsigned int *ptr, unsigned int val);
|
|
|
|
extern unsigned _Unaligned32Read(unsigned int *ptr);
|
2015-04-11 07:44:37 +08:00
|
|
|
#endif /* CONFIG_UNALIGNED_WRITE_UNSUPPORTED */
|
|
|
|
|