1b78f13911bfe6eda303e91ef215c87a165aae8aeAlexandre Rames// Copyright 2015, VIXL authors
2ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// All rights reserved.
3ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
4ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Redistribution and use in source and binary forms, with or without
5ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// modification, are permitted provided that the following conditions are met:
6ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
7ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Redistributions of source code must retain the above copyright notice,
8ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     this list of conditions and the following disclaimer.
9ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Redistributions in binary form must reproduce the above copyright notice,
10ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     this list of conditions and the following disclaimer in the documentation
11ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     and/or other materials provided with the distribution.
12ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Neither the name of ARM Limited nor the names of its contributors may be
13ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     used to endorse or promote products derived from this software without
14ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     specific prior written permission.
15ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
16ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
27ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#ifndef VIXL_GLOBALS_H
28ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#define VIXL_GLOBALS_H
29ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
305799d6c5d10729eaade85ad608109c83ed1ae63barmvixl// Get standard C99 macros for integer types.
31b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#ifndef __STDC_CONSTANT_MACROS
32b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define __STDC_CONSTANT_MACROS
33b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#endif
34b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl
355799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#ifndef __STDC_LIMIT_MACROS
365799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#define __STDC_LIMIT_MACROS
375799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#endif
385799d6c5d10729eaade85ad608109c83ed1ae63barmvixl
395799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#ifndef __STDC_FORMAT_MACROS
40ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#define __STDC_FORMAT_MACROS
415799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#endif
425799d6c5d10729eaade85ad608109c83ed1ae63barmvixl
4378973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langloisextern "C" {
44b68bacb75c1ab265fc539afa93964c7f51f35589Alexandre Rames#include <inttypes.h>
45b68bacb75c1ab265fc539afa93964c7f51f35589Alexandre Rames#include <stdint.h>
4678973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois}
4778973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois
4878973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois#include <cassert>
4978973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois#include <cstdarg>
5078973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois#include <cstddef>
5178973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois#include <cstdio>
5278973f258039f6e96eba85f1b5ecdb14b3c51dbbPierre Langlois#include <cstdlib>
53b68bacb75c1ab265fc539afa93964c7f51f35589Alexandre Rames
541f9074de150536670464a85ef8e0ede60d26e3f9Alexandre Rames#include "platform-vixl.h"
55ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
5638d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#ifdef VIXL_NEGATIVE_TESTING
5738d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#include <stdexcept>
58028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#include <string>
59028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#include <sstream>
6038d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#endif
61ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
624e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Ramesnamespace vixl {
634e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Rames
64ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixltypedef uint8_t byte;
65ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
665289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixl// Type for half-precision (16 bit) floating point numbers.
675289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixltypedef uint16_t float16;
685289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixl
69ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlconst int KBytes = 1024;
70ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlconst int MBytes = 1024 * KBytes;
71ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
724e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Ramesconst int kBitsPerByte = 8;
734e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Rames
744e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Rames}  // namespace vixl
754e7c93cc256c7719d69279d64e4f5d09044b8b2cAlexandre Rames
7628ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois// Detect the host's pointer size.
7728ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#if (UINTPTR_MAX == UINT32_MAX)
7828ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#define VIXL_HOST_POINTER_32
7928ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#elif(UINTPTR_MAX == UINT64_MAX)
8028ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#define VIXL_HOST_POINTER_64
8128ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#else
8228ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#error "Unsupported host pointer size."
8328ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois#endif
8428ee02e59261f0aaa4824953fa3db5dd8f7f8dcfPierre Langlois
8538d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#ifdef VIXL_NEGATIVE_TESTING
86028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_ABORT()                                                         \
87028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                                       \
88028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    std::ostringstream oss;                                                  \
89028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    oss << "Aborting in " << __FILE__ << ", line " << __LINE__ << std::endl; \
90028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    throw std::runtime_error(oss.str());                                     \
9138d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli  } while (false)
92028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_ABORT_WITH_MSG(msg)                                             \
93028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                                       \
94028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    std::ostringstream oss;                                                  \
95028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    oss << (msg) << "in " << __FILE__ << ", line " << __LINE__ << std::endl; \
96028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    throw std::runtime_error(oss.str());                                     \
97028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  } while (false)
98028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_CHECK(condition)                                \
99028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                       \
100028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    if (!(condition)) {                                      \
101028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      std::ostringstream oss;                                \
102028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      oss << "Assertion failed (" #condition ")\nin ";       \
103028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      oss << __FILE__ << ", line " << __LINE__ << std::endl; \
104028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      throw std::runtime_error(oss.str());                   \
105028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    }                                                        \
10638d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli  } while (false)
107b323da089731b39a34ad0a77d20f0a96c1c1a1bcVincent Belliard#define VIXL_THROW_IN_NEGATIVE_TESTING_MODE(error) throw(error)
10838d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#else
109028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_ABORT()                                         \
110028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                       \
111028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    printf("Aborting in %s, line %i\n", __FILE__, __LINE__); \
112028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    abort();                                                 \
113028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  } while (false)
114028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_ABORT_WITH_MSG(msg)                             \
115028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                       \
116028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    printf("%sin %s, line %i\n", (msg), __FILE__, __LINE__); \
117028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    abort();                                                 \
118028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  } while (false)
119028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_CHECK(condition)                                       \
120028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                                              \
121028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    if (!(condition)) {                                             \
122028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      printf("Assertion failed (" #condition ")\nin %s, line %i\n", \
123028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley             __FILE__,                                              \
124028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley             __LINE__);                                             \
125028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley      abort();                                                      \
126028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    }                                                               \
1270f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  } while (false)
128b323da089731b39a34ad0a77d20f0a96c1c1a1bcVincent Belliard#define VIXL_THROW_IN_NEGATIVE_TESTING_MODE(error)
12938d5d1bb12664c89d51f5c1bd75014ab2aabe4e9Georgia Kouveli#endif
130330dc7153e671968beb67f09ed2cb7b5bda334dbarmvixl#ifdef VIXL_DEBUG
1310f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_ASSERT(condition) assert(condition)
132028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_UNIMPLEMENTED()               \
133028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                     \
134028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    VIXL_ABORT_WITH_MSG("UNIMPLEMENTED "); \
1350f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  } while (false)
136028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley#define VIXL_UNREACHABLE()               \
137028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley  do {                                   \
138028fb0566f6af6d839d34ccfec754ba394510302Jacob Bramley    VIXL_ABORT_WITH_MSG("UNREACHABLE "); \
1390f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  } while (false)
140ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#else
1410f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_ASSERT(condition) ((void)0)
1420f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_UNIMPLEMENTED() ((void)0)
1430f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_UNREACHABLE() ((void)0)
144ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#endif
145b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// This is not as powerful as template based assertions, but it is simple.
146b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// It assumes that the descriptions are unique. If this starts being a problem,
147b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// we can switch to a different implemention.
148b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_CONCAT(a, b) a##b
1499d9901810c19fb913383502065150bb532208674Alexandre Rames#if __cplusplus >= 201103L
1509d9901810c19fb913383502065150bb532208674Alexandre Rames#define VIXL_STATIC_ASSERT_LINE(line_unused, condition, message) \
1519d9901810c19fb913383502065150bb532208674Alexandre Rames  static_assert(condition, message)
1529d9901810c19fb913383502065150bb532208674Alexandre Rames#else
1539d9901810c19fb913383502065150bb532208674Alexandre Rames#define VIXL_STATIC_ASSERT_LINE(line, condition, message_unused)            \
154b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl  typedef char VIXL_CONCAT(STATIC_ASSERT_LINE_, line)[(condition) ? 1 : -1] \
1550f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl      __attribute__((unused))
1569d9901810c19fb913383502065150bb532208674Alexandre Rames#endif
157db6443499376478f5281607a3923e6ffc4c8d8ecarmvixl#define VIXL_STATIC_ASSERT(condition) \
1589d9901810c19fb913383502065150bb532208674Alexandre Rames  VIXL_STATIC_ASSERT_LINE(__LINE__, condition, "")
1599d9901810c19fb913383502065150bb532208674Alexandre Rames#define VIXL_STATIC_ASSERT_MESSAGE(condition, message) \
1609d9901810c19fb913383502065150bb532208674Alexandre Rames  VIXL_STATIC_ASSERT_LINE(__LINE__, condition, message)
161ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
16254fce717d9371fa2e8fc46e1d811bdb4ab74f279Alexandre Rames#define VIXL_WARNING(message)                                          \
16354fce717d9371fa2e8fc46e1d811bdb4ab74f279Alexandre Rames  do {                                                                 \
16454fce717d9371fa2e8fc46e1d811bdb4ab74f279Alexandre Rames    printf("WARNING in %s, line %i: %s", __FILE__, __LINE__, message); \
16554fce717d9371fa2e8fc46e1d811bdb4ab74f279Alexandre Rames  } while (false)
16654fce717d9371fa2e8fc46e1d811bdb4ab74f279Alexandre Rames
167db6443499376478f5281607a3923e6ffc4c8d8ecarmvixltemplate <typename T1>
168e0b313e398b4d0a581b60f8233fb183ccb540c40Alexandre Ramesinline void USE(const T1&) {}
169ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
170db6443499376478f5281607a3923e6ffc4c8d8ecarmvixltemplate <typename T1, typename T2>
171e0b313e398b4d0a581b60f8233fb183ccb540c40Alexandre Ramesinline void USE(const T1&, const T2&) {}
172db6443499376478f5281607a3923e6ffc4c8d8ecarmvixl
173db6443499376478f5281607a3923e6ffc4c8d8ecarmvixltemplate <typename T1, typename T2, typename T3>
174e0b313e398b4d0a581b60f8233fb183ccb540c40Alexandre Ramesinline void USE(const T1&, const T2&, const T3&) {}
175db6443499376478f5281607a3923e6ffc4c8d8ecarmvixl
176db6443499376478f5281607a3923e6ffc4c8d8ecarmvixltemplate <typename T1, typename T2, typename T3, typename T4>
177e0b313e398b4d0a581b60f8233fb183ccb540c40Alexandre Ramesinline void USE(const T1&, const T2&, const T3&, const T4&) {}
178db6443499376478f5281607a3923e6ffc4c8d8ecarmvixl
1790f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_ALIGNMENT_EXCEPTION()            \
1800f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  do {                                        \
1810f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl    fprintf(stderr, "ALIGNMENT EXCEPTION\t"); \
1820f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl    VIXL_ABORT();                             \
1830f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  } while (0)
184ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
1856e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// The clang::fallthrough attribute is used along with the Wimplicit-fallthrough
1866e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// argument to annotate intentional fall-through between switch labels.
1876e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// For more information please refer to:
1886e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
1896e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl#ifndef __has_warning
1900f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define __has_warning(x) 0
1916e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl#endif
1926e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl
1936e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// Note: This option is only available for Clang. And will only be enabled for
1946e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl// C++11(201103L).
1956e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl#if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L
19660241a544be0ebf48347789bf0ec268414364627Vincent Belliard#define VIXL_FALLTHROUGH() [[clang::fallthrough]]
1976e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl#else
1980f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_FALLTHROUGH() \
1990f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  do {                     \
2000f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl  } while (0)
2016e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl#endif
2026e2c8275d5f34a531fe1eef7a7aa877601be8558armvixl
203684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#if __cplusplus >= 201103L
20460241a544be0ebf48347789bf0ec268414364627Vincent Belliard#define VIXL_NO_RETURN [[noreturn]]
205684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#else
2060f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_NO_RETURN __attribute__((noreturn))
207684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
208064e02d4e85938b2e2be4d4b37a2691b2e015ebbAlexandre Rames#ifdef VIXL_DEBUG
209064e02d4e85938b2e2be4d4b37a2691b2e015ebbAlexandre Rames#define VIXL_NO_RETURN_IN_DEBUG_MODE VIXL_NO_RETURN
210064e02d4e85938b2e2be4d4b37a2691b2e015ebbAlexandre Rames#else
211064e02d4e85938b2e2be4d4b37a2691b2e015ebbAlexandre Rames#define VIXL_NO_RETURN_IN_DEBUG_MODE
212064e02d4e85938b2e2be4d4b37a2691b2e015ebbAlexandre Rames#endif
213684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl
2143fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois#if __cplusplus >= 201103L
2153fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois#define VIXL_OVERRIDE override
2163fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois#else
2173fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois#define VIXL_OVERRIDE
2183fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois#endif
2193fac43c1a101f98f116e752b80abc122d32b83acPierre Langlois
220684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl// Some functions might only be marked as "noreturn" for the DEBUG build. This
221684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl// macro should be used for such cases (for more details see what
222684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl// VIXL_UNREACHABLE expands to).
223684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#ifdef VIXL_DEBUG
2240f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_DEBUG_NO_RETURN VIXL_NO_RETURN
225684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#else
2260f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#define VIXL_DEBUG_NO_RETURN
227684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
228684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl
2291e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
2301e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifndef VIXL_AARCH64_GENERATE_SIMULATOR_CODE
2311e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#define VIXL_AARCH64_GENERATE_SIMULATOR_CODE 1
232684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
233684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#else
2341e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifndef VIXL_AARCH64_GENERATE_SIMULATOR_CODE
2351e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#define VIXL_AARCH64_GENERATE_SIMULATOR_CODE 0
236684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
2371e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#if VIXL_AARCH64_GENERATE_SIMULATOR_CODE
2380f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#warning "Generating Simulator instructions without Simulator support."
239684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
240684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
241684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl
2421e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois// We do not have a simulator for AArch32, although we can pretend we do so that
2431e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois// tests that require running natively can be skipped.
2441e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifndef __arm__
2451e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#define VIXL_INCLUDE_SIMULATOR_AARCH32
2461e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifndef VIXL_AARCH32_GENERATE_SIMULATOR_CODE
2471e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#define VIXL_AARCH32_GENERATE_SIMULATOR_CODE 1
2481e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#endif
2491e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#else
2501e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#ifndef VIXL_AARCH32_GENERATE_SIMULATOR_CODE
2511e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#define VIXL_AARCH32_GENERATE_SIMULATOR_CODE 0
2521e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#endif
2531e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois#endif
2541e85b7f2e8ad2bfb233de29405aade635ed207cePierre Langlois
255684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#ifdef USE_SIMULATOR
2560f35e36b7f5d1d2f4d95989b418447e1a4bcc8cdarmvixl#error "Please see the release notes for USE_SIMULATOR."
257684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl#endif
258684cd2a7f5845539b58d0da7e012e39df49ceff0armvixl
2599a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta// Target Architecture/ISA
2609a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#ifdef VIXL_INCLUDE_TARGET_A64
2619a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#define VIXL_INCLUDE_TARGET_AARCH64
2629a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#endif
2639a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta
2649a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#if defined(VIXL_INCLUDE_TARGET_A32) && defined(VIXL_INCLUDE_TARGET_T32)
2659a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#define VIXL_INCLUDE_TARGET_AARCH32
2669a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#elif defined(VIXL_INCLUDE_TARGET_A32)
2679a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#define VIXL_INCLUDE_TARGET_A32_ONLY
2689a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#else
2699a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#define VIXL_INCLUDE_TARGET_T32_ONLY
2709a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta#endif
2719a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta
2729a9331faeba996d6c85e6e2a6355ccfc22c6cab6Rodolph Perfetta
273ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#endif  // VIXL_GLOBALS_H
274