#include "sv_reg.h"
#include "sv_mmu.h"
+#define xstr(x) str(x)
+#define str(x) #x
+
void (sv_proc_t::WRITE_FRD)(sv_float32_t value)
{
reg_t reg = _insn->rd().reg;
return sresult;
}
-bool sv_proc_t::rv_lt(sv_reg_t const & lhs, sv_reg_t const & rhs)
-{
- uint8_t bitwidth = _insn->src_bitwidth;
- uint64_t vlhs = 0;
- uint64_t vrhs = 0;
- if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) {
- bool result = lhs < rhs;
- fprintf(stderr, "lt result %lx %lx %x\n",
- (uint64_t)lhs, (uint64_t)rhs, result);
- return result;
- }
- bool result = vlhs < vrhs;
- fprintf(stderr, "lt result %lx %lx %d bw %d\n",
- (uint64_t)lhs, (uint64_t)rhs, result, bitwidth);
- return result;
-}
+#define lt <
+#define gt >
-bool sv_proc_t::rv_lt(sv_sreg_t const & lhs, sv_sreg_t const & rhs)
-{
- uint8_t bitwidth = _insn->src_bitwidth;
- int64_t vlhs = 0;
- int64_t vrhs = 0;
- if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) {
- bool result = lhs < rhs;
- fprintf(stderr, "lt result %lx %lx %x\n",
- (int64_t)lhs, (int64_t)rhs, result);
- return result;
- }
- bool result = vlhs < vrhs;
- fprintf(stderr, "lt result %lx %lx %d bw %d\n",
- (int64_t)lhs, (int64_t)rhs, result, bitwidth);
- return result;
-}
+#define OP_RES_FN( fname, SLHSTYPE, SRHSTYPE, SRESTYPE, \
+ LHSTYPE, RHSTYPE, RESTYPE ) \
+bool sv_proc_t::rv_##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs) \
+{ \
+ uint8_t bitwidth = _insn->src_bitwidth; \
+ LHSTYPE vlhs = 0; \
+ RHSTYPE vrhs = 0; \
+ if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) { \
+ RESTYLE result = lhs op rhs; \
+ fprintf(stderr, "%s result %lx %lx %lx\n", \
+ xstr(op), (LHSTYPE)lhs, (RHSTYPE)rhs, (uint64_t)result); \
+ return result; \
+ } \
+ RESTYPE result = vlhs < vrhs; \
+ fprintf(stderr, "lt result %lx %lx %d bw %d\n", \
+ (LHSTYPE)lhs, (RHSTYPE)rhs, result, bitwidth); \
+ return result; \
+}
+
+#define OP_BOOL_FN( fname, SLHSTYPE, SRHSTYPE, \
+ LHSTYPE, RHSTYPE ) \
+bool sv_proc_t::rv_##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs) \
+{ \
+ uint8_t bitwidth = _insn->src_bitwidth; \
+ LHSTYPE vlhs = 0; \
+ RHSTYPE vrhs = 0; \
+ if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) { \
+ bool result = lhs fname rhs; \
+ fprintf(stderr, "%s result %lx %lx %x\n", \
+ xstr(fname), (LHSTYPE)lhs, (RHSTYPE)rhs, result); \
+ return result; \
+ } \
+ bool result = vlhs < vrhs; \
+ fprintf(stderr, "lt result %lx %lx %d bw %d\n", \
+ (LHSTYPE)lhs, (RHSTYPE)rhs, result, bitwidth); \
+ return result; \
+}
+
+OP_BOOL_FN( lt, sv_reg_t, sv_reg_t, uint64_t, uint64_t )
+OP_BOOL_FN( lt, sv_sreg_t, sv_sreg_t, int64_t, int64_t )
bool sv_proc_t::rv_gt(sv_reg_t const & lhs, sv_reg_t const & rhs)
{