globals-vixl.h revision 5289c5900fb214f2f6aa61e2a9263730dcf4cc17
15289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixl// Copyright 2015, ARM Limited 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 435799d6c5d10729eaade85ad608109c83ed1ae63barmvixl#include <stdint.h> 44ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <inttypes.h> 45ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 46ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <assert.h> 47ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <stdarg.h> 48ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <stdio.h> 49ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <stdint.h> 50ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <stdlib.h> 51ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include <stddef.h> 52ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include "platform.h" 53ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 54ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 55ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixltypedef uint8_t byte; 56ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 575289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixl// Type for half-precision (16 bit) floating point numbers. 585289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixltypedef uint16_t float16; 595289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixl 60ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlconst int KBytes = 1024; 61ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlconst int MBytes = 1024 * KBytes; 62ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 63b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_ABORT() printf("in %s, line %i", __FILE__, __LINE__); abort() 64330dc7153e671968beb67f09ed2cb7b5bda334dbarmvixl#ifdef VIXL_DEBUG 65b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_ASSERT(condition) assert(condition) 66b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_CHECK(condition) VIXL_ASSERT(condition) 67b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_UNIMPLEMENTED() printf("UNIMPLEMENTED\t"); VIXL_ABORT() 68b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_UNREACHABLE() printf("UNREACHABLE\t"); VIXL_ABORT() 69ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#else 70b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_ASSERT(condition) ((void) 0) 71b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_CHECK(condition) assert(condition) 72b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_UNIMPLEMENTED() ((void) 0) 73b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl #define VIXL_UNREACHABLE() ((void) 0) 74ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#endif 75b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// This is not as powerful as template based assertions, but it is simple. 76b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// It assumes that the descriptions are unique. If this starts being a problem, 77b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl// we can switch to a different implemention. 78b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_CONCAT(a, b) a##b 79b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_STATIC_ASSERT_LINE(line, condition) \ 80b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl typedef char VIXL_CONCAT(STATIC_ASSERT_LINE_, line)[(condition) ? 1 : -1] \ 81b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl __attribute__((unused)) 82b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_STATIC_ASSERT(condition) VIXL_STATIC_ASSERT_LINE(__LINE__, condition) //NOLINT 83ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 84ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixltemplate <typename T> inline void USE(T) {} 855289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixltemplate <typename T> inline void USE(T, T) {} 865289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixltemplate <typename T> inline void USE(T, T, T) {} 875289c5900fb214f2f6aa61e2a9263730dcf4cc17armvixltemplate <typename T> inline void USE(T, T, T, T) {} 88ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 89b0c8ae2a5f0abc58f67322052d39bfd47edb2892armvixl#define VIXL_ALIGNMENT_EXCEPTION() printf("ALIGNMENT EXCEPTION\t"); VIXL_ABORT() 90ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl 91ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#endif // VIXL_GLOBALS_H 92