-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hack] Skip functions that trigger compiler bugs.
- Loading branch information
Showing
7 changed files
with
208 additions
and
3 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
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
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
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,114 @@ | ||
import os | ||
import re | ||
import csv | ||
|
||
|
||
def gen_test(v_type_list, v_ele_list, v_name_list, func_name): | ||
print(v_type_list) | ||
print(v_ele_list) | ||
print(v_name_list) | ||
test_content = ''' | ||
#else | ||
fputc('\\n', stdout); | ||
for (int i = 0 ; i < 8 ; i++) {\n''' | ||
for i in range(len(v_type_list)-1): | ||
test_content = test_content+' simde_'+v_type_list[i]+v_ele_list[i]+'_t '+v_name_list[i]+' = simde_test_arm_neon_random_'+v_type_list[i][0]+v_ele_list[i]+'();\n' | ||
test_content = test_content+' simde_'+v_type_list[-1]+v_ele_list[-1]+'_t '+v_name_list[-1]+' = '+func_name+'(' | ||
for i in range(len(v_name_list)-1): | ||
if i != len(v_name_list)-2: | ||
test_content = test_content+v_name_list[i]+', ' | ||
else: | ||
test_content = test_content+v_name_list[i]+');\n\n' | ||
|
||
for i in range(len(v_name_list)): | ||
if i == 0: | ||
test_content = test_content + ' simde_test_arm_neon_write_'+v_type_list[i][0]+v_ele_list[i]+'(2, '+v_name_list[i]+', SIMDE_TEST_VEC_POS_FIRST);\n' | ||
elif i == len(v_name_list)-1: | ||
test_content = test_content + ' simde_test_arm_neon_write_'+v_type_list[i][0]+v_ele_list[i]+'(2, '+v_name_list[i]+', SIMDE_TEST_VEC_POS_LAST);\n' | ||
else: | ||
test_content = test_content + ' simde_test_arm_neon_write_'+v_type_list[i][0]+v_ele_list[i]+'(2, '+v_name_list[i]+', SIMDE_TEST_VEC_POS_MIDDLE);\n' | ||
test_content = test_content + ' }\n return 1;\n#endif\n' | ||
|
||
return test_content | ||
|
||
|
||
type_list = [["float16"], | ||
["float32", "float"], | ||
["float64", "double"], | ||
["uint8"], | ||
["uint16"], | ||
["uint32", "unsigned int", "unsigned"], | ||
["uint64"], | ||
["int8"], | ||
["int16"], | ||
["int32", "int"], | ||
["int64"]] | ||
|
||
dic_type_list = {"float16":["float", "16"], | ||
"float32":["float", "32"],} | ||
|
||
def main_gen(file_path): | ||
# Open the file for reading | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
for i in range(len(lines)): | ||
if "static int" in lines[i]: | ||
if "#if 1" not in lines[i+2]: | ||
func_name = lines[i+1][5:lines[i+1].find(' ')] | ||
lines.insert(i+2, '#if 1\n') | ||
print(f"line numbers: {i}, {func_name}") | ||
# get input para | ||
v_type_list = [] # ex. float16 or uint32 | ||
v_ele_list = [] # ex. 32x2 | ||
v_name_list = [] # ex. a | ||
for j in range(i, i+1000, 1): | ||
if "struct" in lines[j]: | ||
while 'test_vec' not in lines[j]: | ||
j += 1 | ||
# get type | ||
found = False | ||
variable_len = ['1'] | ||
for rows in range(len(type_list)): | ||
if not found: | ||
for cols in range(len(type_list[rows])): | ||
if type_list[rows][cols] in lines[j]: | ||
v_type = '' | ||
for c in type_list[rows][0]: | ||
if c.isdigit(): | ||
break | ||
v_type += c | ||
v_type_list.append(v_type) | ||
found = True | ||
variable_len = re.findall(r'\d+', type_list[rows][0]) | ||
break | ||
else: | ||
break | ||
# get elements | ||
if '[' in lines[j] and '}' not in lines[j]: | ||
v_ele_list.append(variable_len[0]+'x'+lines[j][lines[j].find('[')+1:lines[j].find(']')]) | ||
v_name_list.append(lines[j][lines[j].rfind(' ')+1:lines[j].rfind('[')]) | ||
elif '}' not in lines[j]: | ||
v_ele_list.append(variable_len[0]+'x1') | ||
v_name_list.append(lines[j][lines[j].rfind(' ')+1:lines[j].rfind(';')]) | ||
if "return" in lines[j]: | ||
# Add gen_test function | ||
add_content = gen_test(v_type_list, v_ele_list, v_name_list, func_name) | ||
lines.insert(j+1, add_content) | ||
break | ||
# Write the modified content back to the file | ||
with open(file_path, 'w') as file: | ||
file.writelines(lines) | ||
|
||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
# Open the modify_c.txt file and read its contents | ||
with open('modify_c.txt', 'r') as modify_c_file: | ||
file_names = modify_c_file.read().splitlines() | ||
|
||
for file_name in file_names: | ||
print(f'Start {file_name}') | ||
main_gen(file_name) | ||
print(f'Done {file_name}') | ||
|
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
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
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,83 @@ | ||
abd.c | ||
abdl_high.c | ||
abs.c | ||
addhn_high.c | ||
cgez.c | ||
cgtz.c | ||
cle.c | ||
cltz.c | ||
copy_lane.c | ||
cvt.c | ||
cvt_n.c | ||
cvtm.c | ||
cvtp.c | ||
div.c | ||
dup_lane.c | ||
eor.c | ||
fmlal.c | ||
fmlsl.c | ||
ld3.c | ||
ld4.c | ||
max.c | ||
maxnm.c | ||
maxnmv.c | ||
maxv.c | ||
min.c | ||
minnm.c | ||
minnmv.c | ||
minv.c | ||
mla_lane.c | ||
mls_lane.c | ||
mmlaq.c | ||
mull_high_lane.c | ||
mull_high_n.c | ||
mulx.c | ||
mulx_lane.c | ||
mulx_n.c | ||
padd.c | ||
pmax.c | ||
pmaxnm.c | ||
pmin.c | ||
pminnm.c | ||
qdmlal_lane.c | ||
qdmlsl_lane.c | ||
qdmull_high_lane.c | ||
qmovun_high.c | ||
qrdmlah.c | ||
qrdmlah_lane.c | ||
qrdmlsh.c | ||
qrdmlsh_lane.c | ||
qrdmulh_lane.c | ||
qrshl.c | ||
qrshrn_high_n.c | ||
qrshrun_high_n.c | ||
qshl_n.c | ||
qshrn_high_n.c | ||
qshrn_n.c | ||
raddhn.c | ||
raddhn_high.c | ||
reinterpret.c | ||
rev64.c | ||
rshrn_high_n.c | ||
rshrn_n.c | ||
rsubhn.c | ||
rsubhn_high.c | ||
sli_n.c | ||
st1_lane.c | ||
st1_x2.c | ||
st1_x3.c | ||
st1_x4.c | ||
st1q_x2.c | ||
st1q_x3.c | ||
st1q_x4.c | ||
st2_lane.c | ||
st3.c | ||
st3_lane.c | ||
st4.c | ||
st4_lane.c | ||
trn.c | ||
trn1.c | ||
trn2.c | ||
uzp.c | ||
uzp1.c | ||
uzp2.c |