1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

Python compat - print statement

Make sure all print statements are compatible with Python 2 and Python3 using
the `from __future__ import print_function` statement.

Differential Revision: https://reviews.llvm.org/D56249

llvm-svn: 350307
This commit is contained in:
Serge Guelton 2019-01-03 14:11:33 +00:00
parent 65df098609
commit bc5eec4c75
56 changed files with 592 additions and 487 deletions

View File

@ -6,6 +6,7 @@
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
from __future__ import print_function
from .common import LLVMObject
from .common import c_object_p
@ -605,7 +606,7 @@ def register_enumerations():
]
for enum_class, enum_spec in enums:
for name, value in enum_spec:
print name, value
print(name, value)
enum_class.register(name, value)
return enums

View File

@ -1,3 +1,5 @@
from __future__ import print_function
from .base import TestBase
from ..core import OpCode
from ..core import MemoryBuffer
@ -11,5 +13,5 @@ class TestBitReader(TestBase):
def test_parse_bitcode(self):
source = self.get_test_bc()
m = parse_bitcode(MemoryBuffer(filename=source))
print m.target
print m.datalayout
print(m.target)
print(m.datalayout)

View File

@ -1,3 +1,5 @@
from __future__ import print_function
from .base import TestBase
from ..core import MemoryBuffer
from ..core import PassRegistry
@ -127,7 +129,7 @@ class TestCore(TestBase):
self.assertEqual(inst.opcode, inst_list[i][1])
for op in range(len(inst)):
o = inst.get_operand(op)
print o.name
print(o.name)
o.dump()
inst.dump()
i += 1

View File

@ -1,3 +1,5 @@
from __future__ import print_function
from .base import TestBase
from ..disassembler import Disassembler, Option_UseMarkup
@ -38,6 +40,6 @@ class TestDisassembler(TestBase):
disassembler = Disassembler(triple)
disassembler.set_options(Option_UseMarkup)
count, s = disassembler.get_instruction(sequence)
print s
print(s)
self.assertEqual(count, 4)
self.assertEqual(s, '\tpush\t{<reg:r4>, <reg:lr>}')

View File

