linux/tools/testing/selftests/powerpc/pmu/loop.S
Michael Ellerman 7481cad474 selftests/powerpc: Add a test of counting larx/stcx
This is based on the count_instructions test.

However this one also counts the number of failed stcx's, and in
conjunction with knowing the size of the stcx loop, can calculate the
total number of instructions executed even in the face of
non-deterministic stcx failures.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200426114410.3917383-1-mpe@ellerman.id.au
2020-05-15 11:58:55 +10:00

79 lines
1.3 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright 2013, Michael Ellerman, IBM Corp.
*/
#include <ppc-asm.h>
.text
FUNC_START(thirty_two_instruction_loop)
cmpdi r3,0
beqlr
addi r4,r3,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1
addi r4,r4,1 # 28 addi's
subi r3,r3,1
b FUNC_NAME(thirty_two_instruction_loop)
FUNC_END(thirty_two_instruction_loop)
FUNC_START(thirty_two_instruction_loop_with_ll_sc)
cmpdi r3,0
beqlr
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1 # 5
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
1: ldarx r6,0,r4 # 10
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1 # 15
addi r5,r5,1
addi r5,r5,1
stdcx. r6,0,r4
bne- 1b
addi r5,r5,1 # 20
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1 # 25
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1
addi r5,r5,1 # 30
subi r3,r3,1
b FUNC_NAME(thirty_two_instruction_loop_with_ll_sc)
FUNC_END(thirty_two_instruction_loop_with_ll_sc)