Home | History | Annotate | Download | only in math
      1 /*
      2  * Copyright 2015, Cyril Bur, IBM Corp.
      3  *
      4  * This program is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU General Public License
      6  * as published by the Free Software Foundation; either version
      7  * 2 of the License, or (at your option) any later version.
      8  */
      9 
     10 #include "basic_asm.h"
     11 #include "vsx_asm.h"
     12 
     13 #long check_vsx(vector int *r3);
     14 #This function wraps storeing VSX regs to the end of an array and a
     15 #call to a comparison function in C which boils down to a memcmp()
     16 FUNC_START(check_vsx)
     17 	PUSH_BASIC_STACK(32)
     18 	std	r3,STACK_FRAME_PARAM(0)(sp)
     19 	addi r3, r3, 16 * 12 #Second half of array
     20 	bl store_vsx
     21 	ld r3,STACK_FRAME_PARAM(0)(sp)
     22 	bl vsx_memcmp
     23 	POP_BASIC_STACK(32)
     24 	blr
     25 FUNC_END(check_vsx)
     26 
     27 # int preempt_vmx(vector int *varray, int *threads_starting,
     28 #                 int *running);
     29 # On starting will (atomically) decrement threads_starting as a signal
     30 # that the VMX have been loaded with varray. Will proceed to check the
     31 # validity of the VMX registers while running is not zero.
     32 FUNC_START(preempt_vsx)
     33 	PUSH_BASIC_STACK(512)
     34 	std r3,STACK_FRAME_PARAM(0)(sp) # vector int *varray
     35 	std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
     36 	std r5,STACK_FRAME_PARAM(2)(sp) # int *running
     37 
     38 	bl load_vsx
     39 	nop
     40 
     41 	sync
     42 	# Atomic DEC
     43 	ld r3,STACK_FRAME_PARAM(1)(sp)
     44 1:	lwarx r4,0,r3
     45 	addi r4,r4,-1
     46 	stwcx. r4,0,r3
     47 	bne- 1b
     48 
     49 2:	ld r3,STACK_FRAME_PARAM(0)(sp)
     50 	bl check_vsx
     51 	nop
     52 	cmpdi r3,0
     53 	bne 3f
     54 	ld r4,STACK_FRAME_PARAM(2)(sp)
     55 	ld r5,0(r4)
     56 	cmpwi r5,0
     57 	bne 2b
     58 
     59 3:	POP_BASIC_STACK(512)
     60 	blr
     61 FUNC_END(preempt_vsx)
     62