Search
lxdream.org :: lxdream/src/test/testxir.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxir.c
changeset 1013:76196dbc804a
prev1011:fdd58619b760
author nkeynes
date Sun Apr 19 06:11:19 2009 +0000 (13 years ago)
branchxlat-refactor
permissions -rw-r--r--
last change Update test for changes
view annotate diff log raw
     1 /**
     2  * $Id: testsh4x86.c 988 2009-01-15 11:23:20Z nkeynes $
     3  *
     4  * Test XIR internals
     5  *
     6  * Copyright (c) 2009 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #include <assert.h>
    20 #include <stdlib.h>
    21 #include "xlat/xir.h"
    23 void test_shuffle()
    24 {
    25     int tmp1, tmp2;
    26     struct xir_op op[64];
    27     struct xir_basic_block bb;
    28     xir_basic_block_t xbb = &bb;
    29     bb.ir_alloc_begin = bb.ir_begin = bb.ir_end = bb.ir_ptr = &op[0];
    30     bb.ir_alloc_end = &op[64];
    31     xir_clear_basic_block( xbb );
    32     tmp1 = xir_alloc_temp_reg( xbb, XTY_LONG, -1 );
    33     tmp2 = xir_alloc_temp_reg( xbb, XTY_LONG, -1 );
    35     XOP2IT( OP_SHUFFLE, 0x1243, REG_TMP1 );
    36     XOP2IT( OP_SHUFFLE, 0x3412, REG_TMP1 );
    37     XOP2IT( OP_SHUFFLE, 0x1243, REG_TMP1 );
    38     XOP2IT( OP_SHUFFLE, 0x3412, REG_TMP1 );
    39     XOP2IT( OP_SHUFFLE, 0x1234, REG_TMP1 );
    40     XOP2IT( OP_SHUFFLE, 0x1111, REG_TMP2 );
    41     XOP2IT( OP_SHUFFLE, 0x0123, REG_TMP1 );
    42     XOP0( OP_EXIT );
    43     (bb.ir_ptr-1)->next = NULL;
    44     bb.ir_end = bb.ir_ptr-1;
    46     assert( xir_shuffle_imm32( 0x2134, 0x12345678) == 0x34125678 );
    47     assert( xir_shuffle_imm32( 0x1243, 0x12345678) == 0x12347856 );
    48     assert( xir_shuffle_imm32( 0x3412, 0x12345678) == 0x56781234 );
    50     xir_shuffle_op( op[0].operand[0].value.i, &op[1] );
    51     assert( op[1].operand[0].value.i == 0x4312 ); 
    52     xir_shuffle_op( op[1].operand[0].value.i, &op[2] );
    53     assert( op[2].operand[0].value.i == 0x4321 );
    55     assert( xir_shuffle_lower_size( &op[0] ) == 9);
    56     assert( xir_shuffle_lower_size( &op[1] ) == 8);
    57     assert( xir_shuffle_lower_size( &op[3] ) == 4);
    58     assert( xir_shuffle_lower_size( &op[4] ) == 0);
    59     assert( xir_shuffle_lower_size( &op[5] ) == 12);
    60     assert( xir_shuffle_lower_size( &op[6] ) == 1);
    61     xir_shuffle_lower( xbb, &op[0], tmp1, tmp2 ); 
    62     xir_shuffle_lower( xbb, &op[1], tmp1, tmp2 );
    63     xir_shuffle_lower( xbb, &op[3], tmp1, tmp2 );
    64     xir_shuffle_lower( xbb, &op[4], tmp1, tmp2 );
    65     xir_shuffle_lower( xbb, &op[5], tmp1, tmp2 );
    66     xir_shuffle_lower( xbb, &op[6], tmp1, tmp2 );
    67     xir_dump_block( xbb );
    68     xir_verify_block( xbb, xbb->ir_begin, xbb->ir_end );
    69 }
    74 int main( int argc, char *argv[] )
    75 {
    76     test_shuffle();
    78     return 0;
    79 }
.