Search
lxdream.org :: lxdream/src/test/testxir.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxir.c
changeset 1006:3a169c224c12
next1011:fdd58619b760
author nkeynes
date Tue Apr 07 10:55:03 2009 +0000 (11 years ago)
branchxlat-refactor
permissions -rw-r--r--
last change Commit current work-in-progress to xlat-refactor branch
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/test/testxir.c Tue Apr 07 10:55:03 2009 +0000
1.3 @@ -0,0 +1,74 @@
1.4 +/**
1.5 + * $Id: testsh4x86.c 988 2009-01-15 11:23:20Z nkeynes $
1.6 + *
1.7 + * Test XIR internals
1.8 + *
1.9 + * Copyright (c) 2009 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include <assert.h>
1.23 +#include <stdlib.h>
1.24 +#include "xlat/xir.h"
1.25 +
1.26 +void test_shuffle()
1.27 +{
1.28 + struct xir_op op[64];
1.29 + struct xir_basic_block bb;
1.30 + xir_basic_block_t xbb = &bb;
1.31 + bb.ir_alloc_begin = bb.ir_begin = bb.ir_end = bb.ir_ptr = &op[0];
1.32 + bb.ir_alloc_end = &op[64];
1.33 +
1.34 + XOP2I( OP_SHUFFLE, 0x1243, REG_TMP1 );
1.35 + XOP2I( OP_SHUFFLE, 0x3412, REG_TMP1 );
1.36 + XOP2I( OP_SHUFFLE, 0x1243, REG_TMP1 );
1.37 + XOP2I( OP_SHUFFLE, 0x3412, REG_TMP1 );
1.38 + XOP2I( OP_SHUFFLE, 0x1234, REG_TMP1 );
1.39 + XOP2I( OP_SHUFFLE, 0x1111, REG_TMP2 );
1.40 + XOP2I( OP_SHUFFLE, 0x0123, REG_TMP1 );
1.41 + XOP1I( OP_BR, 0x8C001000 );
1.42 + (bb.ir_ptr-1)->next = NULL;
1.43 + bb.ir_end = bb.ir_ptr-1;
1.44 +
1.45 + assert( xir_shuffle_imm32( 0x2134, 0x12345678) == 0x34125678 );
1.46 + assert( xir_shuffle_imm32( 0x1243, 0x12345678) == 0x12347856 );
1.47 + assert( xir_shuffle_imm32( 0x3412, 0x12345678) == 0x56781234 );
1.48 +
1.49 + xir_shuffle_op( op[0].operand[0].value.i, &op[1] );
1.50 + assert( op[1].operand[0].value.i == 0x4312 );
1.51 + xir_shuffle_op( op[1].operand[0].value.i, &op[2] );
1.52 + assert( op[2].operand[0].value.i == 0x4321 );
1.53 +
1.54 + assert( xir_shuffle_lower_size( &op[0] ) == 9);
1.55 + assert( xir_shuffle_lower_size( &op[1] ) == 8);
1.56 + assert( xir_shuffle_lower_size( &op[3] ) == 4);
1.57 + assert( xir_shuffle_lower_size( &op[4] ) == 0);
1.58 + assert( xir_shuffle_lower_size( &op[5] ) == 12);
1.59 + assert( xir_shuffle_lower_size( &op[6] ) == 1);
1.60 + xir_shuffle_lower( xbb, &op[0], REG_TMP3, REG_TMP4 );
1.61 + xir_shuffle_lower( xbb, &op[1], REG_TMP3, REG_TMP4 );
1.62 + xir_shuffle_lower( xbb, &op[3], REG_TMP3, REG_TMP4 );
1.63 + xir_shuffle_lower( xbb, &op[4], REG_TMP3, REG_TMP4 );
1.64 + xir_shuffle_lower( xbb, &op[5], REG_TMP3, REG_TMP4 );
1.65 + xir_shuffle_lower( xbb, &op[6], REG_TMP3, REG_TMP4 );
1.66 + xir_dump_block( &op[0], NULL );
1.67 +}
1.68 +
1.69 +
1.70 +
1.71 +
1.72 +int main( int argc, char *argv[] )
1.73 +{
1.74 + test_shuffle();
1.75 +
1.76 + return 0;
1.77 +}
1.78 \ No newline at end of file
.