Changeset 3904 for parabix-LLVM


Ignore:
Timestamp:
Jun 30, 2014, 8:19:06 PM (5 years ago)
Author:
linmengl
Message:

add ValueTypes?.cpp, enable getTypesForEVT

Location:
parabix-LLVM
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • parabix-LLVM/MachineValueType.h.pytemplate

    r3852 r3904  
    141141      return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
    142142              SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
     143    }
     144
     145    /// Parabix helper functions here
     146    bool isParabixVector() const {
     147      return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v64i1);
    143148    }
    144149
  • parabix-LLVM/cp_to_place.sh

    r3858 r3904  
    33CodeGen_Folder=$LLVM_ROOT/include/llvm/CodeGen/
    44TableGen_Folder=$LLVM_ROOT/utils/TableGen/
     5IR_Folder=$LLVM_ROOT/lib/IR/
    56
    67cp ValueTypes.td $CodeGen_Folder
    78cp MachineValueType.h $CodeGen_Folder
    89cp CodeGenTarget.cpp $TableGen_Folder
     10cp ValueTypes.cpp $IR_Folder
    911
    10 echo "3 files copied into LLVM folders"
     12echo "4 files copied into LLVM folders, use Git diff to check the changed files."
  • parabix-LLVM/mkValueTypes.py

    r3859 r3904  
    1818    fws = []
    1919    while (fw <= maxwidth): fws.append(fw); fw = fw * 2
     20
    2021    enumVal = 0
    2122    VectorSizeMap = {}
     
    133134    """
    134135vecNumRe = re.compile("v([0-9]+)[if][0-9]+")
    135 
     136def getNumElement(typeString):
     137    """
     138    return number of elements in a type string
     139    e.g. return 32 in v32i1
     140    """
     141    m = vecNumRe.match(typeString)
     142    return int(m.group(1))
    136143
    137144def make_getVectorNumElements(VectorSizeMap):
     
    277284    f.close()
    278285
     286def make_getTypeForEVT(VectorSizeMap):
     287    res = ''
     288    for bitwidth in sorted(VectorSizeMap.keys()):
     289        for tpname in VectorSizeMap[bitwidth]:
     290            if 'f' in tpname:
     291                # only works on integer vectors
     292                continue
     293            num_elt = getNumElement(tpname)
     294            fieldtype = bitwidth / num_elt
     295            if fieldtype > 64 or fieldtype == 2 or fieldtype == 4:
     296                continue
     297            res += "  case MVT::{tpname}:   return VectorType::get(Type::getInt{fieldtype}Ty(Context), {num_elt});\n".format(
     298                    **{'tpname': tpname, 'fieldtype': fieldtype, 'num_elt': num_elt});
     299    return res
     300
     301def makeValueTypes_cpp(maxwidth, minwidth=32):
     302    f = open('ValueTypes.cpp.pytemplate')
     303    t = Template(f.read())
     304    f.close()
     305    (VTmap, VectorSizeMap, VectorFieldSizeMap) = calculateTypeData(maxwidth, minwidth)
     306    VTmap['get_type_for_vector_EVT'] = make_getTypeForEVT(VectorSizeMap)
     307    content = t.substitute(VTmap)
     308    if os.path.exists("ValueTypes.cpp") and  not os.path.exists("ValueTypes.cpp.bak"):
     309        shutil.move("ValueTypes.cpp", "ValueTypes.cpp.bak")
     310    f = open("ValueTypes.cpp", "w")
     311    f.write(content)
     312    f.close()
     313    print "ValueTypes.cpp generated."
     314
    279315if __name__ == '__main__':
    280316    makeMachineValueType_h(1024, 1)
    281317    makeValueTypes_td(1024, 1)
    282318    makeCodeGenTarget_cpp(1024, 1)
     319    makeValueTypes_cpp(1024, 1)
    283320    print "MachineValueType.h, CodeGenTarget.cpp and ValueTypes.td generated."
Note: See TracChangeset for help on using the changeset viewer.