1/*
2 * Copyright (c) 2016 The University of Virginia
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Alec Roelke
29 */
30
31#pragma once
32
33#include <cstdint>
34
35#include "insttest.h"
36
37namespace M
38{
39
40inline int64_t
41mul(int64_t rs1, int64_t rs2)
42{
43    int64_t rd = 0;
44    ROP("mul", rd, rs1, rs2);
45    return rd;
46}
47
48inline int64_t
49mulh(int64_t rs1, int64_t rs2)
50{
51    int64_t rd = 0;
52    ROP("mulh", rd, rs1, rs2);
53    return rd;
54}
55
56inline int64_t
57mulhsu(int64_t rs1, uint64_t rs2)
58{
59    int64_t rd = 0;
60    ROP("mulhsu", rd, rs1, rs2);
61    return rd;
62}
63
64inline uint64_t
65mulhu(uint64_t rs1, uint64_t rs2)
66{
67    uint64_t rd = 0;
68    ROP("mulhu", rd, rs1, rs2);
69    return rd;
70}
71
72inline int64_t
73div(int64_t rs1, int64_t rs2)
74{
75    int64_t rd = 0;
76    ROP("div", rd, rs1, rs2);
77    return rd;
78}
79
80inline uint64_t
81divu(uint64_t rs1, uint64_t rs2)
82{
83    uint64_t rd = 0;
84    ROP("divu", rd, rs1, rs2);
85    return rd;
86}
87
88inline int64_t
89rem(int64_t rs1, int64_t rs2)
90{
91    int64_t rd = 0;
92    ROP("rem", rd, rs1, rs2);
93    return rd;
94}
95
96inline uint64_t
97remu(uint64_t rs1, uint64_t rs2)
98{
99    uint64_t rd = 0;
100    ROP("remu", rd, rs1, rs2);
101    return rd;
102}
103
104inline int64_t
105mulw(int64_t rs1, int64_t rs2)
106{
107    int64_t rd = 0;
108    ROP("mulw", rd, rs1, rs2);
109    return rd;
110}
111
112inline int64_t
113divw(int64_t rs1, int64_t rs2)
114{
115    int64_t rd = 0;
116    ROP("divw", rd, rs1, rs2);
117    return rd;
118}
119
120inline uint64_t
121divuw(uint64_t rs1, uint64_t rs2)
122{
123    uint64_t rd = 0;
124    ROP("divuw", rd, rs1, rs2);
125    return rd;
126}
127
128inline int64_t
129remw(int64_t rs1, int64_t rs2)
130{
131    int64_t rd = 0;
132    ROP("remw", rd, rs1, rs2);
133    return rd;
134}
135
136inline uint64_t
137remuw(uint64_t rs1, uint64_t rs2)
138{
139    uint64_t rd = 0;
140    ROP("remuw", rd, rs1, rs2);
141    return rd;
142}
143
144} // namespace M
145