1 /* MIPS support code for fibers and multithreading.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #include "../common/threadasm.S"
27 #if _MIPS_SIM == _ABIO32
30 * Performs a context switch.
32 * $a0 - void** - ptr to old stack pointer
33 * $a1 - void* - new stack pointer
37 .globl fiber_switchContext
39 .ent fiber_switchContext,0
42 addiu $sp, $sp, -(10 * 4)
44 // fp regs and return address are stored below the stack
45 // because we don't want the GC to scan them.
47 #ifdef __mips_hard_float
48 #define ALIGN8(val) (val + (-val & 7))
49 #define BELOW (ALIGN8(6 * 8 + 4))
50 sdc1 $f20, (0 * 8 - BELOW)($sp)
51 sdc1 $f22, (1 * 8 - BELOW)($sp)
52 sdc1 $f24, (2 * 8 - BELOW)($sp)
53 sdc1 $f26, (3 * 8 - BELOW)($sp)
54 sdc1 $f28, (4 * 8 - BELOW)($sp)
55 sdc1 $f30, (5 * 8 - BELOW)($sp)
74 #ifdef __mips_hard_float
75 ldc1 $f20, (0 * 8 - BELOW)($sp)
76 ldc1 $f22, (1 * 8 - BELOW)($sp)
77 ldc1 $f24, (2 * 8 - BELOW)($sp)
78 ldc1 $f26, (3 * 8 - BELOW)($sp)
79 ldc1 $f28, (4 * 8 - BELOW)($sp)
80 ldc1 $f30, (5 * 8 - BELOW)($sp)
95 addiu $sp, $sp, (10 * 4)
99 .end fiber_switchContext
100 .size fiber_switchContext,.-fiber_switchContext