167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Copyright 2009 The Go Authors. All rights reserved.
267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Use of this source code is governed by a BSD-style
367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// license that can be found in the LICENSE file.
467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#include "go_asm.h"
667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#include "go_tls.h"
767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#include "funcdata.h"
867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#include "textflag.h"
967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
1067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// _rt0_arm is common startup code for most ARM systems when using
1167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// internal linking. This is the entry point for the program from the
1267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// kernel for an ordinary -buildmode=exe program. The stack holds the
1367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// number of arguments and the C-style argv.
1467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT _rt0_arm(SB),NOSPLIT,$-4
1567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R13), R0	// argc
1667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$4(R13), R1		// argv
1767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·rt0_go(SB)
1867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
1967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// main is common startup code for most ARM systems when using
2067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// external linking. The C startup code will call the symbol "main"
2167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// passing argc and argv in the usual C ABI registers R0 and R1.
2267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT main(SB),NOSPLIT,$-4
2367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·rt0_go(SB)
2467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
2567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// _rt0_arm_lib is common startup code for most ARM systems when
2667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// using -buildmode=c-archive or -buildmode=c-shared. The linker will
2767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// arrange to invoke this function as a global constructor (for
2867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// c-archive) or when the shared library is loaded (for c-shared).
2967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// We expect argc and argv to be passed in the usual C ABI registers
3067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R0 and R1.
3167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT _rt0_arm_lib(SB),NOSPLIT,$104
3267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Preserve callee-save registers. Raspberry Pi's dlopen(), for example,
3367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// actually cares that R11 is preserved.
3467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, 12(R13)
3567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, 16(R13)
3667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R6, 20(R13)
3767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R7, 24(R13)
3867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R8, 28(R13)
3967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, 32(R13)
4067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
4167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Skip floating point registers on GOARM < 6.
4267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB    runtime·goarm(SB), R11
4367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$6, R11
4467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BLT	skipfpsave
4567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F8, (32+8*1)(R13)
4667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F9, (32+8*2)(R13)
4767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F10, (32+8*3)(R13)
4867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F11, (32+8*4)(R13)
4967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F12, (32+8*5)(R13)
5067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F13, (32+8*6)(R13)
5167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F14, (32+8*7)(R13)
5267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	F15, (32+8*8)(R13)
5367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotskipfpsave:
5467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Save argc/argv.
5567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, _rt0_arm_lib_argc<>(SB)
5667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, _rt0_arm_lib_argv<>(SB)
5767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
5867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Synchronous initialization.
5967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CALL	runtime·libpreinit(SB)
6067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
6167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Create a new thread to do the runtime initialization.
6267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	_cgo_sys_thread_create(SB), R2
6367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R2
6467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	nocgo
6567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$_rt0_arm_lib_go<>(SB), R0
6667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R1
6767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R2)
6867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	rr
6967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotnocgo:
7067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0x800000, R0                     // stacksize = 8192KB
7167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$_rt0_arm_lib_go<>(SB), R1  // fn
7267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 4(R13)
7367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 8(R13)
7467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·newosproc0(SB)
7567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotrr:
7667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Restore callee-save registers and return.
7767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB    runtime·goarm(SB), R11
7867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$6, R11
7967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BLT	skipfprest
8067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*1)(R13), F8
8167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*2)(R13), F9
8267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*3)(R13), F10
8367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*4)(R13), F11
8467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*5)(R13), F12
8567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*6)(R13), F13
8667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*7)(R13), F14
8767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVD	(32+8*8)(R13), F15
8867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotskipfprest:
8967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	12(R13), R4
9067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	16(R13), R5
9167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	20(R13), R6
9267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	24(R13), R7
9367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	28(R13), R8
9467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	32(R13), R11
9567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
9667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
9767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// _rt0_arm_lib_go initializes the Go runtime.
9867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// This is started in a separate thread by _rt0_arm_lib.
9967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT _rt0_arm_lib_go<>(SB),NOSPLIT,$8
10067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	_rt0_arm_lib_argc<>(SB), R0
10167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	_rt0_arm_lib_argv<>(SB), R1
10267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·rt0_go(SB)
10367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
10467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotDATA _rt0_arm_lib_argc<>(SB)/4,$0
10567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotGLOBL _rt0_arm_lib_argc<>(SB),NOPTR,$4
10667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotDATA _rt0_arm_lib_argv<>(SB)/4,$0
10767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotGLOBL _rt0_arm_lib_argv<>(SB),NOPTR,$4
10867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
10967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// using frame size $-4 means do not save LR on stack.
11067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// argc is in R0, argv is in R1.
11167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·rt0_go(SB),NOSPLIT,$-4
11267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0xcafebabe, R12
11367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
11467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// copy arguments forward on an even stack
11567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// use R13 instead of SP to avoid linker rewriting the offsets
11667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$64, R13		// plenty of scratch
11767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	AND	$~7, R13
11867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 60(R13)		// save argc, argv away
11967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 64(R13)
12067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
12167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// set up g register
12267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// g is R10
12367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·g0(SB), g
12467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·m0(SB), R8
12567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
12667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// save m->g0 = g0
12767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, m_g0(R8)
12867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// save g->m = m0
12967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R8, g_m(g)
13067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
13167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// create istack out of the OS stack
13267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// (1MB of system stack is available on iOS and Android)
13367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$(-64*1024+104)(R13), R0
13467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, g_stackguard0(g)
13567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, g_stackguard1(g)
13667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, (g_stack+stack_lo)(g)
13767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_stack+stack_hi)(g)
13867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
13967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·emptyfunc(SB)	// fault if stack check is wrong
14067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
14167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·_initcgo(SB)	// will clobber R0-R3
14267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
14367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// update stackguard after _cgo_init
14467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_stack+stack_lo)(g), R0
14567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$const__StackGuard, R0
14667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, g_stackguard0(g)
14767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, g_stackguard1(g)
14867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
14967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·check(SB)
15067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
15167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// saved argc, argv
15267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	60(R13), R0
15367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 4(R13)
15467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	64(R13), R1
15567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 8(R13)
15667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·args(SB)
15767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·checkgoarm(SB)
15867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·osinit(SB)
15967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·schedinit(SB)
16067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
16167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// create a new goroutine to start program
16267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·mainPC(SB), R0
16367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.W	R0, -4(R13)
16467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$8, R0
16567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.W	R0, -4(R13)
16667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
16767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.W	R0, -4(R13)	// push $0 as guard
16867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·newproc(SB)
16967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$12(R13), R13	// pop args and LR
17067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
17167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// start this M
17267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·mstart(SB)
17367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
17467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1234, R0
17567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1000, R1
17667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, (R1)	// fail hard
17767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
17867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotDATA	runtime·mainPC+0(SB)/4,$runtime·main(SB)
17967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotGLOBL	runtime·mainPC(SB),RODATA,$4
18067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
18167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·breakpoint(SB),NOSPLIT,$0-0
18267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// gdb won't skip this breakpoint instruction automatically,
18367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// so you must manually "set $pc+=4" to skip it and continue.
18467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#ifdef GOOS_nacl
18567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xe125be7f	// BKPT 0x5bef, NACL_INSTR_ARM_BREAKPOINT
18667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#else
18767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#ifdef GOOS_plan9
18867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xD1200070	// undefined instruction used as armv5 breakpoint in Plan 9
18967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#else
19067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xe7f001f0	// undefined instruction that gdb understands is a software breakpoint
19167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#endif
19267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#endif
19367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
19467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
19567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·asminit(SB),NOSPLIT,$0-0
19667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// disable runfast (flush-to-zero) mode of vfp if runtime.goarm > 5
19767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	runtime·goarm(SB), R11
19867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$5, R11
19967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BLE	4(PC)
20067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xeef1ba10	// vmrs r11, fpscr
20167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BIC	$(1<<24), R11
20267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xeee1ba10	// vmsr fpscr, r11
20367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
20467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
20567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot/*
20667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot *  go-routine
20767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot */
20867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
20967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// void gosave(Gobuf*)
21067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// save state in Gobuf; setjmp
21167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·gosave(SB),NOSPLIT,$-4-4
21267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	buf+0(FP), R0
21367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, gobuf_sp(R0)
21467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	LR, gobuf_pc(R0)
21567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, gobuf_g(R0)
21667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R11
21767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_lr(R0)
21867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_ret(R0)
21967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Assert ctxt is zero. See func save.
22067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_ctxt(R0), R0
22167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R11
22267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	2(PC)
22367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CALL	runtime·badctxt(SB)
22467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
22567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
22667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// void gogo(Gobuf*)
22767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// restore state from Gobuf; longjmp
22867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·gogo(SB),NOSPLIT,$8-4
22967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	buf+0(FP), R1
23067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_g(R1), R0
23167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
23267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
23367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// NOTE: We updated g above, and we are about to update SP.
23467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Until LR and PC are also updated, the g/SP/LR/PC quadruple
23567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// are out of sync and must not be used as the basis of a traceback.
23667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Sigprof skips the traceback when SP is not within g's bounds,
23767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// and when the PC is inside this function, runtime.gogo.
23867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Since we are about to update SP, until we complete runtime.gogo
23967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// we must not leave this function. In particular, no calls
24067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// after this point: it must be straight-line code until the
24167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// final B instruction.
24267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// See large comment in sigprof for more details.
24367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_sp(R1), R13	// restore SP==R13
24467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_lr(R1), LR
24567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_ret(R1), R0
24667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_ctxt(R1), R7
24767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R11
24867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_sp(R1)	// clear to help garbage collector
24967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_ret(R1)
25067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_lr(R1)
25167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, gobuf_ctxt(R1)
25267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gobuf_pc(R1), R11
25367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R11, R11 // set condition codes for == test, needed by stack split
25467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	(R11)
25567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
25667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// func mcall(fn func(*g))
25767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Switch to m->g0's stack, call fn(g).
25867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Fn must never return. It should gogo(&g->sched)
25967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// to keep running g.
26067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·mcall(SB),NOSPLIT,$-4-4
26167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Save caller state in g->sched.
26267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(g)
26367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	LR, (g_sched+gobuf_pc)(g)
26467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R11
26567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, (g_sched+gobuf_lr)(g)
26667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, (g_sched+gobuf_g)(g)
26767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
26867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Switch to m->g0 & its stack, call fn.
26967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, R1
27067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
27167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R0
27267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
27367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R1
27467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	2(PC)
27567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·badmcall(SB)
27667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	runtime·iscgo(SB), R11
27767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R11
27867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL.NE	runtime·save_g(SB)
27967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	fn+0(FP), R0
28067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R13
28167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$8, R13
28267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 4(R13)
28367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R7
28467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R0), R0
28567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
28667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·badmcall2(SB)
28767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
28867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
28967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// systemstack_switch is a dummy routine that systemstack leaves at the bottom
29067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// of the G stack. We need to distinguish the routine that
29167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// lives at the bottom of the G stack from the one that lives
29267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// at the top of the system stack because the one at the top of
29367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// the system stack terminates the stack walk (see topofstack()).
29467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·systemstack_switch(SB),NOSPLIT,$0-0
29567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
29667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0) // clobber lr to ensure push {lr} is kept
29767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
29867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
29967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// func systemstack(fn func())
30067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·systemstack(SB),NOSPLIT,$0-4
30167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	fn+0(FP), R0	// R0 = fn
30267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R1	// R1 = m
30367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
30467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_gsignal(R1), R2	// R2 = gsignal
30567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R2
30667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	noswitch
30767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
30867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R1), R2	// R2 = g0
30967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R2
31067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	noswitch
31167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
31267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_curg(R1), R3
31367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R3
31467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	switch
31567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
31667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Bad: g is not gsignal, not g0, not curg. What is it?
31767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Hide call from linker nosplit analysis.
31867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·badsystemstack(SB), R0
31967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
32067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
32167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotswitch:
32267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// save our state in g->sched. Pretend to
32367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// be systemstack_switch if the G stack is scanned.
32467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·systemstack_switch(SB), R3
32567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#ifdef GOOS_nacl
32667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$4, R3, R3 // get past nacl-insert bic instruction
32767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#endif
32867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$4, R3, R3 // get past push {lr}
32967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, (g_sched+gobuf_pc)(g)
33067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(g)
33167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	LR, (g_sched+gobuf_lr)(g)
33267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, (g_sched+gobuf_g)(g)
33367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
33467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// switch to g0
33567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R5
33667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R2, R0
33767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
33867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, R0
33967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(R2), R3
34067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// make it look like mstart called systemstack on g0, to stop traceback
34167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$4, R3, R3
34267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·mstart(SB), R4
34367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, 0(R3)
34467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, R13
34567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
34667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// call target function
34767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R7
34867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R0), R0
34967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
35067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
35167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// switch back to g
35267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R1
35367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_curg(R1), R0
35467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
35567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R13
35667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R3
35767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, (g_sched+gobuf_sp)(g)
35867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
35967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
36067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotnoswitch:
36167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Using a tail call here cleans up tracebacks since we won't stop
36267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// at an intermediate systemstack.
36367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R7
36467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R0), R0
36567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.P	4(R13), R14	// restore LR
36667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	(R0)
36767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
36867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot/*
36967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot * support for morestack
37067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot */
37167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
37267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Called during function prolog when more stack is needed.
37367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R1 frame size
37467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R3 prolog's LR
37567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// NB. we do not save R0 because we've forced 5c to pass all arguments
37667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// on the stack.
37767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// using frame size $-4 means do not save LR on stack.
37867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//
37967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// The traceback routines see morestack on a g0 as being
38067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// the top of a stack (for example, morestack calling newstack
38167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// calling the scheduler calling newm calling gc), so we must
38267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// record an argument size. For that purpose, it has no arguments.
38367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·morestack(SB),NOSPLIT,$-4-0
38467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Cannot grow scheduler stack (m->g0).
38567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
38667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R4
38767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R4
38867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BNE	3(PC)
38967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·badmorestackg0(SB)
39067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·abort(SB)
39167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
39267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Cannot grow signal stack (m->gsignal).
39367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_gsignal(R8), R4
39467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	g, R4
39567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BNE	3(PC)
39667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·badmorestackgsignal(SB)
39767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·abort(SB)
39867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
39967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Called from f.
40067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Set g->sched to context in f.
40167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(g)
40267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	LR, (g_sched+gobuf_pc)(g)
40367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, (g_sched+gobuf_lr)(g)
40467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R7, (g_sched+gobuf_ctxt)(g)
40567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
40667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Called from f.
40767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Set m->morebuf to f's caller.
40867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, (m_morebuf+gobuf_pc)(R8)	// f's caller's PC
40967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (m_morebuf+gobuf_sp)(R8)	// f's caller's SP
41067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$4(R13), R3			// f's argument pointer
41167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, (m_morebuf+gobuf_g)(R8)
41267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
41367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Call newstack on m->g0's stack.
41467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R0
41567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
41667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R13
41767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
41867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.W  R0, -4(R13)	// create a call frame on g0 (saved LR)
41967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·newstack(SB)
42067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
42167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Not reached, but make sure the return PC from the call to newstack
42267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// is still in this function, and not the beginning of the next.
42367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
42467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
42567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·morestack_noctxt(SB),NOSPLIT,$-4-0
42667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R7
42767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B runtime·morestack(SB)
42867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
42967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// reflectcall: call a function with the given argument list
43067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// func call(argtype *_type, f *FuncVal, arg *byte, argsize, retoffset uint32).
43167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// we don't have variable-sized frames, so we use a small number
43267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// of constant-sized-frame functions to encode a few bits of size in the pc.
43367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Caution: ugly multiline assembly macros in your future!
43467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
43567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#define DISPATCH(NAME,MAXSIZE)		\
43667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$MAXSIZE, R0;		\
43767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.HI	3(PC);			\
43867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$NAME(SB), R1;		\
43967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	(R1)
44067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
44167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT reflect·call(SB), NOSPLIT, $0-0
44267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	·reflectcall(SB)
44367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
44467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT ·reflectcall(SB),NOSPLIT,$-4-20
44567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argsize+12(FP), R0
44667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call16, 16)
44767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call32, 32)
44867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call64, 64)
44967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call128, 128)
45067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call256, 256)
45167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call512, 512)
45267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call1024, 1024)
45367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call2048, 2048)
45467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call4096, 4096)
45567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call8192, 8192)
45667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call16384, 16384)
45767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call32768, 32768)
45867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call65536, 65536)
45967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call131072, 131072)
46067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call262144, 262144)
46167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call524288, 524288)
46267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call1048576, 1048576)
46367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call2097152, 2097152)
46467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call4194304, 4194304)
46567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call8388608, 8388608)
46667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call16777216, 16777216)
46767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call33554432, 33554432)
46867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call67108864, 67108864)
46967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call134217728, 134217728)
47067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call268435456, 268435456)
47167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call536870912, 536870912)
47267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	DISPATCH(runtime·call1073741824, 1073741824)
47367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·badreflectcall(SB), R1
47467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	(R1)
47567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
47667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#define CALLFN(NAME,MAXSIZE)			\
47767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT NAME(SB), WRAPPER, $MAXSIZE-20;		\
47867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	NO_LOCAL_POINTERS;			\
47967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	/* copy arguments to stack */		\
48067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argptr+8(FP), R0;		\
48167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argsize+12(FP), R2;		\
48267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$4, R13, R1;			\
48367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R2;				\
48467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	5(PC);				\
48567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R0), R5;			\
48667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P R5, 1(R1);			\
48767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$1, R2, R2;			\
48867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	-5(PC);				\
48967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	/* call function */			\
49067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	f+4(FP), R7;			\
49167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R7), R0;			\
49267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	PCDATA  $PCDATA_StackMapIndex, $0;	\
49367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0);				\
49467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	/* copy return values back */		\
49567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argtype+0(FP), R4;		\
49667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argptr+8(FP), R0;		\
49767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argsize+12(FP), R2;		\
49867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	retoffset+16(FP), R3;		\
49967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$4, R13, R1;			\
50067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R3, R1;				\
50167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R3, R0;				\
50267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R3, R2;				\
50367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	callRet<>(SB);			\
50467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
50567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
50667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// callRet copies return values back at the end of call*. This is a
50767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// separate function so it can allocate stack space for the arguments
50867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// to reflectcallmove. It does not follow the Go ABI; it expects its
50967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// arguments in registers.
51067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT callRet<>(SB), NOSPLIT, $16-0
51167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, 4(R13)
51267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 8(R13)
51367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 12(R13)
51467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R2, 16(R13)
51567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·reflectcallmove(SB)
51667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
51767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
51867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall16, 16)
51967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall32, 32)
52067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall64, 64)
52167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall128, 128)
52267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall256, 256)
52367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall512, 512)
52467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall1024, 1024)
52567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall2048, 2048)
52667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall4096, 4096)
52767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall8192, 8192)
52867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall16384, 16384)
52967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall32768, 32768)
53067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall65536, 65536)
53167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall131072, 131072)
53267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall262144, 262144)
53367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall524288, 524288)
53467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall1048576, 1048576)
53567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall2097152, 2097152)
53667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall4194304, 4194304)
53767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall8388608, 8388608)
53867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall16777216, 16777216)
53967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall33554432, 33554432)
54067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall67108864, 67108864)
54167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall134217728, 134217728)
54267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall268435456, 268435456)
54367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall536870912, 536870912)
54467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotCALLFNcall1073741824, 1073741824)
54567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
54667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// void jmpdefer(fn, sp);
54767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// called from deferreturn.
54867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// 1. grab stored LR for caller
54967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// 2. sub 4 bytes to get back to BL deferreturn
55067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// 3. B to fn
55167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// TODO(rsc): Push things on stack and then use pop
55267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// to load all registers simultaneously, so that a profiling
55367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// interrupt can never see mismatched SP/LR/PC.
55467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// (And double-check that pop is atomic in that way.)
55567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·jmpdefer(SB),NOSPLIT,$0-8
55667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R13), LR
55767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$-4(LR), LR	// BL deferreturn
55867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	fv+0(FP), R7
55967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	argp+4(FP), R13
56067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$-4(R13), R13	// SP is 4 below argp, due to saved LR
56167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R7), R1
56267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	(R1)
56367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
56467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Save state of caller into g->sched. Smashes R11.
56567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT gosave<>(SB),NOSPLIT,$-4
56667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	LR, (g_sched+gobuf_pc)(g)
56767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(g)
56867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R11
56967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, (g_sched+gobuf_lr)(g)
57067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, (g_sched+gobuf_ret)(g)
57167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, (g_sched+gobuf_ctxt)(g)
57267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Assert ctxt is zero. See func save.
57367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_ctxt)(g), R11
57467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R11
57567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	2(PC)
57667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CALL	runtime·badctxt(SB)
57767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
57867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
57967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// func asmcgocall(fn, arg unsafe.Pointer) int32
58067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Call fn(arg) on the scheduler stack,
58167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// aligned appropriately for the gcc ABI.
58267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// See cgocall.go for more details.
58367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT ·asmcgocall(SB),NOSPLIT,$0-12
58467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	fn+0(FP), R1
58567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	arg+4(FP), R0
58667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
58767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, R2
58867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, R4
58967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
59067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Figure out if we need to switch to m->g0 stack.
59167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// We get called to create new OS threads too, and those
59267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// come in on the m->g0 stack already.
59367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
59467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R3
59567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R3, g
59667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	g0
59767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	gosave<>(SB)
59867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R5
59967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R3, R0
60067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
60167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, R0
60267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R13
60367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
60467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Now on a scheduling stack (a pthread-created stack).
60567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotg0:
60667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$24, R13
60767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BIC	$0x7, R13	// alignment for gcc ABI
60867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, 20(R13) // save old g
60967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_stack+stack_hi)(R4), R4
61067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R2, R4
61167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, 16(R13)	// save depth in stack (can't just save SP, as stack might be copied during a callback)
61267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R1)
61367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
61467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Restore registers, g, stack pointer.
61567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R5
61667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	20(R13), R0
61767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
61867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_stack+stack_hi)(g), R1
61967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	16(R13), R2
62067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R2, R1
62167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, R0
62267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, R13
62367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
62467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, ret+8(FP)
62567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
62667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
62767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// cgocallback(void (*fn)(void*), void *frame, uintptr framesize, uintptr ctxt)
62867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Turn the fn into a Go func (by taking its address) and call
62967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// cgocallback_gofunc.
63067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·cgocallback(SB),NOSPLIT,$16-16
63167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$fn+0(FP), R0
63267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 4(R13)
63367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	frame+4(FP), R0
63467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 8(R13)
63567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	framesize+8(FP), R0
63667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 12(R13)
63767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	ctxt+12(FP), R0
63867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 16(R13)
63967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·cgocallback_gofunc(SB), R0
64067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
64167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
64267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
64367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// cgocallback_gofunc(void (*fn)(void*), void *frame, uintptr framesize, uintptr ctxt)
64467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// See cgocall.go for more details.
64567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT	·cgocallback_gofunc(SB),NOSPLIT,$8-16
64667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	NO_LOCAL_POINTERS
64767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
64867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Load m and g from thread-local storage.
64967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	runtime·iscgo(SB), R0
65067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R0
65167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL.NE	runtime·load_g(SB)
65267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
65367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// If g is nil, Go did not create the current thread.
65467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Call needm to obtain one for temporary use.
65567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// In this case, we're running on the thread stack, so there's
65667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// lots of space, but the linker doesn't know. Hide the call from
65767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// the linker analysis by using an indirect call.
65867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, g
65967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	needm
66067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
66167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
66267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R8, savedm-4(SP)
66367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	havem
66467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
66567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotneedm:
66667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, savedm-4(SP) // g is zero, so is m.
66767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·needm(SB), R0
66867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
66967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
67067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Set m->sched.sp = SP, so that if a panic happens
67167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// during the function we are about to execute, it will
67267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// have a valid SP to run on the g0 stack.
67367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// The next few lines (after the havem label)
67467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// will save this SP onto the stack and then write
67567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// the same SP back to m->sched.sp. That seems redundant,
67667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// but if an unrecovered panic happens, unwindm will
67767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// restore the g->sched.sp from the stack location
67867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// and then systemstack will try to use it. If we don't set it here,
67967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// that restored SP will be uninitialized (typically 0) and
68067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// will not be usable.
68167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
68267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R3
68367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(R3)
68467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
68567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robothavem:
68667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Now there's a valid m, and we're running on its m->g0.
68767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Save current m->g0->sched.sp on stack and then set it to SP.
68867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Save current sp in m->g0->sched.sp in preparation for
68967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// switch back to m->curg stack.
69067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// NOTE: unwindm knows that the saved g->sched.sp is at 4(R13) aka savedsp-8(SP).
69167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R3
69267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(R3), R4
69367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, savedsp-8(SP)
69467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R13, (g_sched+gobuf_sp)(R3)
69567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
69667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Switch to m->curg stack and call runtime.cgocallbackg.
69767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Because we are taking over the execution of m->curg
69867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// but *not* resuming what had been running, we need to
69967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// save that information (m->curg->sched) so we can restore it.
70067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// We can restore m->curg->sched.sp easily, because calling
70167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// runtime.cgocallbackg leaves SP unchanged upon return.
70267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// To save m->curg->sched.pc, we push it onto the stack.
70367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// This has the added benefit that it looks to the traceback
70467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// routine like cgocallbackg is going to return to that
70567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// PC (because the frame we allocate below has the same
70667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// size as cgocallback_gofunc's frame declared above)
70767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// so that the traceback will seamlessly trace back into
70867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// the earlier calls.
70967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	//
71067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// In the new goroutine, -4(SP) is unused (where SP refers to
71167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// m->curg's SP while we're setting it up, before we've adjusted it).
71267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_curg(R8), R0
71367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
71467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R4 // prepare stack as R4
71567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_pc)(g), R5
71667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, -12(R4)
71767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	ctxt+12(FP), R0
71867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, -8(R4)
71967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$-12(R4), R13
72067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·cgocallbackg(SB)
72167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
72267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Restore g->sched (== m->curg->sched) from saved values.
72367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R13), R5
72467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R5, (g_sched+gobuf_pc)(g)
72567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$12(R13), R4
72667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, (g_sched+gobuf_sp)(g)
72767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
72867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Switch back to m->g0's stack and restore m->g0->sched.sp.
72967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// (Unlike m->curg, the g0 goroutine never uses sched.pc,
73067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// so we do not have to restore it.)
73167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R8
73267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_g0(R8), R0
73367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	setg<>(SB)
73467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_sched+gobuf_sp)(g), R13
73567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	savedsp-8(SP), R4
73667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R4, (g_sched+gobuf_sp)(g)
73767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
73867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// If the m on entry was nil, we called needm above to borrow an m
73967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// for the duration of the call. Since the call is over, return it with dropm.
74067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	savedm-4(SP), R6
74167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R6
74267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	3(PC)
74367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$runtime·dropm(SB), R0
74467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	(R0)
74567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
74667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Done!
74767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
74867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
74967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// void setg(G*); set g. for use by needm.
75067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·setg(SB),NOSPLIT,$-4-4
75167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	gg+0(FP), R0
75267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	setg<>(SB)
75367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
75467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT setg<>(SB),NOSPLIT,$-4-0
75567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, g
75667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
75767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// Save g to thread-local storage.
75867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	runtime·iscgo(SB), R0
75967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$0, R0
76067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	2(PC)
76167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·save_g(SB)
76267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
76367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, R0
76467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
76567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
76667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·getcallerpc(SB),NOSPLIT,$-4-4
76767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	0(R13), R0		// LR saved by caller
76867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, ret+0(FP)
76967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
77067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
77167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·emptyfunc(SB),0,$0-0
77267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
77367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
77467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·abort(SB),NOSPLIT,$-4-0
77567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
77667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R0), R1
77767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
77867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// armPublicationBarrier is a native store/store barrier for ARMv7+.
77967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// On earlier ARM revisions, armPublicationBarrier is a no-op.
78067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// This will not work on SMP ARMv6 machines, if any are in use.
78167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// To implement publicationBarrier in sys_$GOOS_arm.s using the native
78267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// instructions, use:
78367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//
78467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//	TEXT ·publicationBarrier(SB),NOSPLIT,$-4-0
78567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//		B	runtime·armPublicationBarrier(SB)
78667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//
78767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·armPublicationBarrier(SB),NOSPLIT,$-4-0
78867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	runtime·goarm(SB), R11
78967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	$7, R11
79067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BLT	2(PC)
79167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD $0xf57ff05e	// DMB ST
79267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
79367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
79467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// AES hashing not implemented for ARM
79567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·aeshash(SB),NOSPLIT,$-4-0
79667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
79767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R0), R1
79867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·aeshash32(SB),NOSPLIT,$-4-0
79967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
80067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R0), R1
80167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·aeshash64(SB),NOSPLIT,$-4-0
80267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
80367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R0), R1
80467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·aeshashstr(SB),NOSPLIT,$-4-0
80567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
80667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(R0), R1
80767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
80867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// memequal(p, q unsafe.Pointer, size uintptr) bool
80967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·memequal(SB),NOSPLIT,$-4-13
81067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	a+0(FP), R1
81167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	b+4(FP), R2
81267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	size+8(FP), R3
81367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R1, R3, R6
81467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1, R0
81567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	R0, ret+12(FP)
81667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R1, R2
81767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET.EQ
81867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotloop:
81967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R1, R6
82067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET.EQ
82167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R1), R4
82267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R2), R5
82367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R4, R5
82467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	loop
82567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
82667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
82767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	R0, ret+12(FP)
82867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
82967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
83067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// memequal_varlen(a, b unsafe.Pointer) bool
83167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·memequal_varlen(SB),NOSPLIT,$16-9
83267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	a+0(FP), R0
83367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	b+4(FP), R1
83467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
83567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	eq
83667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	4(R7), R2    // compiler stores size at offset 4 in the closure
83767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, 4(R13)
83867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, 8(R13)
83967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R2, 12(R13)
84067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·memequal(SB)
84167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	16(R13), R0
84267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	R0, ret+8(FP)
84367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
84467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Roboteq:
84567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1, R0
84667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	R0, ret+8(FP)
84767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
84867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
84967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·cmpstring(SB),NOSPLIT,$-4-20
85067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s1_base+0(FP), R2
85167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s1_len+4(FP), R0
85267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s2_base+8(FP), R3
85367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s2_len+12(FP), R1
85467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$20, R13, R7
85567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·cmpbody(SB)
85667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
85767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT bytes·Compare(SB),NOSPLIT,$-4-28
85867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s1+0(FP), R2
85967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s1+4(FP), R0
86067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s2+12(FP), R3
86167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s2+16(FP), R1
86267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	$28, R13, R7
86367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B	runtime·cmpbody(SB)
86467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
86567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// On entry:
86667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R0 is the length of s1
86767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R1 is the length of s2
86867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R2 points to the start of s1
86967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R3 points to the start of s2
87067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R7 points to return value (-1/0/1 will be written here)
87167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot//
87267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// On exit:
87367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R4, R5, and R6 are clobbered
87467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·cmpbody(SB),NOSPLIT,$-4-0
87567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R2, R3
87667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	samebytes
87767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP 	R0, R1
87867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW 	R0, R6
87967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.LT	R1, R6	// R6 is min(R0, R1)
88067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
88167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R2, R6	// R2 is current byte in s1, R6 is last byte in s1 to compare
88267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotloop:
88367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R2, R6
88467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	samebytes // all compared bytes were the same; compare lengths
88567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R2), R4
88667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R3), R5
88767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R4, R5
88867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BEQ	loop
88967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// bytes differed
89067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.LT	$1, R0
89167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.GT	$-1, R0
89267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, (R7)
89367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
89467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotsamebytes:
89567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
89667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.LT	$1, R0
89767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.GT	$-1, R0
89867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW.EQ	$0, R0
89967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, (R7)
90067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
90167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
90267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// TODO: share code with memequal?
90367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT bytes·Equal(SB),NOSPLIT,$0-25
90467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	a_len+4(FP), R1
90567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	b_len+16(FP), R3
90667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
90767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R1, R3		// unequal lengths are not equal
90867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	notequal
90967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
91067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	a+0(FP), R0
91167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	b+12(FP), R2
91267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R0, R1		// end
91367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
91467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotloop:
91567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
91667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	equal		// reached the end
91767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R0), R4
91867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R2), R5
91967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R4, R5
92067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	loop
92167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
92267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotnotequal:
92367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
92467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU	R0, ret+24(FP)
92567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
92667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
92767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotequal:
92867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1, R0
92967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU	R0, ret+24(FP)
93067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
93167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
93267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT bytes·IndexByte(SB),NOSPLIT,$0-20
93367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s+0(FP), R0
93467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s_len+4(FP), R1
93567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU	c+12(FP), R2	// byte to find
93667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R4		// store base for later
93767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R0, R1		// end
93867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
93967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot_loop:
94067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
94167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	_notfound
94267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R0), R3
94367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R2, R3
94467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	_loop
94567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
94667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$1, R0		// R0 will be one beyond the position we want
94767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R4, R0		// remove base
94867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW    R0, ret+16(FP)
94967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
95067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
95167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot_notfound:
95267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$-1, R0
95367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, ret+16(FP)
95467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
95567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
95667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT strings·IndexByte(SB),NOSPLIT,$0-16
95767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s+0(FP), R0
95867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	s_len+4(FP), R1
95967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU	c+8(FP), R2	// byte to find
96067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R4		// store base for later
96167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	ADD	R0, R1		// end
96267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
96367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot_sib_loop:
96467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
96567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.EQ	_sib_notfound
96667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVBU.P	1(R0), R3
96767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R2, R3
96867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	_sib_loop
96967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
97067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$1, R0		// R0 will be one beyond the position we want
97167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R4, R0		// remove base
97267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, ret+12(FP)
97367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
97467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
97567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot_sib_notfound:
97667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$-1, R0
97767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, ret+12(FP)
97867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
97967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
98067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·return0(SB),NOSPLIT,$0
98167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
98267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
98367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
98467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·procyield(SB),NOSPLIT,$-4
98567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	cycles+0(FP), R1
98667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$0, R0
98767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robotyieldloop:
98867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	WORD	$0xe320f001	// YIELD (NOP pre-ARMv6K)
98967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CMP	R0, R1
99067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B.NE	2(PC)
99167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
99267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	$1, R1
99367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	B yieldloop
99467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
99567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Called from cgo wrappers, this function returns g->m->curg.stack.hi.
99667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// Must obey the gcc calling convention.
99767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT _cgo_topofstack(SB),NOSPLIT,$8
99867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// R11 and g register are clobbered by load_g. They are
99967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// callee-save in the gcc calling convention, so save them here.
100067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, saveR11-4(SP)
100167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g, saveG-8(SP)
100267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
100367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·load_g(SB)
100467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	g_m(g), R0
100567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	m_curg(R0), R0
100667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	(g_stack+stack_hi)(R0), R0
100767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
100867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	saveG-8(SP), g
100967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	saveR11-4(SP), R11
101067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
101167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
101267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// The top-most function running on a goroutine
101367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// returns to goexit+PCQuantum.
101467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·goexit(SB),NOSPLIT,$-4-0
101567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R0	// NOP
101667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	BL	runtime·goexit1(SB)	// does not return
101767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// traceback from goexit1 must hit code range of goexit
101867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R0	// NOP
101967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
102067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// x -> x/1000000, x%1000000, called from Go with args, results on stack.
102167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·usplit(SB),NOSPLIT,$0-12
102267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	x+0(FP), R0
102367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	CALL	runtime·usplitR0(SB)
102467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, q+4(FP)
102567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R1, r+8(FP)
102667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
102767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
102867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// R0, R1 = R0/1000000, R0%1000000
102967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·usplitR0(SB),NOSPLIT,$0
103067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// magic multiply to avoid software divide without available m.
103167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	// see output of go tool compile -S for x/1000000.
103267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, R3
103367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1125899907, R1
103467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MULLU	R1, R0, (R0, R1)
103567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0>>18, R0
103667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1000000, R1
103767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MULU	R0, R1
103867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	SUB	R1, R3, R1
103967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
104067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
104167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·sigreturn(SB),NOSPLIT,$0-0
104267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
104367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
104467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#ifndef GOOS_nacl
104567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot// This is called from .init_array and follows the platform, not Go, ABI.
104667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT runtime·addmoduledata(SB),NOSPLIT,$0-8
104767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R9, saver9-4(SP) // The access to global variables below implicitly uses R9, which is callee-save
104867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R11, saver11-8(SP) // Likewise, R11 is the temp register, but callee-save in C ABI
104967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	runtime·lastmoduledatap(SB), R1
105067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, moduledata_next(R1)
105167845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	R0, runtime·lastmoduledatap(SB)
105267845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	saver11-8(SP), R11
105367845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	saver9-4(SP), R9
105467845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
105567845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot#endif
105667845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot
105767845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team RobotTEXT ·checkASM(SB),NOSPLIT,$0-1
105867845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVW	$1, R3
105967845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	MOVB	R3, ret+0(FP)
106067845c40aa5be5001fb20ef6f6b8d52e3fe6bb1android-build-team Robot	RET
1061