@ -9,6 +9,7 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import print_function
import sys, os
from datetime import date
@ -234,14 +235,14 @@ for name in os.listdir(command_guide_path):
header = f.readline().rstrip('\n')
if len(header) != len(title):
print >>sys.stderr, (
print((
"error: invalid header in %r (does not match title)" % (
file_subpath,))
file_subpath,)), file=sys.stderr)
if ' - ' not in title:
print >>sys.stderr, (
print((
("error: invalid title in %r "
"(expected '<name> - <description>')") % (
file_subpath,))
file_subpath,)), file=sys.stderr)
# Split the name out of the title.
name,description = title.split(' - ', 1)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
import random
@ -173,7 +175,7 @@ class KScriptGenerator:
def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
""" Generate a random Kaleidoscope script based on the given parameters """
print "Generating " + filename
print("Generating " + filename)
print(" %d functions, %d elements per function, %d functions between execution" %
(numFuncs, elementsPerFunc, funcsBetweenExec))
print(" Call weighting = %f" % callWeighting)
@ -200,7 +202,7 @@ def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callW
script.writeEmptyLine()
script.writeFinalFunctionCounts()
funcsCalled = len(script.calledFunctions)
print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
# Execution begins here
@ -216,4 +218,4 @@ dataSets = [(5000, 3, 50, 0.50), (5000, 10, 100, 0.10), (5000, 10, 5, 0.10), (5
for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
print "All done!"
print("All done!")

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
class TimingScriptGenerator:
"""Used to generate a bash script which will invoke the toy and time it"""
def __init__(self, scriptname, outputname):
@ -47,7 +49,7 @@ def splitScript(inputname, libGenScript, timingScript):
infile = open(inputname, "r")
libfile = open(libname, "w")
callfile = open(callname, "w")
print "Splitting %s into %s and %s" % (inputname, callname, libname)
print("Splitting %s into %s and %s" % (inputname, callname, libname))
for line in infile:
if not line.startswith("#"):
if line.startswith("print"):
@ -67,4 +69,4 @@ script_list = ["test-5000-3-50-50.k", "test-5000-10-100-10.k", "test-5000-10-5-1
for script in script_list:
splitScript(script, libGenScript, timingScript)
print "All done!"
print("All done!")

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
import random
@ -178,7 +180,7 @@ class KScriptGenerator:
def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
""" Generate a random Kaleidoscope script based on the given parameters """
print "Generating " + filename
print("Generating " + filename)
print(" %d functions, %d elements per function, %d functions between execution" %
(numFuncs, elementsPerFunc, funcsBetweenExec))
print(" Call weighting = %f" % callWeighting)
@ -205,7 +207,7 @@ def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callW
script.writeEmptyLine()
script.writeFinalFunctionCounts()
funcsCalled = len(script.calledFunctions)
print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
# Execution begins here
@ -221,4 +223,4 @@ dataSets = [(5000, 3, 50, 0.50), (5000, 10, 100, 0.10), (5000, 10, 5, 0.10), (5
for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
print "All done!"
print("All done!")

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
class TimingScriptGenerator:
"""Used to generate a bash script which will invoke the toy and time it"""
def __init__(self, scriptname, outputname):
@ -47,7 +49,7 @@ def splitScript(inputname, libGenScript, timingScript):
infile = open(inputname, "r")
libfile = open(libname, "w")
callfile = open(callname, "w")
print "Splitting %s into %s and %s" % (inputname, callname, libname)
print("Splitting %s into %s and %s" % (inputname, callname, libname))
for line in infile:
if not line.startswith("#"):
if line.startswith("print"):
@ -67,4 +69,4 @@ script_list = ["test-5000-3-50-50.k", "test-5000-10-100-10.k", "test-5000-10-5-1
for script in script_list:
splitScript(script, libGenScript, timingScript)
print "All done!"
print("All done!")

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
import random
@ -173,7 +175,7 @@ class KScriptGenerator:
def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
""" Generate a random Kaleidoscope script based on the given parameters """
print "Generating " + filename
print("Generating " + filename)
print(" %d functions, %d elements per function, %d functions between execution" %
(numFuncs, elementsPerFunc, funcsBetweenExec))
print(" Call weighting = %f" % callWeighting)
@ -200,7 +202,7 @@ def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callW
script.writeEmptyLine()
script.writeFinalFunctionCounts()
funcsCalled = len(script.calledFunctions)
print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
# Execution begins here
@ -216,4 +218,4 @@ dataSets = [(5000, 3, 50, 0.50), (5000, 10, 100, 0.10), (5000, 10, 5, 0.10), (5
for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
print "All done!"
print("All done!")

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
# Currently any print-out from the custom tool is interpreted as a crash

View File

@ -5,6 +5,8 @@
# RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,CHECK_P64 %t.ll
# RUN: llc < %t.ll -march=nvptx -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,CHECK_P32 %t.ll
from __future__ import print_function
from itertools import product
from string import Template

View File

@ -4,6 +4,8 @@
# RUN: python %s > %t.ll
# RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx61 | FileCheck %t.ll
from __future__ import print_function
from itertools import product
from string import Template

View File

@ -67,42 +67,44 @@
# CHECK: c %r4, 136(%r3)
# CHECK: jge [[LABEL]]
from __future__ import print_function
branch_blocks = 10
main_size = 0xffd8
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i32 *%stop, i32 %limit) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bstop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i)
print ' %%bcur%d = load i32 , i32 *%%bstop%d' % (i, i)
print ' %%btest%d = icmp eq i32 %%limit, %%bcur%d' % (i, i)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bstop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i))
print(' %%bcur%d = load i32 , i32 *%%bstop%d' % (i, i))
print(' %%btest%d = icmp eq i32 %%limit, %%bcur%d' % (i, i))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i + 25)
print ' %%acur%d = load i32 , i32 *%%astop%d' % (i, i)
print ' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i + 25))
print(' %%acur%d = load i32 , i32 *%%astop%d' % (i, i))
print(' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -56,12 +56,14 @@
# CHECK: c %r4, 1036(%r3)
# CHECK: jge [[LABEL]]
from __future__ import print_function
blocks = 256 + 4
print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
print 'entry:'
print ' br label %b0'
print ''
print('define void @f1(i8 *%base, i32 *%stop, i32 %limit) {')
print('entry:')
print(' br label %b0')
print('')
a, b = 1, 1
for i in xrange(blocks):
@ -69,14 +71,14 @@ for i in xrange(blocks):
value = a % 256
next = 'b%d' % (i + 1) if i + 1 < blocks else 'end'
other = 'end' if 2 * i < blocks else 'b0'
print 'b%d:' % i
print ' store volatile i8 %d, i8 *%%base' % value
print ' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i)
print ' %%acur%d = load i32 , i32 *%%astop%d' % (i, i)
print ' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
print ' br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next)
print('b%d:' % i)
print(' store volatile i8 %d, i8 *%%base' % value)
print(' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i))
print(' %%acur%d = load i32 , i32 *%%astop%d' % (i, i))
print(' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i))
print(' br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next))
print ''
print '%s:' % next
print ' ret void'
print '}'
print('')
print('%s:' % next)
print(' ret void')
print('}')

View File

@ -67,44 +67,46 @@
# CHECK: cr %r4, [[REG]]
# CHECK: jge [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop, i32 %limit) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop, i32 %limit) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
print ' %%btest%d = icmp eq i32 %%limit, %%bext%d' % (i, i)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
print(' %%btest%d = icmp eq i32 %%limit, %%bext%d' % (i, i))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
print ' %%atest%d = icmp eq i32 %%limit, %%aext%d' % (i, i)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
print(' %%atest%d = icmp eq i32 %%limit, %%aext%d' % (i, i))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -71,44 +71,46 @@
# CHECK: cgr %r4, [[REG]]
# CHECK: jge [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop, i64 %limit) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop, i64 %limit) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
print ' %%btest%d = icmp eq i64 %%limit, %%bext%d' % (i, i)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
print(' %%btest%d = icmp eq i64 %%limit, %%bext%d' % (i, i))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
print ' %%atest%d = icmp eq i64 %%limit, %%aext%d' % (i, i)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
print(' %%atest%d = icmp eq i64 %%limit, %%aext%d' % (i, i))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -71,42 +71,44 @@
# CHECK: chi [[REG]], 107
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bcur%d = load i8 , i8 *%%stop' % i
print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
print ' %%btest%d = icmp slt i32 %%bext%d, %d' % (i, i, i + 50)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bcur%d = load i8 , i8 *%%stop' % i)
print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
print(' %%btest%d = icmp slt i32 %%bext%d, %d' % (i, i, i + 50))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%acur%d = load i8 , i8 *%%stop' % i
print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
print ' %%atest%d = icmp slt i32 %%aext%d, %d' % (i, i, i + 100)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%acur%d = load i8 , i8 *%%stop' % i)
print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
print(' %%atest%d = icmp slt i32 %%aext%d, %d' % (i, i, i + 100))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -71,42 +71,44 @@
# CHECK: cghi [[REG]], 107
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bcur%d = load i8 , i8 *%%stop' % i
print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
print ' %%btest%d = icmp slt i64 %%bext%d, %d' % (i, i, i + 50)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bcur%d = load i8 , i8 *%%stop' % i)
print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
print(' %%btest%d = icmp slt i64 %%bext%d, %d' % (i, i, i + 50))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%acur%d = load i8 , i8 *%%stop' % i
print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
print ' %%atest%d = icmp slt i64 %%aext%d, %d' % (i, i, i + 100)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%acur%d = load i8 , i8 *%%stop' % i)
print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
print(' %%atest%d = icmp slt i64 %%aext%d, %d' % (i, i, i + 100))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -32,37 +32,39 @@
# CHECK: ahi {{%r[0-9]+}}, -1
# CHECK: jglh
from __future__ import print_function
branch_blocks = 8
main_size = 0xffd8
print 'define void @f1(i8 *%base, i32 *%counts) {'
print 'entry:'
print('define void @f1(i8 *%base, i32 *%counts) {')
print('entry:')
for i in xrange(branch_blocks - 1, -1, -1):
print ' %%countptr%d = getelementptr i32, i32 *%%counts, i64 %d' % (i, i)
print ' %%initcount%d = load i32 , i32 *%%countptr%d' % (i, i)
print ' br label %%loop%d' % i
print(' %%countptr%d = getelementptr i32, i32 *%%counts, i64 %d' % (i, i))
print(' %%initcount%d = load i32 , i32 *%%countptr%d' % (i, i))
print(' br label %%loop%d' % i)
print 'loop%d:' % i
print('loop%d:' % i)
block1 = 'entry' if i == branch_blocks - 1 else 'loop%d' % (i + 1)
block2 = 'loop0' if i == 0 else 'after%d' % (i - 1)
print (' %%count%d = phi i32 [ %%initcount%d, %%%s ],'
' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2))
print((' %%count%d = phi i32 [ %%initcount%d, %%%s ],'
' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2)))
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%nextcount%d = add i32 %%count%d, -1' % (i, i)
print ' %%test%d = icmp ne i32 %%nextcount%d, 0' % (i, i)
print ' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i)
print ''
print 'after%d:' % i
print(' %%nextcount%d = add i32 %%count%d, -1' % (i, i))
print(' %%test%d = icmp ne i32 %%nextcount%d, 0' % (i, i))
print(' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i))
print('')
print('after%d:' % i)
print ' ret void'
print '}'
print(' ret void')
print('}')

View File

@ -33,37 +33,39 @@
# CHECK: aghi {{%r[0-9]+}}, -1
# CHECK: jglh
from __future__ import print_function
branch_blocks = 8
main_size = 0xffd8
print 'define void @f1(i8 *%base, i64 *%counts) {'
print 'entry:'
print('define void @f1(i8 *%base, i64 *%counts) {')
print('entry:')
for i in xrange(branch_blocks - 1, -1, -1):
print ' %%countptr%d = getelementptr i64, i64 *%%counts, i64 %d' % (i, i)
print ' %%initcount%d = load i64 , i64 *%%countptr%d' % (i, i)
print ' br label %%loop%d' % i
print(' %%countptr%d = getelementptr i64, i64 *%%counts, i64 %d' % (i, i))
print(' %%initcount%d = load i64 , i64 *%%countptr%d' % (i, i))
print(' br label %%loop%d' % i)
print 'loop%d:' % i
print('loop%d:' % i)
block1 = 'entry' if i == branch_blocks - 1 else 'loop%d' % (i + 1)
block2 = 'loop0' if i == 0 else 'after%d' % (i - 1)
print (' %%count%d = phi i64 [ %%initcount%d, %%%s ],'
' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2))
print((' %%count%d = phi i64 [ %%initcount%d, %%%s ],'
' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2)))
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%nextcount%d = add i64 %%count%d, -1' % (i, i)
print ' %%test%d = icmp ne i64 %%nextcount%d, 0' % (i, i)
print ' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i)
print ''
print 'after%d:' % i
print(' %%nextcount%d = add i64 %%count%d, -1' % (i, i))
print(' %%test%d = icmp ne i64 %%nextcount%d, 0' % (i, i))
print(' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i))
print('')
print('after%d:' % i)
print ' ret void'
print '}'
print(' ret void')
print('}')

View File

@ -67,44 +67,46 @@
# CHECK: clr %r4, [[REG]]
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop, i32 %limit) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop, i32 %limit) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
print ' %%btest%d = icmp ult i32 %%limit, %%bext%d' % (i, i)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
print(' %%btest%d = icmp ult i32 %%limit, %%bext%d' % (i, i))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
print ' %%atest%d = icmp ult i32 %%limit, %%aext%d' % (i, i)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
print(' %%atest%d = icmp ult i32 %%limit, %%aext%d' % (i, i))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -71,44 +71,46 @@
# CHECK: clgr %r4, [[REG]]
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffcc
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i8 *%stop, i64 %limit) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i8 *%stop, i64 %limit) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
print ' %%btest%d = icmp ult i64 %%limit, %%bext%d' % (i, i)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
print(' %%btest%d = icmp ult i64 %%limit, %%bext%d' % (i, i))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
print ' %%atest%d = icmp ult i64 %%limit, %%aext%d' % (i, i)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
print(' %%atest%d = icmp ult i64 %%limit, %%aext%d' % (i, i))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -87,44 +87,46 @@
# CHECK: clfi [[REG]], 107
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffc6
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i32 *%stopa, i32 *%stopb) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i32 *%stopa, i32 *%stopb) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bcur%da = load i32 , i32 *%%stopa' % i
print ' %%bcur%db = load i32 , i32 *%%stopb' % i
print ' %%bsub%d = sub i32 %%bcur%da, %%bcur%db' % (i, i, i)
print ' %%btest%d = icmp ult i32 %%bsub%d, %d' % (i, i, i + 50)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bcur%da = load i32 , i32 *%%stopa' % i)
print(' %%bcur%db = load i32 , i32 *%%stopb' % i)
print(' %%bsub%d = sub i32 %%bcur%da, %%bcur%db' % (i, i, i))
print(' %%btest%d = icmp ult i32 %%bsub%d, %d' % (i, i, i + 50))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%acur%da = load i32 , i32 *%%stopa' % i
print ' %%acur%db = load i32 , i32 *%%stopb' % i
print ' %%asub%d = sub i32 %%acur%da, %%acur%db' % (i, i, i)
print ' %%atest%d = icmp ult i32 %%asub%d, %d' % (i, i, i + 100)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%acur%da = load i32 , i32 *%%stopa' % i)
print(' %%acur%db = load i32 , i32 *%%stopb' % i)
print(' %%asub%d = sub i32 %%acur%da, %%acur%db' % (i, i, i))
print(' %%atest%d = icmp ult i32 %%asub%d, %d' % (i, i, i + 100))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -87,44 +87,46 @@
# CHECK: clgfi [[REG]], 107
# CHECK: jgl [[LABEL]]
from __future__ import print_function
branch_blocks = 8
main_size = 0xffb4
print '@global = global i32 0'
print('@global = global i32 0')
print 'define void @f1(i8 *%base, i64 *%stopa, i64 *%stopb) {'
print 'entry:'
print ' br label %before0'
print ''
print('define void @f1(i8 *%base, i64 *%stopa, i64 *%stopb) {')
print('entry:')
print(' br label %before0')
print('')
for i in xrange(branch_blocks):
next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
print 'before%d:' % i
print ' %%bcur%da = load i64 , i64 *%%stopa' % i
print ' %%bcur%db = load i64 , i64 *%%stopb' % i
print ' %%bsub%d = sub i64 %%bcur%da, %%bcur%db' % (i, i, i)
print ' %%btest%d = icmp ult i64 %%bsub%d, %d' % (i, i, i + 50)
print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
print ''
print('before%d:' % i)
print(' %%bcur%da = load i64 , i64 *%%stopa' % i)
print(' %%bcur%db = load i64 , i64 *%%stopb' % i)
print(' %%bsub%d = sub i64 %%bcur%da, %%bcur%db' % (i, i, i))
print(' %%btest%d = icmp ult i64 %%bsub%d, %d' % (i, i, i + 50))
print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
print('')
print '%s:' % next
print('%s:' % next)
a, b = 1, 1
for i in xrange(0, main_size, 6):
a, b = b, a + b
offset = 4096 + b % 500000
value = a % 256
print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
for i in xrange(branch_blocks):
print ' %%acur%da = load i64 , i64 *%%stopa' % i
print ' %%acur%db = load i64 , i64 *%%stopb' % i
print ' %%asub%d = sub i64 %%acur%da, %%acur%db' % (i, i, i)
print ' %%atest%d = icmp ult i64 %%asub%d, %d' % (i, i, i + 100)
print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
print ''
print 'after%d:' % i
print(' %%acur%da = load i64 , i64 *%%stopa' % i)
print(' %%acur%db = load i64 , i64 *%%stopb' % i)
print(' %%asub%d = sub i64 %%acur%da, %%acur%db' % (i, i, i))
print(' %%atest%d = icmp ult i64 %%asub%d, %d' % (i, i, i + 100))
print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
print('')
print('after%d:' % i)
print ' %dummy = load volatile i32, i32 *@global'
print ' ret void'
print '}'
print(' %dummy = load volatile i32, i32 *@global')
print(' ret void')
print('}')

View File

@ -18,23 +18,26 @@
# CHECK: lay [[REG:%r[0-5]]], 4096(%r15)
# CHECK: mvc {{[0-9]+}}(8,{{%r[0-9]+}}), 8([[REG]])
# CHECK: br %r14
from __future__ import print_function
count = 500
print 'declare void @foo()'
print ''
print 'define void @f1(i64 *%base0, i64 *%base1) {'
print('declare void @foo()')
print('')
print('define void @f1(i64 *%base0, i64 *%base1) {')
for i in range(count):
print ' %%ptr%d = getelementptr i64, i64 *%%base%d, i64 %d' % (i, i % 2, i / 2)
print ' %%val%d = load i64 , i64 *%%ptr%d' % (i, i)
print ''
print(' %%ptr%d = getelementptr i64, i64 *%%base%d, i64 %d' % (i, i % 2, i / 2))
print(' %%val%d = load i64 , i64 *%%ptr%d' % (i, i))
print('')
print ' call void @foo()'
print ''
print(' call void @foo()')
print('')
for i in range(count):
print ' store i64 %%val%d, i64 *%%ptr%d' % (i, i)
print(' store i64 %%val%d, i64 *%%ptr%d' % (i, i))
print ''
print ' ret void'
print '}'
print('')
print(' ret void')
print('}')

View File

@ -19,55 +19,58 @@
# the first 8168 bytes to be used for the call. 160 of these bytes are
# allocated for the ABI frame. There are also 5 argument registers, one of
# which is used as a base pointer.
from __future__ import print_function
args = (8168 - 160) / 8 + (5 - 1)
print 'declare i64 *@foo(i64 *%s)' % (', i64' * args)
print 'declare void @bar(i64 *)'
print ''
print 'define i64 @f1(i64 %foo) {'
print 'entry:'
print('declare i64 *@foo(i64 *%s)' % (', i64' * args))
print('declare void @bar(i64 *)')
print('')
print('define i64 @f1(i64 %foo) {')
print('entry:')
# Make the allocation big, so that it goes at the top of the frame.
print ' %array = alloca [1000 x i64]'
print ' %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0'
print ' %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args)
print ''
print(' %array = alloca [1000 x i64]')
print(' %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0')
print(' %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args))
print('')
# Make sure all GPRs are used. One is needed for the stack pointer and
# another for %base, so we need 14 live values.
count = 14
for i in range(count):
print ' %%ptr%d = getelementptr i64, i64 *%%base, i64 %d' % (i, i / 2)
print ' %%val%d = load volatile i64 , i64 *%%ptr%d' % (i, i)
print ''
print(' %%ptr%d = getelementptr i64, i64 *%%base, i64 %d' % (i, i / 2))
print(' %%val%d = load volatile i64 , i64 *%%ptr%d' % (i, i))
print('')
# Encourage the register allocator to give preference to these %vals
# by using them several times.
for j in range(4):
for i in range(count):
print ' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
print ''
print(' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i))
print('')
# Copy the incoming argument, which we expect to be spilled, to the frame
# index for the alloca area. Also throw in a volatile store, so that this
# block cannot be reordered with the surrounding code.
print ' %cond = icmp eq i64 %val0, %val1'
print ' br i1 %cond, label %skip, label %fallthru'
print ''
print 'fallthru:'
print ' store i64 %foo, i64 *%area'
print ' store volatile i64 %val0, i64 *%ptr0'
print ' br label %skip'
print ''
print 'skip:'
print(' %cond = icmp eq i64 %val0, %val1')
print(' br i1 %cond, label %skip, label %fallthru')
print('')
print('fallthru:')
print(' store i64 %foo, i64 *%area')
print(' store volatile i64 %val0, i64 *%ptr0')
print(' br label %skip')
print('')
print('skip:')
# Use each %val a few more times to emphasise the point, and to make sure
# that they are live across the store of %foo.
for j in range(4):
for i in range(count):
print ' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
print ''
print(' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i))
print('')
print ' call void @bar(i64 *%area)'
print ' ret i64 0'
print '}'
print(' call void @bar(i64 *%area)')
print(' ret i64 0')
print('}')

View File

@ -1,5 +1,7 @@
# RUN: python %s | llvm-mc -filetype=obj -triple i686-pc-win32 - | llvm-readobj -h | FileCheck %s
from __future__ import print_function
# This test checks that the COFF object emitter can produce objects with
# more than 65279 sections.

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import argparse

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
# Generates ELF, COFF and MachO object files for different architectures
# containing all relocations:
#

View File

@ -22,6 +22,8 @@ Other options:
--host host_name - host name to bind server to (127.0.0.1)
'''
from __future__ import print_function
import argparse
import http.server
import json

View File

@ -8,10 +8,13 @@
#the comments
#10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
#than removing all lines for which the lable CONTAINS %tmp.#
from __future__ import print_function
import re
import sys
if( len(sys.argv) < 3 ):
print 'usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>'
print('usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>')
sys.exit(1)
#get a file object
input = open(sys.argv[1], 'r')

View File

@ -25,14 +25,16 @@
#currently the script prints the names it is searching for
#to STDOUT, so you can check to see if they are what you intend
from __future__ import print_function
import re
import string
import sys
if len(sys.argv) < 3:
print 'usage is ./DSAextract <dot_file_to_modify> \
<output_file> [list of nodes to extract]'
print('usage is ./DSAextract <dot_file_to_modify> \
<output_file> [list of nodes to extract]')
#open the input file
input = open(sys.argv[1], 'r')
@ -73,7 +75,7 @@ while buffer != '':
#test code
#print '\n'
print node_name_set
print(node_name_set)
#print node_set

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import argparse
import email.mime.multipart
import email.mime.text

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
def analyze_match_table(path):
# Extract the instruction table.
data = open(path).read()
@ -37,10 +39,10 @@ def analyze_match_table(path):
condcode_mnemonics = set(m for m in mnemonics
if 'MCK_CondCode' in mnemonic_flags[m])
noncondcode_mnemonics = mnemonics - condcode_mnemonics
print ' || '.join('Mnemonic == "%s"' % m
for m in ccout_mnemonics)
print ' || '.join('Mnemonic == "%s"' % m
for m in noncondcode_mnemonics)
print(' || '.join('Mnemonic == "%s"' % m
for m in ccout_mnemonics))
print(' || '.join('Mnemonic == "%s"' % m
for m in noncondcode_mnemonics))
def main():
import sys

View File

@ -10,6 +10,8 @@ One good use of this program is to test whether your linear time algorithm is
really behaving linearly.
"""
from __future__ import print_function
import argparse
def main():
parser = argparse.ArgumentParser(description=__doc__)
@ -17,27 +19,27 @@ def main():
help="Number of ladder rungs. Must be a multiple of 2")
args = parser.parse_args()
if (args.rungs % 2) != 0:
print "Rungs must be a multiple of 2"
print("Rungs must be a multiple of 2")
return
print "int ladder(int *foo, int *bar, int x) {"
print("int ladder(int *foo, int *bar, int x) {")
rung1 = xrange(0, args.rungs, 2)
rung2 = xrange(1, args.rungs, 2)
for i in rung1:
print "rung1%d:" % i
print "*foo = x++;"
print("rung1%d:" % i)
print("*foo = x++;")
if i != rung1[-1]:
print "if (*bar) goto rung1%d;" % (i+2)
print "else goto rung2%d;" % (i+1)
print("if (*bar) goto rung1%d;" % (i+2))
print("else goto rung2%d;" % (i+1))
else:
print "goto rung2%d;" % (i+1)
print("goto rung2%d;" % (i+1))
for i in rung2:
print "rung2%d:" % i
print "*foo = x++;"
print("rung2%d:" % i)
print("*foo = x++;")
if i != rung2[-1]:
print "goto rung2%d;" % (i+2)
print("goto rung2%d;" % (i+2))
else:
print "return *foo;"
print "}"
print("return *foo;")
print("}")
if __name__ == '__main__':
main()

View File

@ -4,6 +4,8 @@
# demanglings. Useful for stress testing the demangler against a large corpus
# of inputs.
from __future__ import print_function
import argparse
import functools
import os

View File

@ -4,6 +4,8 @@
# and saves them in individual dot files (one for each plan). Optionally, and
# providing 'dot' is installed, it can also render the dot into a PNG file.
from __future__ import print_function
import sys
import re
import argparse

View File

@ -1,3 +1,5 @@
from __future__ import print_function
import gdb.printing
class Iterator:

View File

@ -10,6 +10,8 @@
dump format.
"""
from __future__ import print_function
import os
import sys
import re
@ -32,8 +34,8 @@ def look_for_indirect(file):
result = re.search('(call|jmp).*\*', line)
if result != None:
# TODO: Perhaps use cxxfilt to demangle functions?
print function
print line
print(function)
print(line)
return
def main(args):

View File

@ -2,6 +2,7 @@
#
# Common lint functions applicable to multiple types of files.
from __future__ import print_function
import re
def VerifyLineLength(filename, lines, max_length):
@ -89,7 +90,7 @@ def RunLintOverAllFiles(linter, filenames):
for filename in filenames:
file = open(filename, 'r')
if not file:
print 'Cound not open %s' % filename
print('Cound not open %s' % filename)
continue
lines = file.readlines()
lint.extend(linter.RunOnFile(filename, lines))

View File

@ -6,6 +6,7 @@
# TODO: add unittests for the verifier functions:
# http://docs.python.org/library/unittest.html .
from __future__ import print_function
import common_lint
import re
import sys
@ -86,7 +87,7 @@ class CppLint(common_lint.BaseLint):
def CppLintMain(filenames):
all_lint = common_lint.RunLintOverAllFiles(CppLint(), filenames)
for lint in all_lint:
print '%s:%d:%s' % (lint[0], lint[1], lint[2])
print('%s:%d:%s' % (lint[0], lint[1], lint[2]))
return 0

View File

@ -1,3 +1,5 @@
from __future__ import print_function
import errno
import itertools
import math

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python
from __future__ import print_statement
import os
sorted_environment = sorted(os.environ.items())
for name,value in sorted_environment:
print name,'=',value
print(name,'=',value)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys

View File

@ -2,7 +2,7 @@
Descriptor objects for entities that are part of the LLVM project.
"""
from __future__ import absolute_import
from __future__ import absolute_import, print_function
try:
import configparser
except:
@ -461,8 +461,8 @@ def _read_components_from_parser(parser, path, subpath):
info = type_class.parse(subpath,
IniFormatParser(parser.items(section)))
except TypeError:
print >>sys.stderr, "error: invalid component %r in %r: %s" % (
section, path, "unable to instantiate: %r" % type_name)
print("error: invalid component %r in %r: %s" % (
section, path, "unable to instantiate: %r" % type_name), file=sys.stderr)
import traceback
traceback.print_exc()
raise SystemExit(1)

View File

@ -5,6 +5,7 @@ Summarize the information in the given coverage files.
Emits the number of rules covered or the percentage of rules covered depending
on whether --num-rules has been used to specify the total number of rules.
"""
from __future__ import print_function
import argparse
import struct
@ -59,9 +60,9 @@ def main():
num_rules = dict(args.num_rules)
for backend, rules_for_backend in covered_rules.items():
if backend in num_rules:
print "%s: %3.2f%% of rules covered" % (backend, (float(len(rules_for_backend.keys())) / num_rules[backend]) * 100)
print("%s: %3.2f%% of rules covered" % (backend, float(len(rules_for_backend)) / num_rules[backend]) * 100))
else:
print "%s: %d rules covered" % (backend, len(rules_for_backend.keys()))
print("%s: %d rules covered" % (backend, len(rules_for_backend)))
if __name__ == '__main__':
main()

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
import re, string, sys, os, time
DEBUG = 0
@ -22,12 +24,12 @@ def parse(file):
fname = ''
for t in r:
if DEBUG:
print t
print(t)
if t[0] == 'PASS' or t[0] == 'FAIL' :
tmp = t[2].split(testDirName)
if DEBUG:
print tmp
print(tmp)
if len(tmp) == 2:
fname = tmp[1].strip('\r\n')
@ -41,26 +43,26 @@ def parse(file):
test[fname][k] = 'NA'
test[fname][t[1]] = t[0]
if DEBUG:
print test[fname][t[1]]
print(test[fname][t[1]])
else :
try:
n = t[0].split('RESULT-')[1]
if DEBUG:
print n;
print(n);
if n == 'llc' or n == 'jit-comptime' or n == 'compile':
test[fname][tp + n] = float(t[2].split(' ')[2])
if DEBUG:
print test[fname][tp + n]
print(test[fname][tp + n])
elif n.endswith('-time') :
test[fname][exp + n] = float(t[2].strip('\r\n'))
if DEBUG:
print test[fname][exp + n]
print(test[fname][exp + n])
else :
print "ERROR!"
print("ERROR!")
sys.exit(1)
except:
@ -73,7 +75,7 @@ def diffResults(d_old, d_new):
for t in sorted(d_old.keys()) :
if DEBUG:
print t
print(t)
if d_new.has_key(t) :
@ -83,42 +85,42 @@ def diffResults(d_old, d_new):
if d_new[t].has_key(x):
if d_old[t][x] == 'PASS':
if d_new[t][x] != 'PASS':
print t + " *** REGRESSION (" + x + ")\n"
print(t + " *** REGRESSION (" + x + ")\n")
else:
if d_new[t][x] == 'PASS':
print t + " * NEW PASS (" + x + ")\n"
print(t + " * NEW PASS (" + x + ")\n")
else :
print t + "*** REGRESSION (" + x + ")\n"
print(t + "*** REGRESSION (" + x + ")\n")
# For execution time, if there is no result, its a fail.
for x in exectime:
if d_old[t].has_key(tp + x):
if not d_new[t].has_key(tp + x):
print t + " *** REGRESSION (" + tp + x + ")\n"
print(t + " *** REGRESSION (" + tp + x + ")\n")
else :
if d_new[t].has_key(tp + x):
print t + " * NEW PASS (" + tp + x + ")\n"
print(t + " * NEW PASS (" + tp + x + ")\n")
for x in comptime:
if d_old[t].has_key(exp + x):
if not d_new[t].has_key(exp + x):
print t + " *** REGRESSION (" + exp + x + ")\n"
print(t + " *** REGRESSION (" + exp + x + ")\n")
else :
if d_new[t].has_key(exp + x):
print t + " * NEW PASS (" + exp + x + ")\n"
print(t + " * NEW PASS (" + exp + x + ")\n")
else :
print t + ": Removed from test-suite.\n"
print(t + ": Removed from test-suite.\n")
#Main
if len(sys.argv) < 3 :
print 'Usage:', sys.argv[0], \
'<old log> <new log>'
print('Usage:', sys.argv[0], \
'<old log> <new log>')
sys.exit(-1)
d_old = parse(sys.argv[1])

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
import re, string, sys, os, time, math
DEBUG = 0
@ -18,13 +20,13 @@ def parse(file):
fname = ''
for t in r:
if DEBUG:
print t
print(t)
if t[0] == 'PASS' or t[0] == 'FAIL' :
tmp = t[2].split('llvm-test/')
if DEBUG:
print tmp
print(tmp)
if len(tmp) == 2:
fname = tmp[1].strip('\r\n')
@ -41,7 +43,7 @@ def parse(file):
n = t[0].split('RESULT-')[1]
if DEBUG:
print "n == ", n;
print("n == ", n);
if n == 'compile-success':
test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
@ -49,7 +51,7 @@ def parse(file):
elif n == 'exec-success':
test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
if DEBUG:
print test[fname][string.replace(n, '-success', '')]
print(test[fname][string.replace(n, '-success', '')])
else :
# print "ERROR!"
@ -120,36 +122,36 @@ def diffResults(d_old, d_new):
removed += t + "\n"
if len(regressions['compile state']) != 0:
print 'REGRESSION: Compilation Failed'
print regressions['compile state']
print('REGRESSION: Compilation Failed')
print(regressions['compile state'])
if len(regressions['exec state']) != 0:
print 'REGRESSION: Execution Failed'
print regressions['exec state']
print('REGRESSION: Execution Failed')
print(regressions['exec state'])
if len(regressions['compile time']) != 0:
print 'REGRESSION: Compilation Time'
print regressions['compile time']
print('REGRESSION: Compilation Time')
print(regressions['compile time'])
if len(regressions['exec time']) != 0:
print 'REGRESSION: Execution Time'
print regressions['exec time']
print('REGRESSION: Execution Time')
print(regressions['exec time'])
if len(passes['compile state']) != 0:
print 'NEW PASSES: Compilation'
print passes['compile state']
print('NEW PASSES: Compilation')
print(passes['compile state'])
if len(passes['exec state']) != 0:
print 'NEW PASSES: Execution'
print passes['exec state']
print('NEW PASSES: Execution')
print(passes['exec state'])
if len(removed) != 0:
print 'REMOVED TESTS'
print removed
print('REMOVED TESTS')
print(removed)
# Main
if len(sys.argv) < 3 :
print 'Usage:', sys.argv[0], '<old log> <new log>'
print('Usage:', sys.argv[0], '<old log> <new log>')
sys.exit(-1)
d_old = parse(sys.argv[1])

View File

@ -13,6 +13,8 @@ set of transforms you want to test, and run the program. If it crashes, it found
a bug.
"""
from __future__ import print_function
import argparse
import itertools
import random
@ -109,13 +111,13 @@ def main():
if args.verbose:
# Print out the shuffle sequence in a compact form.
print >>sys.stderr, ('Testing shuffle sequence "%s" (v%d%s):' %
(args.seed, width, element_type))
print(('Testing shuffle sequence "%s" (v%d%s):' %
(args.seed, width, element_type)), file=sys.stderr)
for i, shuffles in enumerate(shuffle_tree):
print >>sys.stderr, ' tree level %d:' % (i,)
print(' tree level %d:' % (i,), file=sys.stderr)
for j, s in enumerate(shuffles):
print >>sys.stderr, ' shuffle %d: %s' % (j, s)
print >>sys.stderr, ''
print(' shuffle %d: %s' % (j, s), file=sys.stderr)
print('', file=sys.stderr)
# Symbolically evaluate the shuffle tree.
inputs = [[int(j % element_modulus)
@ -128,15 +130,15 @@ def main():
for j in s]
for i, s in enumerate(shuffles)]
if len(results) != 1:
print >>sys.stderr, 'ERROR: Bad results: %s' % (results,)
print('ERROR: Bad results: %s' % (results,), file=sys.stderr)
sys.exit(1)
result = results[0]
if args.verbose:
print >>sys.stderr, 'Which transforms:'
print >>sys.stderr, ' from: %s' % (inputs,)
print >>sys.stderr, ' into: %s' % (result,)
print >>sys.stderr, ''
print('Which transforms:', file=sys.stderr)
print(' from: %s' % (inputs,), file=sys.stderr)
print(' into: %s' % (result,), file=sys.stderr)
print('', file=sys.stderr)
# The IR uses silly names for floating point types. We also need a same-size
# integer type.
@ -150,25 +152,25 @@ def main():
# Now we need to generate IR for the shuffle function.
subst = {'N': width, 'T': element_type, 'IT': integral_element_type}
print """
print("""
define internal fastcc <%(N)d x %(T)s> @test(%(arguments)s) noinline nounwind {
entry:""" % dict(subst,
arguments=', '.join(
['<%(N)d x %(T)s> %%s.0.%(i)d' % dict(subst, i=i)
for i in xrange(args.max_shuffle_height + 1)]))
for i in xrange(args.max_shuffle_height + 1)])))
for i, shuffles in enumerate(shuffle_tree):
for j, s in enumerate(shuffles):
print """
print("""
%%s.%(next_i)d.%(j)d = shufflevector <%(N)d x %(T)s> %%s.%(i)d.%(j)d, <%(N)d x %(T)s> %%s.%(i)d.%(next_j)d, <%(N)d x i32> <%(S)s>
""".strip('\n') % dict(subst, i=i, next_i=i + 1, j=j, next_j=j + 1,
S=', '.join(['i32 ' + (str(si) if si != -1 else 'undef')
for si in s]))
for si in s])))
print """
print("""
ret <%(N)d x %(T)s> %%s.%(i)d.0
}
""" % dict(subst, i=len(shuffle_tree))
""" % dict(subst, i=len(shuffle_tree)))
# Generate some string constants that we can use to report errors.
for i, r in enumerate(result):
@ -176,24 +178,24 @@ entry:""" % dict(subst,
s = ('FAIL(%(seed)s): lane %(lane)d, expected %(result)d, found %%d\n\\0A' %
{'seed': args.seed, 'lane': i, 'result': r})
s += ''.join(['\\00' for _ in itertools.repeat(None, 128 - len(s) + 2)])
print """
print("""
@error.%(i)d = private unnamed_addr global [128 x i8] c"%(s)s"
""".strip() % {'i': i, 's': s}
""".strip() % {'i': i, 's': s})
# Define a wrapper function which is marked 'optnone' to prevent
# interprocedural optimizations from deleting the test.
print """
print("""
define internal fastcc <%(N)d x %(T)s> @test_wrapper(%(arguments)s) optnone noinline {
%%result = call fastcc <%(N)d x %(T)s> @test(%(arguments)s)
ret <%(N)d x %(T)s> %%result
}
""" % dict(subst,
arguments=', '.join(['<%(N)d x %(T)s> %%s.%(i)d' % dict(subst, i=i)
for i in xrange(args.max_shuffle_height + 1)]))
for i in xrange(args.max_shuffle_height + 1)])))
# Finally, generate a main function which will trap if any lanes are mapped
# incorrectly (in an observable way).
print """
print("""
define i32 @main() {
entry:
; Create a scratch space to print error messages.
@ -212,18 +214,18 @@ entry:
'(<%(N)d x %(IT)s> <%(input)s> to <%(N)d x %(T)s>)' %
dict(subst, input=', '.join(['%(IT)s %(i)d' % dict(subst, i=i)
for i in input])))
for input in inputs]))
for input in inputs])))
# Test that each non-undef result lane contains the expected value.
for i, r in enumerate(result):
if r == -1:
print """
print("""
test.%(i)d:
; Skip this lane, its value is undef.
br label %%test.%(next_i)d
""" % dict(subst, i=i, next_i=i + 1)
""" % dict(subst, i=i, next_i=i + 1))
else:
print """
print("""
test.%(i)d:
%%v.%(i)d = extractelement <%(N)d x %(IT)s> %%v.cast, i32 %(i)d
%%cmp.%(i)d = icmp ne %(IT)s %%v.%(i)d, %(r)d
@ -238,9 +240,9 @@ die.%(i)d:
call i32 @write(i32 2, i8* %%str.ptr, i32 %%length.%(i)d)
call void @llvm.trap()
unreachable
""" % dict(subst, i=i, next_i=i + 1, r=r)
""" % dict(subst, i=i, next_i=i + 1, r=r))
print """
print("""
test.%d:
ret i32 0
}
@ -249,7 +251,7 @@ declare i32 @strlen(i8*)
declare i32 @write(i32, i8*, i32)
declare i32 @sprintf(i8*, i8*, ...)
declare void @llvm.trap() noreturn nounwind
""" % (len(result),)
""" % (len(result),))
if __name__ == '__main__':
main()

View File

@ -13,6 +13,7 @@ Take the output IR printed to stdout, compile it to an executable using whatever
set of transforms you want to test, and run the program. If it crashes, it found
a bug (an error message with the expected and actual result is printed).
"""
from __future__ import print_function
import random
import uuid
@ -145,7 +146,7 @@ class ShufInstr(Instruction):
def calc_value(self):
if self.value != None:
print 'Trying to calculate the value of a shuffle instruction twice'
print('Trying to calculate the value of a shuffle instruction twice')
exit(1)
result = []
@ -179,7 +180,7 @@ class SelectInstr(Instruction):
def calc_value(self):
if self.value != None:
print 'Trying to calculate the value of a select instruction twice'
print('Trying to calculate the value of a select instruction twice')
exit(1)
result = []
@ -343,7 +344,7 @@ def main():
help='Choose specific number of vector elements to be tested. (default: random)')
args = parser.parse_args()
print '; The seed used for this test is ' + args.seed
print('; The seed used for this test is ' + args.seed)
assert args.min_num_inputs < args.max_num_inputs , "Minimum value greater than maximum."
assert args.type in [None, 'i8', 'i16', 'i32', 'i64', 'f32', 'f64'], "Illegal type."
@ -362,14 +363,14 @@ def main():
# print the actual test function by dumping the generated instructions.
insts_str = ''.join([inst.dump() for inst in insts])
print test_template.format(ty = ty.dump(), inputs = inputs_str,
instructions = insts_str, last_name = res.name)
print(test_template.format(ty = ty.dump(), inputs = inputs_str,
instructions = insts_str, last_name = res.name))
# Print the error message templates as global strings
for i in range(len(res.value)):
pad = ''.join(['\\00']*(31 - len(str(i)) - len(str(res.value[i]))))
print error_template.format(lane = str(i), exp = str(res.value[i]),
padding = pad)
print(error_template.format(lane = str(i), exp = str(res.value[i]),
padding = pad))
# Prepare the runtime checks and failure handlers.
scalar_ty = ty.get_scalar_type()
@ -395,7 +396,7 @@ def main():
inputs_values = [', '.join([scalar_ty.dump() + ' ' + str(i) for i in inp]) for inp in inputs_values]
inputs = ', '.join([ty.dump() + ' <' + inp + '>' for inp in inputs_values])
print main_template.format(ty = ty.dump(), inputs = inputs, check_die = check_die)
print(main_template.format(ty = ty.dump(), inputs = inputs, check_die = check_die))
if __name__ == '__main__':

View File

@ -17,6 +17,8 @@ Right now this generates a function which implements simple case folding (C+S
entries).
"""
from __future__ import print_function
import sys
import re
import urllib2
@ -116,22 +118,22 @@ f.close()
dump_block(current_block)
print '//===---------- Support/UnicodeCaseFold.cpp -------------------------------===//'
print '//'
print '// This file was generated by utils/unicode-case-fold.py from the Unicode'
print '// case folding database at'
print '// ', sys.argv[1]
print '//'
print '// To regenerate this file, run:'
print '// utils/unicode-case-fold.py \\'
print '// "{}" \\'.format(sys.argv[1])
print '// > lib/Support/UnicodeCaseFold.cpp'
print '//'
print '//===----------------------------------------------------------------------===//'
print ''
print '#include "llvm/Support/Unicode.h"'
print ''
print "int llvm::sys::unicode::foldCharSimple(int C) {"
print body
print " return C;"
print "}"
print('//===---------- Support/UnicodeCaseFold.cpp -------------------------------===//')
print('//')
print('// This file was generated by utils/unicode-case-fold.py from the Unicode')
print('// case folding database at')
print('// ', sys.argv[1])
print('//')
print('// To regenerate this file, run:')
print('// utils/unicode-case-fold.py \\')
print('// "{}" \\'.format(sys.argv[1]))
print('// > lib/Support/UnicodeCaseFold.cpp')
print('//')
print('//===----------------------------------------------------------------------===//')
print('')
print('#include "llvm/Support/Unicode.h"')
print('')
print("int llvm::sys::unicode::foldCharSimple(int C) {")
print(body)
print(" return C;")
print("}")

View File

@ -29,6 +29,8 @@ The script is designed to make adding checks to a test case fast, it is *not*
designed to be authoratitive about what constitutes a good test!
"""
from __future__ import print_function
import argparse
import itertools
import os # Used to advertise this file's name ("autogenerated_note").
@ -66,12 +68,12 @@ def main():
opt_basename = os.path.basename(args.opt_binary)
if (opt_basename != "opt"):
print >>sys.stderr, 'ERROR: Unexpected opt name: ' + opt_basename
print('ERROR: Unexpected opt name: ' + opt_basename, file=sys.stderr)
sys.exit(1)
for test in args.tests:
if args.verbose:
print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
with open(test) as f:
input_lines = [l.rstrip() for l in f]
@ -85,20 +87,20 @@ def main():
run_lines.append(l)
if args.verbose:
print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
for l in run_lines:
print >>sys.stderr, ' RUN: ' + l
print(' RUN: ' + l, file=sys.stderr)
prefix_list = []
for l in run_lines:
(tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
if not tool_cmd.startswith(opt_basename + ' '):
print >>sys.stderr, 'WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l)
print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
continue
if not filecheck_cmd.startswith('FileCheck '):
print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
continue
tool_cmd_args = tool_cmd[len(opt_basename):].strip()
@ -119,8 +121,8 @@ def main():
func_dict.update({prefix: dict()})
for prefixes, opt_args in prefix_list:
if args.verbose:
print >>sys.stderr, 'Extracted opt cmd: ' + opt_basename + ' ' + opt_args
print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
print('Extracted opt cmd: ' + opt_basename + ' ' + opt_args, file=sys.stderr)
print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
raw_tool_outputs = common.invoke_tool(args.opt_binary, opt_args, test)
@ -134,7 +136,7 @@ def main():
is_in_function_start = False
prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
if args.verbose:
print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
output_lines = []
output_lines.append(autogenerated_note)
@ -181,7 +183,7 @@ def main():
is_in_function = is_in_function_start = True
if args.verbose:
print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
with open(test, 'wb') as f:
f.writelines([l + '\n' for l in output_lines])

View File

@ -7,6 +7,8 @@ FileCheck patterns. It can either update all of the tests in the file or
a single test function.
"""
from __future__ import print_function
import argparse
import os # Used to advertise this file's name ("autogenerated_note").
import string
@ -42,7 +44,7 @@ def main():
for test in args.tests:
if args.verbose:
print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
with open(test) as f:
input_lines = [l.rstrip() for l in f]
@ -63,9 +65,9 @@ def main():
run_lines.append(l)
if args.verbose:
print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
for l in run_lines:
print >>sys.stderr, ' RUN: ' + l
print(' RUN: ' + l, file=sys.stderr)
run_list = []
for l in run_lines:
@ -81,11 +83,11 @@ def main():
if len(commands) > 1:
filecheck_cmd = commands[1]
if not llc_cmd.startswith('llc '):
print >>sys.stderr, 'WARNING: Skipping non-llc RUN line: ' + l
print('WARNING: Skipping non-llc RUN line: ' + l, file=sys.stderr)
continue
if not filecheck_cmd.startswith('FileCheck '):
print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
continue
llc_cmd_args = llc_cmd[len('llc'):].strip()
@ -107,12 +109,12 @@ def main():
func_dict.update({prefix: dict()})
for prefixes, llc_args, triple_in_cmd in run_list:
if args.verbose:
print >>sys.stderr, 'Extracted LLC cmd: llc ' + llc_args
print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
print('Extracted LLC cmd: llc ' + llc_args, file=sys.stderr)
print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
raw_tool_output = common.invoke_tool(args.llc_binary, llc_args, test)
if not (triple_in_cmd or triple_in_ir):
print >>sys.stderr, "Cannot find a triple. Assume 'x86'"
print("Cannot find a triple. Assume 'x86'", file=sys.stderr)
asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
triple_in_cmd or triple_in_ir or 'x86', prefixes, func_dict)
@ -122,7 +124,7 @@ def main():
func_name = None
prefix_set = set([prefix for p in run_list for prefix in p[0]])
if args.verbose:
print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
output_lines = []
output_lines.append(autogenerated_note)
@ -167,7 +169,7 @@ def main():
is_in_function = is_in_function_start = True
if args.verbose:
print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
with open(test, 'wb') as f:
f.writelines([l + '\n' for l in output_lines])

View File

@ -29,6 +29,8 @@ The script is designed to make adding checks to a test case fast, it is *not*
designed to be authoratitive about what constitutes a good test!
"""
from __future__ import print_function
import argparse
import itertools
import os # Used to advertise this file's name ("autogenerated_note").
@ -66,12 +68,12 @@ def main():
opt_basename = os.path.basename(args.opt_binary)
if (opt_basename != "opt"):
print >>sys.stderr, 'ERROR: Unexpected opt name: ' + opt_basename
print('ERROR: Unexpected opt name: ' + opt_basename, file=sys.stderr)
sys.exit(1)
for test in args.tests:
if args.verbose:
print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
with open(test) as f:
input_lines = [l.rstrip() for l in f]
@ -85,20 +87,20 @@ def main():
run_lines.append(l)
if args.verbose:
print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
for l in run_lines:
print >>sys.stderr, ' RUN: ' + l
print(' RUN: ' + l, file=sys.stderr)
prefix_list = []
for l in run_lines:
(tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
if not tool_cmd.startswith(opt_basename + ' '):
print >>sys.stderr, 'WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l)
print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
continue
if not filecheck_cmd.startswith('FileCheck '):
print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
continue
tool_cmd_args = tool_cmd[len(opt_basename):].strip()
@ -119,8 +121,8 @@ def main():
func_dict.update({prefix: dict()})
for prefixes, opt_args in prefix_list:
if args.verbose:
print >>sys.stderr, 'Extracted opt cmd: ' + opt_basename + ' ' + opt_args
print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
print('Extracted opt cmd: ' + opt_basename + ' ' + opt_args, file=sys.stderr)
print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
raw_tool_output = common.invoke_tool(args.opt_binary, opt_args, test)
common.build_function_body_dictionary(
@ -131,7 +133,7 @@ def main():
is_in_function_start = False
prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
if args.verbose:
print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
output_lines = []
output_lines.append(autogenerated_note)
@ -178,7 +180,7 @@ def main():
is_in_function = is_in_function_start = True
if args.verbose:
print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
with open(test, 'wb') as f:
f.writelines([l + '\n' for l in output_lines])

View File

@ -20,6 +20,7 @@ limitations:
"""
from __future__ import print_function
import os
code_owners = {}
@ -97,7 +98,7 @@ def find_owners(fpath):
import sys
if len(sys.argv) < 2:
print "usage " + sys.argv[0] + " file_or_folder"
print("usage " + sys.argv[0] + " file_or_folder")
exit(-1)
# the path we are checking
@ -105,13 +106,13 @@ path = str(sys.argv[1])
# check if this is real path
if not os.path.exists(path):
print "path (" + path + ") does not exist"
print("path (" + path + ") does not exist")
exit(-1)
owners_name = find_owners(path)
# be grammatically correct
print "The owner(s) of the (" + path + ") is(are) : " + str(owners_name)
print("The owner(s) of the (" + path + ") is(are) : " + str(owners_name))
exit(0)
@ -119,7 +120,7 @@ exit(0)
# not yet used
root = "."
for dir,subdirList,fileList in os.walk( root , topdown=False ) :
print "dir :" , dir
print("dir :" , dir)
for fname in fileList :
print "-" , fname
print
print("-" , fname)
print()