* runtime/config/sparc/os-unix-sysdep.c (__cilkrts_getticks): Adjust
[official-gcc.git] / libcilkrts / runtime / config / sparc / os-unix-sysdep.c
bloba3ede6461a022f83a167457623de13e3289599c3
1 /* os-unix-sysdep.c -*-C-*-
3 *************************************************************************
5 * Copyright (C) 2009-2016, Intel Corporation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
32 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * *********************************************************************
37 * PLEASE NOTE: This file is a downstream copy of a file mainitained in
38 * a repository at cilkplus.org. Changes made to this file that are not
39 * submitted through the contribution process detailed at
40 * http://www.cilkplus.org/submit-cilk-contribution will be lost the next
41 * time that a new version is released. Changes only submitted to the
42 * GNU compiler collection or posted to the git repository at
43 * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
44 * not tracked.
46 * We welcome your contributions to this open source project. Thank you
47 * for your assistance in helping us improve Cilk Plus.
48 *************************************************************************
50 * This file contains system-specific code for SPARC-based systems
53 #include "os.h"
54 #include "sysdep.h"
57 * The cycle counter is used for debugging. This function is only called if
58 * CILK_PROFILE is defined when the runtime is built.
60 COMMON_SYSDEP unsigned long long __cilkrts_getticks(void)
62 unsigned long long tick;
63 #if defined(__sparcv9) || defined(__arch64__)
64 __asm__ volatile("rd %%tick, %0" : "=r"(tick));
65 #else
66 __asm__ volatile("rd %%tick, %L0\n"
67 "srlx %L0, 32, %H0"
68 : "=r"(tick));
69 #endif
70 return tick;
74 * A "short pause" - called from the Cilk runtime's spinloops.
76 COMMON_SYSDEP void __cilkrts_short_pause(void)
78 /* Spin around for 8 cycles. */
79 __asm__ volatile("rd %ccr, %g0");
80 __asm__ volatile("rd %ccr, %g0");
81 __asm__ volatile("rd %ccr, %g0");
82 __asm__ volatile("rd %ccr, %g0");
86 * Interlocked exchange - used to implement the Cilk runtime's spinloops
88 COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr, int x)
90 x = __sync_lock_test_and_set(ptr, x);
91 return x;
96 * Restore the floating point state that is stored in a stack frame at each
97 * spawn. This should be called each time a frame is resumed.
99 * Only valid for IA32 and Intel64 processors.
101 void restore_x86_fp_state (__cilkrts_stack_frame *sf)
107 * Save the floating point state to the __cilkrts_stack_frame at each spawn.
109 * Architecture-specific - Should only be needed on IA32 and Intel64
110 * processors.
112 void sysdep_save_fp_ctrl_state(__cilkrts_stack_frame *sf)