Ejemplo n.º 1
0
 def assertMatches(self, checkerString, c1String):
     checkerString = \
       """
     /// CHECK-START: MyMethod MyPass
   """ + checkerString
     c1String = \
       """
     begin_compilation
       name "MyMethod"
       method "MyMethod"
       date 1234
     end_compilation
     begin_cfg
       name "MyPass"
   """ + c1String + \
       """
     end_cfg
   """
     checkerFile = ParseCheckerStream("<test-file>", "CHECK",
                                      io.StringIO(ToUnicode(checkerString)))
     c1File = ParseC1visualizerStream("<c1-file>",
                                      io.StringIO(ToUnicode(c1String)))
     assert len(checkerFile.testCases) == 1
     assert len(c1File.passes) == 1
     MatchTestCase(checkerFile.testCases[0], c1File.passes[0])
Ejemplo n.º 2
0
def RunTests(checkPrefix, checkPath, outputFilename, targetArch):
    c1File = ParseC1visualizerStream(os.path.basename(outputFilename),
                                     open(outputFilename, "r"))
    for checkFilename in FindCheckerFiles(checkPath):
        checkerFile = ParseCheckerStream(os.path.basename(checkFilename),
                                         checkPrefix, open(checkFilename, "r"))
        MatchFiles(checkerFile, c1File, targetArch)
Ejemplo n.º 3
0
    def assertMatches(self,
                      checkerString,
                      c1String,
                      isa=None,
                      instructionSetFeatures=None):
        checkerString = \
          """
        /// CHECK-START: MyMethod MyPass
      """ + checkerString
        metaData = ""
        if isa:
            metaData += "isa:" + isa

        if instructionSetFeatures:
            if metaData:
                metaData += " "

            joinedFeatures = ",".join(
                map(
                    lambda feature: feature
                    if instructionSetFeatures[feature] else "-" + feature,
                    instructionSetFeatures))
            metaData += "isa_features:" + joinedFeatures

        metaDataString = ""
        if metaData:
            metaDataString = \
              """
          begin_compilation
            name "%s"
            method "%s"
            date 1234
          end_compilation
        """ % (metaData, metaData)
        c1String = metaDataString + \
          """
        begin_compilation
          name "MyMethod"
          method "MyMethod"
          date 1234
        end_compilation
        begin_cfg
          name "MyPass"
      """ + c1String + \
          """
        end_cfg
      """
        checkerFile = ParseCheckerStream("<test-file>", "CHECK",
                                         io.StringIO(ToUnicode(checkerString)))
        c1File = ParseC1visualizerStream("<c1-file>",
                                         io.StringIO(ToUnicode(c1String)))
        assert len(checkerFile.testCases) == 1
        assert len(c1File.passes) == 1
        MatchTestCase(checkerFile.testCases[0], c1File.passes[0],
                      c1File.instructionSetFeatures)
Ejemplo n.º 4
0
def DumpPass(outputFilename, passName):
  c1File = ParseC1visualizerStream(os.path.basename(outputFilename), open(outputFilename, "r"))
  compiler_pass = c1File.findPass(passName)
  if compiler_pass:
    maxLineNo = compiler_pass.startLineNo + len(compiler_pass.body)
    lenLineNo = len(str(maxLineNo)) + 2
    curLineNo = compiler_pass.startLineNo
    for line in compiler_pass.body:
      Logger.log((str(curLineNo) + ":").ljust(lenLineNo) + line)
      curLineNo += 1
  else:
    Logger.fail("Pass \"" + passName + "\" not found in the output")
Ejemplo n.º 5
0
 def assertParsesTo(self, c1Text, expectedData):
     expectedFile = self.createFile(expectedData)
     actualFile = ParseC1visualizerStream("<c1_file>",
                                          io.StringIO(ToUnicode(c1Text)))
     return self.assertEqual(expectedFile, actualFile)
Ejemplo n.º 6
0
def ListPasses(outputFilename):
    c1File = ParseC1visualizerStream(os.path.basename(outputFilename),
                                     open(outputFilename, "r"))
    for compiler_pass in c1File.passes:
        Logger.log(compiler_pass.name)