w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pixman-arm.c
Go to the documentation of this file.
1 /*
2  * Copyright © 2000 SuSE, Inc.
3  * Copyright © 2007 Red Hat, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of SuSE not be used in advertising or
10  * publicity pertaining to distribution of the software without specific,
11  * written prior permission. SuSE makes no representations about the
12  * suitability of this software for any purpose. It is provided "as is"
13  * without express or implied warranty.
14  *
15  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 
26 #include "pixman-private.h"
27 
28 typedef enum
29 {
30  ARM_V7 = (1 << 0),
31  ARM_V6 = (1 << 1),
32  ARM_VFP = (1 << 2),
33  ARM_NEON = (1 << 3),
34  ARM_IWMMXT = (1 << 4)
36 
37 #if defined(USE_ARM_SIMD) || defined(USE_ARM_NEON) || defined(USE_ARM_IWMMXT)
38 
39 #if defined(_MSC_VER)
40 
41 /* Needed for EXCEPTION_ILLEGAL_INSTRUCTION */
42 #include <windows.h>
43 
44 extern int pixman_msvc_try_arm_neon_op ();
45 extern int pixman_msvc_try_arm_simd_op ();
46 
47 static arm_cpu_features_t
48 detect_cpu_features (void)
49 {
51 
52  __try
53  {
54  pixman_msvc_try_arm_simd_op ();
55  features |= ARM_V6;
56  }
57  __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
58  {
59  }
60 
61  __try
62  {
63  pixman_msvc_try_arm_neon_op ();
64  features |= ARM_NEON;
65  }
66  __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
67  {
68  }
69 
70  return features;
71 }
72 
73 #elif defined(__APPLE__) && defined(TARGET_OS_IPHONE) /* iOS */
74 
75 #include "TargetConditionals.h"
76 
77 static arm_cpu_features_t
78 detect_cpu_features (void)
79 {
81 
82  features |= ARM_V6;
83 
84  /* Detection of ARM NEON on iOS is fairly simple because iOS binaries
85  * contain separate executable images for each processor architecture.
86  * So all we have to do is detect the armv7 architecture build. The
87  * operating system automatically runs the armv7 binary for armv7 devices
88  * and the armv6 binary for armv6 devices.
89  */
90 #if defined(__ARM_NEON__)
91  features |= ARM_NEON;
92 #endif
93 
94  return features;
95 }
96 
97 #elif defined(__ANDROID__) || defined(ANDROID) /* Android */
98 
99 #include <cpu-features.h>
100 
101 static arm_cpu_features_t
102 detect_cpu_features (void)
103 {
105  AndroidCpuFamily cpu_family;
106  uint64_t cpu_features;
107 
108  cpu_family = android_getCpuFamily();
109  cpu_features = android_getCpuFeatures();
110 
111  if (cpu_family == ANDROID_CPU_FAMILY_ARM)
112  {
113  if (cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7)
114  features |= ARM_V7;
115 
116  if (cpu_features & ANDROID_CPU_ARM_FEATURE_VFPv3)
117  features |= ARM_VFP;
118 
119  if (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON)
120  features |= ARM_NEON;
121  }
122 
123  return features;
124 }
125 
126 #elif defined (__linux__) /* linux ELF */
127 
128 #include <unistd.h>
129 #include <sys/types.h>
130 #include <sys/stat.h>
131 #include <sys/mman.h>
132 #include <fcntl.h>
133 #include <string.h>
134 #include <elf.h>
135 
136 static arm_cpu_features_t
137 detect_cpu_features (void)
138 {
140  Elf32_auxv_t aux;
141  int fd;
142 
143  fd = open ("/proc/self/auxv", O_RDONLY);
144  if (fd >= 0)
145  {
146  while (read (fd, &aux, sizeof(Elf32_auxv_t)) == sizeof(Elf32_auxv_t))
147  {
148  if (aux.a_type == AT_HWCAP)
149  {
150  uint32_t hwcap = aux.a_un.a_val;
151 
152  /* hardcode these values to avoid depending on specific
153  * versions of the hwcap header, e.g. HWCAP_NEON
154  */
155  if ((hwcap & 64) != 0)
156  features |= ARM_VFP;
157  if ((hwcap & 512) != 0)
158  features |= ARM_IWMMXT;
159  /* this flag is only present on kernel 2.6.29 */
160  if ((hwcap & 4096) != 0)
161  features |= ARM_NEON;
162  }
163  else if (aux.a_type == AT_PLATFORM)
164  {
165  const char *plat = (const char*) aux.a_un.a_val;
166 
167  if (strncmp (plat, "v7l", 3) == 0)
168  features |= (ARM_V7 | ARM_V6);
169  else if (strncmp (plat, "v6l", 3) == 0)
170  features |= ARM_V6;
171  }
172  }
173  close (fd);
174  }
175 
176  return features;
177 }
178 
179 #elif defined (_3DS) /* 3DS homebrew (devkitARM) */
180 
181 static arm_cpu_features_t
182 detect_cpu_features (void)
183 {
185 
186  features |= ARM_V6;
187 
188  return features;
189 }
190 
191 #elif defined (PSP2) || defined (__SWITCH__)
192 /* Vita (VitaSDK) or Switch (devkitA64) homebrew */
193 
194 static arm_cpu_features_t
195 detect_cpu_features (void)
196 {
198 
199  features |= ARM_NEON;
200 
201  return features;
202 }
203 
204 #else /* Unknown */
205 
206 static arm_cpu_features_t
207 detect_cpu_features (void)
208 {
209  return 0;
210 }
211 
212 #endif /* Linux elf */
213 
214 static pixman_bool_t
215 have_feature (arm_cpu_features_t feature)
216 {
217  static pixman_bool_t initialized;
219 
220  if (!initialized)
221  {
222  features = detect_cpu_features();
223  initialized = TRUE;
224  }
225 
226  return (features & feature) == feature;
227 }
228 
229 #endif /* USE_ARM_SIMD || USE_ARM_NEON || USE_ARM_IWMMXT */
230 
233 {
234 #ifdef USE_ARM_SIMD
235  if (!_pixman_disabled ("arm-simd") && have_feature (ARM_V6))
237 #endif
238 
239 #ifdef USE_ARM_IWMMXT
240  if (!_pixman_disabled ("arm-iwmmxt") && have_feature (ARM_IWMMXT))
241  imp = _pixman_implementation_create_mmx (imp);
242 #endif
243 
244 #ifdef USE_ARM_NEON
245  if (!_pixman_disabled ("arm-neon") && have_feature (ARM_NEON))
247 #endif
248 
249  return imp;
250 }
feature
Definition: control.c:37
@ TRUE
Definition: dd.h:102
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
#define read
Definition: win32lib.h:88
#define O_RDONLY
Definition: win32lib.h:176
#define open
Definition: win32lib.h:86
#define close
Definition: win32lib.h:63
int strncmp()
@ aux
Definition: lyrics.c:59
static const Mapping features[]
Definition: otfdescrip.cc:537
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
pixman_implementation_t * _pixman_implementation_create_arm_neon(pixman_implementation_t *fallback)
pixman_implementation_t * _pixman_implementation_create_arm_simd(pixman_implementation_t *fallback)
arm_cpu_features_t
Definition: pixman-arm.c:29
@ ARM_V7
Definition: pixman-arm.c:30
@ ARM_IWMMXT
Definition: pixman-arm.c:34
@ ARM_V6
Definition: pixman-arm.c:31
@ ARM_NEON
Definition: pixman-arm.c:33
@ ARM_VFP
Definition: pixman-arm.c:32
pixman_implementation_t * _pixman_arm_get_implementations(pixman_implementation_t *imp)
Definition: pixman-arm.c:232
pixman_bool_t _pixman_disabled(const char *name)
int pixman_bool_t
Definition: pixman.h:113