blob: f52877657cd83b93b0840c62bf344d1e78fae307 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_BASE_BUILD_CONFIG_H_
6#define V8_BASE_BUILD_CONFIG_H_
7
8#include "include/v8config.h"
9
10// Processor architecture detection. For more info on what's defined, see:
11// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
12// http://www.agner.org/optimize/calling_conventions.pdf
13// or with gcc, run: "echo | gcc -E -dM -"
14#if defined(_M_X64) || defined(__x86_64__)
15#if defined(__native_client__)
16// For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
17// generates ARM machine code, together with a portable ARM simulator
18// compiled for the host architecture in question.
19//
20// Since Native Client is ILP-32 on all architectures we use
21// V8_HOST_ARCH_IA32 on both 32- and 64-bit x86.
22#define V8_HOST_ARCH_IA32 1
23#define V8_HOST_ARCH_32_BIT 1
24#else
25#define V8_HOST_ARCH_X64 1
26#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32.
27#define V8_HOST_ARCH_32_BIT 1
28#else
29#define V8_HOST_ARCH_64_BIT 1
30#endif
31#endif // __native_client__
Emily Bernierd0a1eb72015-03-24 16:35:39 -040032#elif defined(__pnacl__)
33// PNaCl is also ILP-32.
34#define V8_HOST_ARCH_IA32 1
35#define V8_HOST_ARCH_32_BIT 1
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036#elif defined(_M_IX86) || defined(__i386__)
37#define V8_HOST_ARCH_IA32 1
38#define V8_HOST_ARCH_32_BIT 1
39#elif defined(__AARCH64EL__)
40#define V8_HOST_ARCH_ARM64 1
41#define V8_HOST_ARCH_64_BIT 1
42#elif defined(__ARMEL__)
43#define V8_HOST_ARCH_ARM 1
44#define V8_HOST_ARCH_32_BIT 1
45#elif defined(__mips64)
46#define V8_HOST_ARCH_MIPS64 1
47#define V8_HOST_ARCH_64_BIT 1
48#elif defined(__MIPSEB__) || defined(__MIPSEL__)
49#define V8_HOST_ARCH_MIPS 1
50#define V8_HOST_ARCH_32_BIT 1
51#else
52#error "Host architecture was not detected as supported by v8"
53#endif
54
55#if defined(__ARM_ARCH_7A__) || \
56 defined(__ARM_ARCH_7R__) || \
57 defined(__ARM_ARCH_7__)
58# define CAN_USE_ARMV7_INSTRUCTIONS 1
59# ifndef CAN_USE_VFP3_INSTRUCTIONS
60# define CAN_USE_VFP3_INSTRUCTIONS
61# endif
62#endif
63
64
65// Target architecture detection. This may be set externally. If not, detect
66// in the same way as the host architecture, that is, target the native
67// environment as presented by the compiler.
68#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_X87 && \
69 !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && \
70 !V8_TARGET_ARCH_MIPS64
71#if defined(_M_X64) || defined(__x86_64__)
72#define V8_TARGET_ARCH_X64 1
73#elif defined(_M_IX86) || defined(__i386__)
74#define V8_TARGET_ARCH_IA32 1
75#elif defined(__AARCH64EL__)
76#define V8_TARGET_ARCH_ARM64 1
77#elif defined(__ARMEL__)
78#define V8_TARGET_ARCH_ARM 1
79#elif defined(__mips64)
80#define V8_TARGET_ARCH_MIPS64 1
81#elif defined(__MIPSEB__) || defined(__MIPSEL__)
82#define V8_TARGET_ARCH_MIPS 1
83#else
84#error Target architecture was not detected as supported by v8
85#endif
86#endif
87
88// Determine architecture pointer size.
89#if V8_TARGET_ARCH_IA32
90#define V8_TARGET_ARCH_32_BIT 1
91#elif V8_TARGET_ARCH_X64
92#if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT
93#if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32.
94#define V8_TARGET_ARCH_32_BIT 1
95#else
96#define V8_TARGET_ARCH_64_BIT 1
97#endif
98#endif
99#elif V8_TARGET_ARCH_ARM
100#define V8_TARGET_ARCH_32_BIT 1
101#elif V8_TARGET_ARCH_ARM64
102#define V8_TARGET_ARCH_64_BIT 1
103#elif V8_TARGET_ARCH_MIPS
104#define V8_TARGET_ARCH_32_BIT 1
105#elif V8_TARGET_ARCH_MIPS64
106#define V8_TARGET_ARCH_64_BIT 1
107#elif V8_TARGET_ARCH_X87
108#define V8_TARGET_ARCH_32_BIT 1
109#else
110#error Unknown target architecture pointer size
111#endif
112
113// Check for supported combinations of host and target architectures.
114#if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
115#error Target architecture ia32 is only supported on ia32 host
116#endif
117#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \
118 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_64_BIT))
119#error Target architecture x64 is only supported on x64 host
120#endif
121#if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \
122 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT))
123#error Target architecture x32 is only supported on x64 host with x32 support
124#endif
125#if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM))
126#error Target architecture arm is only supported on arm and ia32 host
127#endif
128#if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64))
129#error Target architecture arm64 is only supported on arm64 and x64 host
130#endif
131#if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS))
132#error Target architecture mips is only supported on mips and ia32 host
133#endif
134#if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64))
135#error Target architecture mips64 is only supported on mips64 and x64 host
136#endif
137
138// Determine architecture endianness.
139#if V8_TARGET_ARCH_IA32
140#define V8_TARGET_LITTLE_ENDIAN 1
141#elif V8_TARGET_ARCH_X64
142#define V8_TARGET_LITTLE_ENDIAN 1
143#elif V8_TARGET_ARCH_ARM
144#define V8_TARGET_LITTLE_ENDIAN 1
145#elif V8_TARGET_ARCH_ARM64
146#define V8_TARGET_LITTLE_ENDIAN 1
147#elif V8_TARGET_ARCH_MIPS
148#if defined(__MIPSEB__)
149#define V8_TARGET_BIG_ENDIAN 1
150#else
151#define V8_TARGET_LITTLE_ENDIAN 1
152#endif
153#elif V8_TARGET_ARCH_MIPS64
154#define V8_TARGET_LITTLE_ENDIAN 1
155#elif V8_TARGET_ARCH_X87
156#define V8_TARGET_LITTLE_ENDIAN 1
157#else
158#error Unknown target architecture endianness
159#endif
160
161// Number of bits to represent the page size for paged spaces. The value of 20
162// gives 1Mb bytes per page.
163const int kPageSizeBits = 20;
164
165#endif // V8_BASE_BUILD_CONFIG_H_