// RISC-V Compliance Test Header File
// Copyright (c) 2017, Codasip Ltd. All Rights Reserved.
// See LICENSE for license details.
//
// Description: Common header file for RV32I tests

#ifndef _COMPLIANCE_TEST_H
#define _COMPLIANCE_TEST_H

//-----------------------------------------------------------------------
// RV Compliance Macros
//-----------------------------------------------------------------------

#define RV_COMPLIANCE_HALT                                                   \
        .global check;                                                       \
        la a1, __BSS_START__;                                                \
        la a2, __BSS_END__;                                                  \
        j  4f;                                                               \
        3: sw zero, 0(a1);                                                   \
        add a1, a1, 4;                                                       \
        4: bne     a1, a2, 3b;                                               \
        la sp, __C_STACK_TOP__;                                              \
        la t5, check;                                                        \
        jalr x1, t5, 0;                                                      \
        beqz a0, 1f;                                                         \
        RVTEST_FAIL;                                                         \
        1: RVTEST_PASS                                                       \

#define RV_COMPLIANCE_RV32M                                                  \
        RVTEST_RV32M                                                         \

#define RV_COMPLIANCE_CODE_BEGIN                                             \
        RVTEST_CODE_BEGIN                                                    \

#define RV_COMPLIANCE_CODE_END                                               \
        RVTEST_CODE_END                                                      \

#define RV_COMPLIANCE_DATA_BEGIN                                             \
        RVTEST_DATA_BEGIN                                                    \

#define RV_COMPLIANCE_DATA_END                                               \
        RVTEST_DATA_END                                                      \

#endif