Changeset 3996 for trunk


Ignore:
Timestamp:
Aug 12, 2014, 1:54:54 PM (4 years ago)
Author:
linmengl
Message:

extend template system for i4 and i8.

Location:
trunk/lib_ir/gen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/gen/gen.py

    r3981 r3996  
    1313
    1414FunctionList = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"]
     15FunctionListI4 = ["add", "sub"]
     16FunctionListI8 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"]
     17
     18FW = 2
    1519
    1620def C(name):
    17     return name + "_2"
     21    return "{name}_{fw}".format(name=name, fw=FW)
    1822
    1923def CXX(name):
    2024    if name in ["vsll", "vsrl", "vsra"]:
    21         return "simd<2>::" + name[1:] + "i"
    22     return "simd<2>::" + name
     25        return "simd<{fw}>::{name}i".format(fw=FW, name=name[1:])
     26    return "simd<{fw}>::{name}".format(fw=FW, name=name)
    2327
    2428def OP(name):
     
    4145    return ""
    4246
    43 FunctionNames = [{"c": C(name), "cxx": CXX(name), "op": OP(name), "flag": FLAG(name)}
    44                     for name in FunctionList]
     47#Get all v64i2 names
     48FunctionNames = [{"c": C(name), "cxx": CXX(name), "op": OP(name),
     49                  "flag": FLAG(name), "fw": FW} for name in FunctionList]
     50FW = 4
     51FunctionNamesI4 = [{"c": C(name), "cxx": CXX(name), "op": OP(name),
     52                    "flag": FLAG(name), "fw": FW} for name in FunctionListI4]
     53FW = 8
     54FunctionNamesI8 = [{"c": C(name), "cxx": CXX(name), "op": OP(name),
     55                    "flag": FLAG(name), "fw": FW} for name in FunctionListI8]
    4556
    4657#configuring Jinja2
     
    5768    fillTemplate(template=TestTemplate, output=TestOutput,
    5869                 params=dict(HeaderComment = "AUTO GENERATED FILE",
    59                              FunctionNames = FunctionNames))
     70                             FunctionNames = FunctionNames,
     71                             FunctionNamesI4 = FunctionNamesI4,
     72                             FunctionNamesI8 = FunctionNamesI8,
     73                             ))
    6074
    6175def genLLFile():
    6276    fillTemplate(template=LLTemplate, output=LLOutput,
    63                  params=dict(FunctionNames = FunctionNames))
     77                 params=dict(FunctionNames = FunctionNames,
     78                             FunctionNamesI4 = FunctionNamesI4,
     79                             FunctionNamesI8 = FunctionNamesI8,
     80                             ))
    6481
    6582def genFuncFile():
     
    6885                             FunctionNames = FunctionNames,
    6986                             Implement = impl_data.getImplements()))
     87    # NEED to copy manually.
    7088    # mv ParabixGeneratedFuncs.h ~/llvm_suit/llvm_git/lib/Target/X86/
    7189
     
    7391    genTestFile()
    7492    genLLFile()
    75     genFuncFile()
     93    #genFuncFile()
    7694
  • trunk/lib_ir/gen/llc_func.pytemplate.ll

    r3985 r3996  
    1212{% endfor %}
    1313
     14{% for i in [0, 1, 17] %}
    1415{% for x in range(0, 4) %}
    15 define <64 x i2> @insertelement_idx0_elt{{ x }}(<64 x i2> %a) {
     16define <64 x i2> @insertelement_idx{{ i }}_elt{{ x }}(<64 x i2> %a) {
    1617entry:
    17   %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 0
     18  %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 {{ i }}
    1819  ret <64 x i2> %c
    1920}
    2021
    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 %}
    3323{% endfor %}
    3424
     
    4131}
    4232{% endfor %}
     33
     34; v32i4 starts here
     35{% for name in FunctionNamesI4 %}
     36define <32 x i4> @{{name.c}}(<32 x i4> %a, <32 x i4> %b) {
     37entry:
     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 %}
     50define <16 x i8> @{{name.c}}(<16 x i8> %a, <16 x i8> %b) {
     51entry:
     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  
    99#include <cstdlib>
    1010using namespace std;
     11{% set Names = FunctionNames + FunctionNamesI4 + FunctionNamesI8 %}
    1112
    1213extern "C" {
    13 {% for name in FunctionNames %}
     14{% for name in Names %}
    1415  SIMD_type {{ name.c }}(SIMD_type a, SIMD_type b);
    1516{% endfor %}
     
    3637  short x;
    3738
    38   for (unsigned i = 0; i < 5; ++i) {
     39  for (unsigned i = 0; i < 50; ++i) {
    3940    fill_random(a, b);
    4041
    41     {% for name in FunctionNames %}
     42    {% for name in Names %}
    4243    {% if name.flag == "" %}
    4344    c = {{ name.c }}(a, b);
     
    4546    if (Store2String(c,1) != Store2String(d,1)) {
    4647      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
    4753      return 1;
    4854    }
     
    5258
    5359    //Shifting tests need special treatment
    54     {% for name in FunctionNames %}
     60    {% for name in Names %}
    5561    {% if name.flag == "shifting" %}
    56     {% for x in [0, 1] %}
    57     b = mvmd<2>::fill({{ x }});
     62    {% for x in range(0, name.fw) %}
    5863    c = {{ name.cxx }}<{{ x }}>(a);
     64    b = mvmd<{{ name.fw }}>::fill({{ x }});
    5965    d = {{ name.c }}(a, b);
    6066    if (Store2String(c,1) != Store2String(d,1)) {
     
    6874  }
    6975
    70   //Testcases for insert/extract element
     76  //Testcases for insert/extract element on v64i2
    7177  {% for x in range(0, 4) %}
    7278  a = mvmd<32>::fill4(0, 1, 0, 0);
Note: See TracChangeset for help on using the changeset viewer.