<commit_before>#include <nv40.h>
#include <rsx.h>
#include <gcm_sys.h>
#include <ppu_intrinsics.h>

#include "commands.h"
#include "rsx_internal.h"

#ifndef RSX_MEMCPY
#define RSX_MEMCPY	__builtin_memcpy
#endif

static __inline__ f32 swapF32_16(f32 v)
{
	ieee32 d;
	d.f = v;
	d.u = ( ( ( d.u >> 16 ) & 0xffff ) << 0 ) | ( ( ( d.u >> 0 ) & 0xffff ) << 16 );
	return d.f;
}

s32 __attribute__((noinline)) rsxContextCallback(gcmContextData *context,u32 count)
{
	register s32 result asm("3");
	asm volatile (
		"stdu	1,-128(1)\n"
		"mr		31,2\n"
		"lwz	0,0(%0)\n"
		"lwz	2,4(%0)\n"
		"mtctr	0\n"
		"bctrl\n"
		"mr		2,31\n"
		"addi	1,1,128\n"
		: : "b"(context->callback)
		: "r31", "r0", "lr"
	);
	return result;
}

void rsxSetReturnCommand(gcmContextData *context)
{
	RSX_CONTEXT_CURRENT_BEGIN(1);
	RSX_CONTEXT_CURRENTP[0] = RSX_METHOD_FLAG_RETURN;
	RSX_CONTEXT_CURRENT_END(1);
}

void rsxSetCallCommand(gcmContextData *context,u32 offset)
{
	RSX_CONTEXT_CURRENT_BEGIN(1);
	RSX_CONTEXT_CURRENTP[0] = (offset | RSX_METHOD_FLAG_CALL);
	RSX_CONTEXT_CURRENT_END(1);<commit_msg>- cleaner reg naming - add result register to the output operand(s)<commit_after>#include <nv40.h>
#include <rsx.h>
#include <gcm_sys.h>
#include <ppu_intrinsics.h>

#include "commands.h"
#include "rsx_internal.h"

#ifndef RSX_MEMCPY
#define RSX_MEMCPY	__builtin_memcpy
#endif

static __inline__ f32 swapF32_16(f32 v)
{
	ieee32 d;
	d.f = v;
	d.u = ( ( ( d.u >> 16 ) & 0xffff ) << 0 ) | ( ( ( d.u >> 0 ) & 0xffff ) << 16 );
	return d.f;
}

s32 __attribute__((noinline)) rsxContextCallback(gcmContextData *context,u32 count)
{
	register s32 result asm("r3");
	asm volatile (
		"stdu	1,-128(1)\n"
		"mr		31,2\n"
		"lwz	0,0(%0)\n"
		"lwz	2,4(%0)\n"
		"mtctr	0\n"
		"bctrl\n"
		"mr		2,31\n"
		"addi	1,1,128\n"
		: "=r"(result)
		: "b"(context->callback)
		: "r31", "r0", "lr"
	);
	return result;
}

void rsxSetReturnCommand(gcmContextData *context)
{
	RSX_CONTEXT_CURRENT_BEGIN(1);
	RSX_CONTEXT_CURRENTP[0] = RSX_METHOD_FLAG_RETURN;
	RSX_CONTEXT_CURRENT_END(1);
}

void rsxSetCallCommand(gcmContextData *context,u32 offset)
{
	RSX_CONTEXT_CURRENT_BEGIN(1);
	RSX_CONTEXT_CURRENTP[0] = (offset | RSX_METHOD_FLAG_CALL);
	RSX_CONTEXT_CURRENT_END(1);
{'fraction_non_alphanumeric': 0.16425339366515837, 'fraction_numerical': 0.05520361990950226, 'mean_word_length': 4.742857142857143, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '197242', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1038, 'n_words': 182}