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