1# See LICENSE for license details. 2 3#***************************************************************************** 4# lb.S 5#----------------------------------------------------------------------------- 6# 7# Test lb instruction. 8# 9 10#include "riscv_test.h" 11#include "test_macros.h" 12 13RVTEST_RV64U 14RVTEST_CODE_BEGIN 15 16 #------------------------------------------------------------- 17 # Basic tests 18 #------------------------------------------------------------- 19 20 TEST_LD_OP( 2, lb, 0xffffffffffffffff, 0, tdat ); 21 TEST_LD_OP( 3, lb, 0x0000000000000000, 1, tdat ); 22 TEST_LD_OP( 4, lb, 0xfffffffffffffff0, 2, tdat ); 23 TEST_LD_OP( 5, lb, 0x000000000000000f, 3, tdat ); 24 25 # Test with negative offset 26 27 TEST_LD_OP( 6, lb, 0xffffffffffffffff, -3, tdat4 ); 28 TEST_LD_OP( 7, lb, 0x0000000000000000, -2, tdat4 ); 29 TEST_LD_OP( 8, lb, 0xfffffffffffffff0, -1, tdat4 ); 30 TEST_LD_OP( 9, lb, 0x000000000000000f, 0, tdat4 ); 31 32 # Test with a negative base 33 34 TEST_CASE( 10, x5, 0xffffffffffffffff, \ 35 la x1, tdat; \ 36 addi x1, x1, -32; \ 37 lb x5, 32(x1); \ 38 ) 39 40 # Test with unaligned base 41 42 TEST_CASE( 11, x5, 0x0000000000000000, \ 43 la x1, tdat; \ 44 addi x1, x1, -6; \ 45 lb x5, 7(x1); \ 46 ) 47 48 #------------------------------------------------------------- 49 # Bypassing tests 50 #------------------------------------------------------------- 51 52 TEST_LD_DEST_BYPASS( 12, 0, lb, 0xfffffffffffffff0, 1, tdat2 ); 53 TEST_LD_DEST_BYPASS( 13, 1, lb, 0x000000000000000f, 1, tdat3 ); 54 TEST_LD_DEST_BYPASS( 14, 2, lb, 0x0000000000000000, 1, tdat1 ); 55 56 TEST_LD_SRC1_BYPASS( 15, 0, lb, 0xfffffffffffffff0, 1, tdat2 ); 57 TEST_LD_SRC1_BYPASS( 16, 1, lb, 0x000000000000000f, 1, tdat3 ); 58 TEST_LD_SRC1_BYPASS( 17, 2, lb, 0x0000000000000000, 1, tdat1 ); 59 60 #------------------------------------------------------------- 61 # Test write-after-write hazard 62 #------------------------------------------------------------- 63 64 TEST_CASE( 18, x2, 2, \ 65 la x5, tdat; \ 66 lb x2, 0(x5); \ 67 li x2, 2; \ 68 ) 69 70 TEST_CASE( 19, x2, 2, \ 71 la x5, tdat; \ 72 lb x2, 0(x5); \ 73 nop; \ 74 li x2, 2; \ 75 ) 76 77 TEST_PASSFAIL 78 79RVTEST_CODE_END 80 81 .data 82RVTEST_DATA_BEGIN 83 84 TEST_DATA 85 86tdat: 87tdat1: .byte 0xff 88tdat2: .byte 0x00 89tdat3: .byte 0xf0 90tdat4: .byte 0x0f 91 92RVTEST_DATA_END 93