Changeset 3853 for parabix-LLVM


Ignore:
Timestamp:
Jun 4, 2014, 12:46:58 AM (4 years ago)
Author:
cameron
Message:

Also generate CodeGenTarget?.cpp for TableGen?

Location:
parabix-LLVM
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • parabix-LLVM/mkValueTypes.py

    r3852 r3853  
    1414    enumTypeLine = "\t%s\t\t=  %s,\n"
    1515    defTypeLine = "def %s\t: ValueType<%s , %s>;\n"
     16    enumStringLine = "  case MVT::%s:     return \"MVT::%s\";\n"
    1617    fw = 1
    1718    fws = []
     
    2526    VTmap['integer_type_lines'] = ''
    2627    VTmap['int_value_type_defs'] = ''
     28    VTmap['int_type_enum_strings'] = ''
    2729    intTypes = ""
    2830    intVecTypes = ""
     
    3234        VTmap['integer_type_lines'] += enumTypeLine % (iType, enumVal)
    3335        VTmap['int_value_type_defs'] += defTypeLine % (iType, fw, enumVal)
     36        VTmap['int_type_enum_strings'] += enumStringLine % (iType, iType)
    3437    VTmap['first_integer_type'] = 'i%s' % fws[0]
    3538    VTmap['last_integer_type'] = 'i%s' % fws[-1]
     
    4447    VTmap['integer_vector_type_lines'] = ''
    4548    VTmap['int_vector_value_type_defs'] = ''
     49    VTmap['int_vector_value_enum_strings'] = ''
    4650    for fw in fws:
    4751        for fieldcount in [f for f in fws if f * fw <= maxwidth and f * fw >= minvecwidth]:
     
    5054            VTmap['integer_vector_type_lines'] += enumTypeLine % (vType, enumVal)
    5155            VTmap['int_vector_value_type_defs'] += defTypeLine % (vType, fieldcount * fw, enumVal)
     56            VTmap['int_vector_value_enum_strings'] += enumStringLine % (vType, vType)
    5257            VectorSizeMap[fw * fieldcount].append(vType)
    5358            VectorFieldSizeMap[fw].append(vType)
     
    5661    VTmap['float_vector_type_lines'] = ''
    5762    VTmap['float_vector_value_type_defs'] = ''
     63    VTmap['float_vector_value_enum_strings'] = ''
    5864    for fpfw in [16,32,64]:
    5965        for fieldcount in [f for f in fws if f * fpfw <= maxwidth]:
     
    6268            VTmap['float_vector_type_lines'] += enumTypeLine % (vType, enumVal)
    6369            VTmap['float_vector_value_type_defs'] += defTypeLine % (vType, fieldcount * fpfw, enumVal)
     70            VTmap['float_vector_value_enum_strings'] += enumStringLine % (vType, vType)
    6471            VectorSizeMap[fpfw * fieldcount].append(vType)
    6572            VectorFieldSizeMap[fpfw].append(vType)
     
    258265    f.close()
    259266
     267def makeCodeGenTarget_cpp(maxwidth, minwidth=32):
     268    f = open('CodeGenTarget.cpp.pytemplate')
     269    t = Template(f.read())
     270    f.close()
     271    (VTmap, VectorSizeMap, VectorFieldSizeMap) = calculateTypeData(maxwidth, minwidth)
     272    content = t.substitute(VTmap)
     273    if os.path.exists("CodeGenTarget.cpp") and  not os.path.exists("CodeGenTarget.cpp.bak"):
     274        shutil.move("CodeGenTarget.cpp", "CodeGenTarget.cpp.bak")
     275    f = open("CodeGenTarget.cpp", "w")
     276    f.write(content)
     277    f.close()
     278
    260279if __name__ == '__main__':
    261280    makeMachineValueType_h(128, 1)
    262281    makeValueTypes_td(128, 1)
    263     print "MachineValueType.h and ValueTypes.td generated."
     282    makeCodeGenTarget_cpp(128, 1)
     283    print "MachineValueType.h, CodeGenTarget.cpp and ValueTypes.td generated."
Note: See TracChangeset for help on using the changeset viewer.