-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync with [sparcians/atlas-dev@a778609](https://github.com/sparcians/atlas-dev/tree/a7786093b16abd7b831cf88d4a29d6debde4720d)
- Loading branch information
1 parent
b62fe90
commit 25e173f
Showing
193 changed files
with
3,210 additions
and
4,761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ arch/rv64/** | |
spike | ||
.vscode/** | ||
mavis_json | ||
riscv-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os, sys, re, subprocess | ||
|
||
if len(sys.argv) > 1: | ||
os.chdir(os.path.abspath(sys.argv[1])) | ||
|
||
result = subprocess.run(['git', 'status', '--porcelain', '|', 'grep "M "'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
if result.returncode == 0 and result.stdout: | ||
raise RuntimeError('Cannot have uncommitted changes in this directory: {}'.format(os.getcwd())) | ||
|
||
ext = os.path.basename(os.getcwd()) | ||
rv_insts_cpp = 'Rv{}Insts.cpp'.format(ext) | ||
pattern = r"ActionGroup\* Rv{}Insts::".format(ext) | ||
|
||
headers = set() | ||
headers.add('#include "core/ActionGroup.hpp"\n') | ||
headers.add('#include "include/ActionTags.hpp"\n') | ||
for filename in os.listdir(os.getcwd()): | ||
if filename.endswith(".cpp") and filename != rv_insts_cpp: | ||
with open(filename, 'r') as fin: | ||
for line in fin.readlines(): | ||
if line.find('#include') == 0: | ||
headers.add(line) | ||
|
||
lines = list(headers) | ||
lines = sorted(lines, key=len, reverse=True) | ||
lines.append('') | ||
|
||
with open(rv_insts_cpp, 'r') as fin: | ||
transfer = False | ||
for line in fin.readlines(): | ||
if line.find('namespace atlas') == 0: | ||
transfer = True | ||
elif line.find('// namespace atlas') != -1: | ||
break | ||
|
||
if transfer: | ||
lines.append(line) | ||
|
||
lines = [''.join(lines)] | ||
lines.append('') | ||
|
||
for filename in os.listdir(os.getcwd()): | ||
if filename.endswith(".cpp") and filename != rv_insts_cpp: | ||
lines.append('') | ||
with open(filename, 'r') as fin: | ||
transfer = False | ||
for line in fin.readlines(): | ||
if re.search(pattern, line): | ||
transfer = True | ||
elif line.find('// namespace atlas') != -1: | ||
break | ||
|
||
if transfer: | ||
lines.append(line.rstrip('\n')) | ||
|
||
lines.append('') | ||
lines.append('} // namespace atlas') | ||
|
||
with open(rv_insts_cpp, 'w') as fout: | ||
fout.write('\n'.join(lines)) | ||
|
||
for filename in os.listdir(os.getcwd()): | ||
if filename.endswith('.cpp') and filename != rv_insts_cpp: | ||
os.remove(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,3 @@ target_link_libraries(atlasinsts | |
rvzicsr | ||
rvzifencei | ||
) | ||
add_dependencies(atlasinsts AutogenArchFiles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
typedef int64_t sreg_t; | ||
typedef uint64_t reg_t; | ||
#define xlen 64 | ||
|
||
template <typename T> inline sreg_t sext32(T x) { return (sreg_t)(int32_t)(x); } | ||
|
||
template <typename T> inline reg_t zext32(T x) { return (reg_t)(uint32_t)(x); } | ||
|
||
template <typename T> inline sreg_t sext(T x, uint32_t pos) | ||
{ | ||
return (((sreg_t)(x) << (64 - (pos))) >> (64 - (pos))); | ||
} | ||
|
||
template <typename T> inline reg_t zext(T x, uint32_t pos) | ||
{ | ||
return (((reg_t)(x) << (64 - (pos))) >> (64 - (pos))); | ||
} | ||
|
||
template <typename T> inline sreg_t sext_xlen(T x) { return sext(x, xlen); } | ||
|
||
template <typename T> inline reg_t zext_xlen(T x) { return zext(x, xlen); } | ||
|
||
inline uint64_t mulhu(uint64_t a, uint64_t b) | ||
{ | ||
uint64_t t; | ||
uint32_t y1, y2, y3; | ||
uint64_t a0 = (uint32_t)a, a1 = a >> 32; | ||
uint64_t b0 = (uint32_t)b, b1 = b >> 32; | ||
|
||
t = a1 * b0 + ((a0 * b0) >> 32); | ||
y1 = t; | ||
y2 = t >> 32; | ||
|
||
t = a0 * b1 + y1; | ||
|
||
t = a1 * b1 + y2 + (t >> 32); | ||
y2 = t; | ||
y3 = t >> 32; | ||
|
||
return ((uint64_t)y3 << 32) | y2; | ||
} | ||
|
||
inline int64_t mulhsu(int64_t a, uint64_t b) | ||
{ | ||
int negate = a < 0; | ||
uint64_t res = mulhu(a < 0 ? -a : a, b); | ||
return negate ? ~res + (a * b == 0) : res; | ||
} | ||
|
||
inline int64_t mulh(int64_t a, int64_t b) | ||
{ | ||
int negate = (a < 0) != (b < 0); | ||
uint64_t res = mulhu(a < 0 ? -a : a, b < 0 ? -b : b); | ||
return negate ? ~res + ((uint64_t)a * (uint64_t)b == 0) : res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
project(Atlas) | ||
|
||
file(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.cpp") | ||
add_library(rva | ||
OBJECT | ||
RvaInsts.cpp | ||
amoadd_d.cpp | ||
amoadd_w.cpp | ||
amoand_d.cpp | ||
amoand_w.cpp | ||
amomax_d.cpp | ||
amomax_w.cpp | ||
amomaxu_d.cpp | ||
amomaxu_w.cpp | ||
amomin_d.cpp | ||
amomin_w.cpp | ||
amominu_d.cpp | ||
amominu_w.cpp | ||
amoor_d.cpp | ||
amoor_w.cpp | ||
amoswap_d.cpp | ||
amoswap_w.cpp | ||
amoxor_d.cpp | ||
amoxor_w.cpp | ||
lr_d.cpp | ||
lr_w.cpp | ||
sc_d.cpp | ||
sc_w.cpp | ||
${SOURCES} | ||
) |
Oops, something went wrong.