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
diff --git a/llvm/test/CodeGen/NVPTX/ld-st-addrrspace.py b/llvm/test/CodeGen/NVPTX/ld-st-addrrspace.py
index c944066..7c28620 100644
--- a/llvm/test/CodeGen/NVPTX/ld-st-addrrspace.py
+++ b/llvm/test/CodeGen/NVPTX/ld-st-addrrspace.py
@@ -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
 
diff --git a/llvm/test/CodeGen/NVPTX/wmma.py b/llvm/test/CodeGen/NVPTX/wmma.py
index bec5a27..14bbfd7 100644
--- a/llvm/test/CodeGen/NVPTX/wmma.py
+++ b/llvm/test/CodeGen/NVPTX/wmma.py
@@ -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
 
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-01.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-01.py
index 344d261..e66042d 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-01.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-01.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-02.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-02.py
index 7f7b099..4566d97 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-02.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-02.py
@@ -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 @@
     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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-03.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-03.py
index 75c9ea4..16fcbe7 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-03.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-03.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-04.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-04.py
index d475c95..2b22f75 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-04.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-04.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-05.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-05.py
index 0a56eff..8f85a32 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-05.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-05.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-06.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-06.py
index 5b05434..7f1fce3 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-06.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-06.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-07.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-07.py
index c5fef10..03764c6 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-07.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-07.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-08.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-08.py
index 8b6b673..56e3901 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-08.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-08.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-09.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-09.py
index 6b568a6..40bfe31 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-09.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-09.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-10.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-10.py
index c6f8945..0adcaa4 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-10.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-10.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-11.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-11.py
index 10466df..f553b35 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-11.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-11.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/branch-range-12.py b/llvm/test/CodeGen/SystemZ/Large/branch-range-12.py
index 809483a..1cedc6d 100644
--- a/llvm/test/CodeGen/SystemZ/Large/branch-range-12.py
+++ b/llvm/test/CodeGen/SystemZ/Large/branch-range-12.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/spill-01.py b/llvm/test/CodeGen/SystemZ/Large/spill-01.py
index f59f607..2831804 100644
--- a/llvm/test/CodeGen/SystemZ/Large/spill-01.py
+++ b/llvm/test/CodeGen/SystemZ/Large/spill-01.py
@@ -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('}')
diff --git a/llvm/test/CodeGen/SystemZ/Large/spill-02.py b/llvm/test/CodeGen/SystemZ/Large/spill-02.py
index 4ccfa11..f835993 100644
--- a/llvm/test/CodeGen/SystemZ/Large/spill-02.py
+++ b/llvm/test/CodeGen/SystemZ/Large/spill-02.py
@@ -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('}')