Changeset 3996 for trunk/lib_ir
- Timestamp:
- Aug 12, 2014, 1:54:54 PM (5 years ago)
- Location:
- trunk/lib_ir/gen
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib_ir/gen/gen.py
r3981 r3996 13 13 14 14 FunctionList = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"] 15 FunctionListI4 = ["add", "sub"] 16 FunctionListI8 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"] 17 18 FW = 2 15 19 16 20 def C(name): 17 return name + "_2"21 return "{name}_{fw}".format(name=name, fw=FW) 18 22 19 23 def CXX(name): 20 24 if name in ["vsll", "vsrl", "vsra"]: 21 return "simd< 2>::" + name[1:] + "i"22 return "simd< 2>::" + name25 return "simd<{fw}>::{name}i".format(fw=FW, name=name[1:]) 26 return "simd<{fw}>::{name}".format(fw=FW, name=name) 23 27 24 28 def OP(name): … … 41 45 return "" 42 46 43 FunctionNames = [{"c": C(name), "cxx": CXX(name), "op": OP(name), "flag": FLAG(name)} 44 for name in FunctionList] 47 #Get all v64i2 names 48 FunctionNames = [{"c": C(name), "cxx": CXX(name), "op": OP(name), 49 "flag": FLAG(name), "fw": FW} for name in FunctionList] 50 FW = 4 51 FunctionNamesI4 = [{"c": C(name), "cxx": CXX(name), "op": OP(name), 52 "flag": FLAG(name), "fw": FW} for name in FunctionListI4] 53 FW = 8 54 FunctionNamesI8 = [{"c": C(name), "cxx": CXX(name), "op": OP(name), 55 "flag": FLAG(name), "fw": FW} for name in FunctionListI8] 45 56 46 57 #configuring Jinja2 … … 57 68 fillTemplate(template=TestTemplate, output=TestOutput, 58 69 params=dict(HeaderComment = "AUTO GENERATED FILE", 59 FunctionNames = FunctionNames)) 70 FunctionNames = FunctionNames, 71 FunctionNamesI4 = FunctionNamesI4, 72 FunctionNamesI8 = FunctionNamesI8, 73 )) 60 74 61 75 def genLLFile(): 62 76 fillTemplate(template=LLTemplate, output=LLOutput, 63 params=dict(FunctionNames = FunctionNames)) 77 params=dict(FunctionNames = FunctionNames, 78 FunctionNamesI4 = FunctionNamesI4, 79 FunctionNamesI8 = FunctionNamesI8, 80 )) 64 81 65 82 def genFuncFile(): … … 68 85 FunctionNames = FunctionNames, 69 86 Implement = impl_data.getImplements())) 87 # NEED to copy manually. 70 88 # mv ParabixGeneratedFuncs.h ~/llvm_suit/llvm_git/lib/Target/X86/ 71 89 … … 73 91 genTestFile() 74 92 genLLFile() 75 genFuncFile()93 #genFuncFile() 76 94 -
trunk/lib_ir/gen/llc_func.pytemplate.ll
r3985 r3996 12 12 {% endfor %} 13 13 14 {% for i in [0, 1, 17] %} 14 15 {% for x in range(0, 4) %} 15 define <64 x i2> @insertelement_idx 0_elt{{ x }}(<64 x i2> %a) {16 define <64 x i2> @insertelement_idx{{ i }}_elt{{ x }}(<64 x i2> %a) { 16 17 entry: 17 %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 018 %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 {{ i }} 18 19 ret <64 x i2> %c 19 20 } 20 21 21 define <64 x i2> @insertelement_idx1_elt{{ x }}(<64 x i2> %a) { 22 entry: 23 %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 1 24 ret <64 x i2> %c 25 } 26 27 define <64 x i2> @insertelement_idx17_elt{{ x }}(<64 x i2> %a) { 28 entry: 29 %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 17 30 ret <64 x i2> %c 31 } 32 22 {% endfor %} 33 23 {% endfor %} 34 24 … … 41 31 } 42 32 {% endfor %} 33 34 ; v32i4 starts here 35 {% for name in FunctionNamesI4 %} 36 define <32 x i4> @{{name.c}}(<32 x i4> %a, <32 x i4> %b) { 37 entry: 38 %c = {{ name.op }} <32 x i4> %a, %b 39 {% if "icmp" in name.op %} 40 %d = sext <32 x i1> %c to <32 x i4> 41 ret <32 x i4> %d 42 {% else %} 43 ret <32 x i4> %c 44 {% endif %} 45 } 46 {% endfor %} 47 48 ; v16i8 starts here 49 {% for name in FunctionNamesI8 %} 50 define <16 x i8> @{{name.c}}(<16 x i8> %a, <16 x i8> %b) { 51 entry: 52 %c = {{ name.op }} <16 x i8> %a, %b 53 {% if "icmp" in name.op %} 54 %d = sext <16 x i1> %c to <16 x i8> 55 ret <16 x i8> %d 56 {% else %} 57 ret <16 x i8> %c 58 {% endif %} 59 } 60 {% endfor %} -
trunk/lib_ir/gen/test_llc.pytemplate.cpp
r3985 r3996 9 9 #include <cstdlib> 10 10 using namespace std; 11 {% set Names = FunctionNames + FunctionNamesI4 + FunctionNamesI8 %} 11 12 12 13 extern "C" { 13 {% for name in FunctionNames %}14 {% for name in Names %} 14 15 SIMD_type {{ name.c }}(SIMD_type a, SIMD_type b); 15 16 {% endfor %} … … 36 37 short x; 37 38 38 for (unsigned i = 0; i < 5 ; ++i) {39 for (unsigned i = 0; i < 50; ++i) { 39 40 fill_random(a, b); 40 41 41 {% for name in FunctionNames %}42 {% for name in Names %} 42 43 {% if name.flag == "" %} 43 44 c = {{ name.c }}(a, b); … … 45 46 if (Store2String(c,1) != Store2String(d,1)) { 46 47 cout << "{{ name.c }} faild." << endl; 48 cout << "A = " << Store2String(a, 1) << endl; 49 cout << "B = " << Store2String(b, 1) << endl; 50 cout << "c = " << Store2String(c, 1) << endl; 51 cout << "cxx=" << Store2String(d, 1) << endl; 52 47 53 return 1; 48 54 } … … 52 58 53 59 //Shifting tests need special treatment 54 {% for name in FunctionNames %}60 {% for name in Names %} 55 61 {% if name.flag == "shifting" %} 56 {% for x in [0, 1] %} 57 b = mvmd<2>::fill({{ x }}); 62 {% for x in range(0, name.fw) %} 58 63 c = {{ name.cxx }}<{{ x }}>(a); 64 b = mvmd<{{ name.fw }}>::fill({{ x }}); 59 65 d = {{ name.c }}(a, b); 60 66 if (Store2String(c,1) != Store2String(d,1)) { … … 68 74 } 69 75 70 //Testcases for insert/extract element 76 //Testcases for insert/extract element on v64i2 71 77 {% for x in range(0, 4) %} 72 78 a = mvmd<32>::fill4(0, 1, 0, 0);
Note: See TracChangeset
for help on using the changeset viewer.