llvm.org GIT mirror llvm / 60ccceb
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350307 91177308-0d34-0410-b5e6-96231b3b80d8 Serge Guelton 6 months ago
56 changed file(s) with 594 addition(s) and 489 deletion(s). Raw diff Collapse all Expand all
55 # License. See LICENSE.TXT for details.
66 #
77 #===------------------------------------------------------------------------===#
8 from __future__ import print_function
89
910 from .common import LLVMObject
1011 from .common import c_object_p
604605 ]
605606 for enum_class, enum_spec in enums:
606607 for name, value in enum_spec:
607 print name, value
608 print(name, value)
608609 enum_class.register(name, value)
609610 return enums
610611
0 from __future__ import print_function
1
2 from .base import TestBase
13 from ..core import OpCode
24 from ..core import MemoryBuffer
1012 def test_parse_bitcode(self):
1113 source = self.get_test_bc()
1214 m = parse_bitcode(MemoryBuffer(filename=source))
13 print m.target
14 print m.datalayout
15 print(m.target)
16 print(m.datalayout)
0 from __future__ import print_function
1
2 from .base import TestBase
13 from ..core import MemoryBuffer
24 from ..core import PassRegistry
126128 self.assertEqual(inst.opcode, inst_list[i][1])
127129 for op in range(len(inst)):
128130 o = inst.get_operand(op)
129 print o.name
131 print(o.name)
130132 o.dump()
131133 inst.dump()
132134 i += 1
0 from __future__ import print_function
1
2 from .base import TestBase
13
24 from ..disassembler import Disassembler, Option_UseMarkup
3739 disassembler = Disassembler(triple)
3840 disassembler.set_options(Option_UseMarkup)
3941 count, s = disassembler.get_instruction(sequence)
40 print s
42 print(s)
4143 self.assertEqual(count, 4)
4244 self.assertEqual(s, '\tpush\t{, }')
88 #
99 # All configuration values have a default; values that are commented out
1010 # serve to show the default.
11 from __future__ import print_function
1112
1213 import sys, os
1314 from datetime import date
233234 header = f.readline().rstrip('\n')
234235
235236 if len(header) != len(title):
236 print >>sys.stderr, (
237 print((
237238 "error: invalid header in %r (does not match title)" % (
238 file_subpath,))
239 file_subpath,)), file=sys.stderr)
239240 if ' - ' not in title:
240 print >>sys.stderr, (
241 print((
241242 ("error: invalid title in %r "
242243 "(expected ' - ')") % (
243 file_subpath,))
244 file_subpath,)), file=sys.stderr)
244245
245246 # Split the name out of the title.
246247 name,description = title.split(' - ', 1)
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import sys
35 import random
172174
173175 def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
174176 """ Generate a random Kaleidoscope script based on the given parameters """
175 print "Generating " + filename
177 print("Generating " + filename)
176178 print(" %d functions, %d elements per function, %d functions between execution" %
177179 (numFuncs, elementsPerFunc, funcsBetweenExec))
178180 print(" Call weighting = %f" % callWeighting)
199201 script.writeEmptyLine()
200202 script.writeFinalFunctionCounts()
201203 funcsCalled = len(script.calledFunctions)
202 print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
204 print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
203205 timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
204206
205207 # Execution begins here
215217 for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
216218 filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
217219 generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
218 print "All done!"
220 print("All done!")
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 class TimingScriptGenerator:
35 """Used to generate a bash script which will invoke the toy and time it"""
4648 infile = open(inputname, "r")
4749 libfile = open(libname, "w")
4850 callfile = open(callname, "w")
49 print "Splitting %s into %s and %s" % (inputname, callname, libname)
51 print("Splitting %s into %s and %s" % (inputname, callname, libname))
5052 for line in infile:
5153 if not line.startswith("#"):
5254 if line.startswith("print"):
6668
6769 for script in script_list:
6870 splitScript(script, libGenScript, timingScript)
69 print "All done!"
71 print("All done!")
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import sys
35 import random
177179
178180 def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
179181 """ Generate a random Kaleidoscope script based on the given parameters """
180 print "Generating " + filename
182 print("Generating " + filename)
181183 print(" %d functions, %d elements per function, %d functions between execution" %
182184 (numFuncs, elementsPerFunc, funcsBetweenExec))
183185 print(" Call weighting = %f" % callWeighting)
204206 script.writeEmptyLine()
205207 script.writeFinalFunctionCounts()
206208 funcsCalled = len(script.calledFunctions)
207 print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
209 print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
208210 timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
209211
210212 # Execution begins here
220222 for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
221223 filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
222224 generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
223 print "All done!"
225 print("All done!")
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 class TimingScriptGenerator:
35 """Used to generate a bash script which will invoke the toy and time it"""
4648 infile = open(inputname, "r")
4749 libfile = open(libname, "w")
4850 callfile = open(callname, "w")
49 print "Splitting %s into %s and %s" % (inputname, callname, libname)
51 print("Splitting %s into %s and %s" % (inputname, callname, libname))
5052 for line in infile:
5153 if not line.startswith("#"):
5254 if line.startswith("print"):
6668
6769 for script in script_list:
6870 splitScript(script, libGenScript, timingScript)
69 print "All done!"
71 print("All done!")
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import sys
35 import random
172174
173175 def generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript):
174176 """ Generate a random Kaleidoscope script based on the given parameters """
175 print "Generating " + filename
177 print("Generating " + filename)
176178 print(" %d functions, %d elements per function, %d functions between execution" %
177179 (numFuncs, elementsPerFunc, funcsBetweenExec))
178180 print(" Call weighting = %f" % callWeighting)
199201 script.writeEmptyLine()
200202 script.writeFinalFunctionCounts()
201203 funcsCalled = len(script.calledFunctions)
202 print " Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted)
204 print(" Called %d of %d functions, %d total" % (funcsCalled, numFuncs, script.totalCallsExecuted))
203205 timingScript.writeTimingCall(filename, numFuncs, funcsCalled, script.totalCallsExecuted)
204206
205207 # Execution begins here
215217 for (numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting) in dataSets:
216218 filename = "test-%d-%d-%d-%d.k" % (numFuncs, elementsPerFunc, funcsBetweenExec, int(callWeighting * 100))
217219 generateKScript(filename, numFuncs, elementsPerFunc, funcsBetweenExec, callWeighting, timingScript)
218 print "All done!"
220 print("All done!")
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import sys
35
33 # RUN: python %s > %t.ll
44 # RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,CHECK_P64 %t.ll
55 # RUN: llc < %t.ll -march=nvptx -mcpu=sm_30 | FileCheck -check-prefixes=CHECK,CHECK_P32 %t.ll
6
7 from __future__ import print_function
68
79 from itertools import product
810 from string import Template
22
33 # RUN: python %s > %t.ll
44 # RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx61 | FileCheck %t.ll
5
6 from __future__ import print_function
57
68 from itertools import product
79 from string import Template
6666 # CHECK: c %r4, 136(%r3)
6767 # CHECK: jge [[LABEL]]
6868
69 from __future__ import print_function
70
6971 branch_blocks = 10
7072 main_size = 0xffd8
7173
72 print '@global = global i32 0'
74 print('@global = global i32 0')
7375
74 print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
75 print 'entry:'
76 print ' br label %before0'
77 print ''
76 print('define void @f1(i8 *%base, i32 *%stop, i32 %limit) {')
77 print('entry:')
78 print(' br label %before0')
79 print('')
7880
7981 for i in xrange(branch_blocks):
8082 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
81 print 'before%d:' % i
82 print ' %%bstop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i)
83 print ' %%bcur%d = load i32 , i32 *%%bstop%d' % (i, i)
84 print ' %%btest%d = icmp eq i32 %%limit, %%bcur%d' % (i, i)
85 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
86 print ''
83 print('before%d:' % i)
84 print(' %%bstop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i))
85 print(' %%bcur%d = load i32 , i32 *%%bstop%d' % (i, i))
86 print(' %%btest%d = icmp eq i32 %%limit, %%bcur%d' % (i, i))
87 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
88 print('')
8789
88 print '%s:' % next
90 print('%s:' % next)
8991 a, b = 1, 1
9092 for i in xrange(0, main_size, 6):
9193 a, b = b, a + b
9294 offset = 4096 + b % 500000
9395 value = a % 256
94 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
95 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
96 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
97 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
9698
9799 for i in xrange(branch_blocks):
98 print ' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i + 25)
99 print ' %%acur%d = load i32 , i32 *%%astop%d' % (i, i)
100 print ' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
101 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
102 print ''
103 print 'after%d:' % i
100 print(' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i + 25))
101 print(' %%acur%d = load i32 , i32 *%%astop%d' % (i, i))
102 print(' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i))
103 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
104 print('')
105 print('after%d:' % i)
104106
105 print ' %dummy = load volatile i32, i32 *@global'
106 print ' ret void'
107 print '}'
107 print(' %dummy = load volatile i32, i32 *@global')
108 print(' ret void')
109 print('}')
5555 # CHECK: c %r4, 1036(%r3)
5656 # CHECK: jge [[LABEL]]
5757
58 from __future__ import print_function
59
5860 blocks = 256 + 4
5961
60 print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
61 print 'entry:'
62 print ' br label %b0'
63 print ''
62 print('define void @f1(i8 *%base, i32 *%stop, i32 %limit) {')
63 print('entry:')
64 print(' br label %b0')
65 print('')
6466
6567 a, b = 1, 1
6668 for i in xrange(blocks):
6870 value = a % 256
6971 next = 'b%d' % (i + 1) if i + 1 < blocks else 'end'
7072 other = 'end' if 2 * i < blocks else 'b0'
71 print 'b%d:' % i
72 print ' store volatile i8 %d, i8 *%%base' % value
73 print ' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i)
74 print ' %%acur%d = load i32 , i32 *%%astop%d' % (i, i)
75 print ' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
76 print ' br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next)
73 print('b%d:' % i)
74 print(' store volatile i8 %d, i8 *%%base' % value)
75 print(' %%astop%d = getelementptr i32, i32 *%%stop, i64 %d' % (i, i))
76 print(' %%acur%d = load i32 , i32 *%%astop%d' % (i, i))
77 print(' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i))
78 print(' br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next))
7779
78 print ''
79 print '%s:' % next
80 print ' ret void'
81 print '}'
80 print('')
81 print('%s:' % next)
82 print(' ret void')
83 print('}')
6666 # CHECK: cr %r4, [[REG]]
6767 # CHECK: jge [[LABEL]]
6868
69 from __future__ import print_function
70
6971 branch_blocks = 8
7072 main_size = 0xffcc
7173
72 print '@global = global i32 0'
74 print('@global = global i32 0')
7375
74 print 'define void @f1(i8 *%base, i8 *%stop, i32 %limit) {'
75 print 'entry:'
76 print ' br label %before0'
77 print ''
76 print('define void @f1(i8 *%base, i8 *%stop, i32 %limit) {')
77 print('entry:')
78 print(' br label %before0')
79 print('')
7880
7981 for i in xrange(branch_blocks):
8082 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
81 print 'before%d:' % i
82 print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
83 print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
84 print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
85 print ' %%btest%d = icmp eq i32 %%limit, %%bext%d' % (i, i)
86 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
87 print ''
83 print('before%d:' % i)
84 print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
85 print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
86 print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
87 print(' %%btest%d = icmp eq i32 %%limit, %%bext%d' % (i, i))
88 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
89 print('')
8890
89 print '%s:' % next
91 print('%s:' % next)
9092 a, b = 1, 1
9193 for i in xrange(0, main_size, 6):
9294 a, b = b, a + b
9395 offset = 4096 + b % 500000
9496 value = a % 256
95 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
96 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
97 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
98 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
9799
98100 for i in xrange(branch_blocks):
99 print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
100 print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
101 print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
102 print ' %%atest%d = icmp eq i32 %%limit, %%aext%d' % (i, i)
103 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
104 print ''
105 print 'after%d:' % i
101 print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
102 print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
103 print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
104 print(' %%atest%d = icmp eq i32 %%limit, %%aext%d' % (i, i))
105 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
106 print('')
107 print('after%d:' % i)
106108
107 print ' %dummy = load volatile i32, i32 *@global'
108 print ' ret void'
109 print '}'
109 print(' %dummy = load volatile i32, i32 *@global')
110 print(' ret void')
111 print('}')
7070 # CHECK: cgr %r4, [[REG]]
7171 # CHECK: jge [[LABEL]]
7272
73 from __future__ import print_function
74
7375 branch_blocks = 8
7476 main_size = 0xffcc
7577
76 print '@global = global i32 0'
78 print('@global = global i32 0')
7779
78 print 'define void @f1(i8 *%base, i8 *%stop, i64 %limit) {'
79 print 'entry:'
80 print ' br label %before0'
81 print ''
80 print('define void @f1(i8 *%base, i8 *%stop, i64 %limit) {')
81 print('entry:')
82 print(' br label %before0')
83 print('')
8284
8385 for i in xrange(branch_blocks):
8486 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
85 print 'before%d:' % i
86 print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
87 print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
88 print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
89 print ' %%btest%d = icmp eq i64 %%limit, %%bext%d' % (i, i)
90 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
91 print ''
87 print('before%d:' % i)
88 print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
89 print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
90 print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
91 print(' %%btest%d = icmp eq i64 %%limit, %%bext%d' % (i, i))
92 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
93 print('')
9294
93 print '%s:' % next
95 print('%s:' % next)
9496 a, b = 1, 1
9597 for i in xrange(0, main_size, 6):
9698 a, b = b, a + b
9799 offset = 4096 + b % 500000
98100 value = a % 256
99 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
100 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
101 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
102 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
101103
102104 for i in xrange(branch_blocks):
103 print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
104 print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
105 print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
106 print ' %%atest%d = icmp eq i64 %%limit, %%aext%d' % (i, i)
107 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
108 print ''
109 print 'after%d:' % i
105 print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
106 print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
107 print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
108 print(' %%atest%d = icmp eq i64 %%limit, %%aext%d' % (i, i))
109 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
110 print('')
111 print('after%d:' % i)
110112
111 print ' %dummy = load volatile i32, i32 *@global'
112 print ' ret void'
113 print '}'
113 print(' %dummy = load volatile i32, i32 *@global')
114 print(' ret void')
115 print('}')
7070 # CHECK: chi [[REG]], 107
7171 # CHECK: jgl [[LABEL]]
7272
73 from __future__ import print_function
74
7375 branch_blocks = 8
7476 main_size = 0xffcc
7577
76 print '@global = global i32 0'
78 print('@global = global i32 0')
7779
78 print 'define void @f1(i8 *%base, i8 *%stop) {'
79 print 'entry:'
80 print ' br label %before0'
81 print ''
80 print('define void @f1(i8 *%base, i8 *%stop) {')
81 print('entry:')
82 print(' br label %before0')
83 print('')
8284
8385 for i in xrange(branch_blocks):
8486 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
85 print 'before%d:' % i
86 print ' %%bcur%d = load i8 , i8 *%%stop' % i
87 print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
88 print ' %%btest%d = icmp slt i32 %%bext%d, %d' % (i, i, i + 50)
89 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
90 print ''
87 print('before%d:' % i)
88 print(' %%bcur%d = load i8 , i8 *%%stop' % i)
89 print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
90 print(' %%btest%d = icmp slt i32 %%bext%d, %d' % (i, i, i + 50))
91 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
92 print('')
9193
92 print '%s:' % next
94 print('%s:' % next)
9395 a, b = 1, 1
9496 for i in xrange(0, main_size, 6):
9597 a, b = b, a + b
9698 offset = 4096 + b % 500000
9799 value = a % 256
98 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
99 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
100 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
101 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
100102
101103 for i in xrange(branch_blocks):
102 print ' %%acur%d = load i8 , i8 *%%stop' % i
103 print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
104 print ' %%atest%d = icmp slt i32 %%aext%d, %d' % (i, i, i + 100)
105 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
106 print ''
107 print 'after%d:' % i
104 print(' %%acur%d = load i8 , i8 *%%stop' % i)
105 print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
106 print(' %%atest%d = icmp slt i32 %%aext%d, %d' % (i, i, i + 100))
107 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
108 print('')
109 print('after%d:' % i)
108110
109 print ' %dummy = load volatile i32, i32 *@global'
110 print ' ret void'
111 print '}'
111 print(' %dummy = load volatile i32, i32 *@global')
112 print(' ret void')
113 print('}')
7070 # CHECK: cghi [[REG]], 107
7171 # CHECK: jgl [[LABEL]]
7272
73 from __future__ import print_function
74
7375 branch_blocks = 8
7476 main_size = 0xffcc
7577
76 print '@global = global i32 0'
78 print('@global = global i32 0')
7779
78 print 'define void @f1(i8 *%base, i8 *%stop) {'
79 print 'entry:'
80 print ' br label %before0'
81 print ''
80 print('define void @f1(i8 *%base, i8 *%stop) {')
81 print('entry:')
82 print(' br label %before0')
83 print('')
8284
8385 for i in xrange(branch_blocks):
8486 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
85 print 'before%d:' % i
86 print ' %%bcur%d = load i8 , i8 *%%stop' % i
87 print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
88 print ' %%btest%d = icmp slt i64 %%bext%d, %d' % (i, i, i + 50)
89 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
90 print ''
87 print('before%d:' % i)
88 print(' %%bcur%d = load i8 , i8 *%%stop' % i)
89 print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
90 print(' %%btest%d = icmp slt i64 %%bext%d, %d' % (i, i, i + 50))
91 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
92 print('')
9193
92 print '%s:' % next
94 print('%s:' % next)
9395 a, b = 1, 1
9496 for i in xrange(0, main_size, 6):
9597 a, b = b, a + b
9698 offset = 4096 + b % 500000
9799 value = a % 256
98 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
99 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
100 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
101 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
100102
101103 for i in xrange(branch_blocks):
102 print ' %%acur%d = load i8 , i8 *%%stop' % i
103 print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
104 print ' %%atest%d = icmp slt i64 %%aext%d, %d' % (i, i, i + 100)
105 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
106 print ''
107 print 'after%d:' % i
104 print(' %%acur%d = load i8 , i8 *%%stop' % i)
105 print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
106 print(' %%atest%d = icmp slt i64 %%aext%d, %d' % (i, i, i + 100))
107 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
108 print('')
109 print('after%d:' % i)
108110
109 print ' %dummy = load volatile i32, i32 *@global'
110 print ' ret void'
111 print '}'
111 print(' %dummy = load volatile i32, i32 *@global')
112 print(' ret void')
113 print('}')
3131 # CHECK: ahi {{%r[0-9]+}}, -1
3232 # CHECK: jglh
3333
34 from __future__ import print_function
35
3436 branch_blocks = 8
3537 main_size = 0xffd8
3638
37 print 'define void @f1(i8 *%base, i32 *%counts) {'
38 print 'entry:'
39 print('define void @f1(i8 *%base, i32 *%counts) {')
40 print('entry:')
3941
4042 for i in xrange(branch_blocks - 1, -1, -1):
41 print ' %%countptr%d = getelementptr i32, i32 *%%counts, i64 %d' % (i, i)
42 print ' %%initcount%d = load i32 , i32 *%%countptr%d' % (i, i)
43 print ' br label %%loop%d' % i
43 print(' %%countptr%d = getelementptr i32, i32 *%%counts, i64 %d' % (i, i))
44 print(' %%initcount%d = load i32 , i32 *%%countptr%d' % (i, i))
45 print(' br label %%loop%d' % i)
4446
45 print 'loop%d:' % i
47 print('loop%d:' % i)
4648 block1 = 'entry' if i == branch_blocks - 1 else 'loop%d' % (i + 1)
4749 block2 = 'loop0' if i == 0 else 'after%d' % (i - 1)
48 print (' %%count%d = phi i32 [ %%initcount%d, %%%s ],'
49 ' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2))
50 print((' %%count%d = phi i32 [ %%initcount%d, %%%s ],'
51 ' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2)))
5052
5153 a, b = 1, 1
5254 for i in xrange(0, main_size, 6):
5355 a, b = b, a + b
5456 offset = 4096 + b % 500000
5557 value = a % 256
56 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
57 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
58 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
59 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
5860
5961 for i in xrange(branch_blocks):
60 print ' %%nextcount%d = add i32 %%count%d, -1' % (i, i)
61 print ' %%test%d = icmp ne i32 %%nextcount%d, 0' % (i, i)
62 print ' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i)
63 print ''
64 print 'after%d:' % i
62 print(' %%nextcount%d = add i32 %%count%d, -1' % (i, i))
63 print(' %%test%d = icmp ne i32 %%nextcount%d, 0' % (i, i))
64 print(' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i))
65 print('')
66 print('after%d:' % i)
6567
66 print ' ret void'
67 print '}'
68 print(' ret void')
69 print('}')
3232 # CHECK: aghi {{%r[0-9]+}}, -1
3333 # CHECK: jglh
3434
35 from __future__ import print_function
36
3537 branch_blocks = 8
3638 main_size = 0xffd8
3739
38 print 'define void @f1(i8 *%base, i64 *%counts) {'
39 print 'entry:'
40 print('define void @f1(i8 *%base, i64 *%counts) {')
41 print('entry:')
4042
4143 for i in xrange(branch_blocks - 1, -1, -1):
42 print ' %%countptr%d = getelementptr i64, i64 *%%counts, i64 %d' % (i, i)
43 print ' %%initcount%d = load i64 , i64 *%%countptr%d' % (i, i)
44 print ' br label %%loop%d' % i
44 print(' %%countptr%d = getelementptr i64, i64 *%%counts, i64 %d' % (i, i))
45 print(' %%initcount%d = load i64 , i64 *%%countptr%d' % (i, i))
46 print(' br label %%loop%d' % i)
4547
46 print 'loop%d:' % i
48 print('loop%d:' % i)
4749 block1 = 'entry' if i == branch_blocks - 1 else 'loop%d' % (i + 1)
4850 block2 = 'loop0' if i == 0 else 'after%d' % (i - 1)
49 print (' %%count%d = phi i64 [ %%initcount%d, %%%s ],'
50 ' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2))
51 print((' %%count%d = phi i64 [ %%initcount%d, %%%s ],'
52 ' [ %%nextcount%d, %%%s ]' % (i, i, block1, i, block2)))
5153
5254 a, b = 1, 1
5355 for i in xrange(0, main_size, 6):
5456 a, b = b, a + b
5557 offset = 4096 + b % 500000
5658 value = a % 256
57 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
58 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
59 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
60 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
5961
6062 for i in xrange(branch_blocks):
61 print ' %%nextcount%d = add i64 %%count%d, -1' % (i, i)
62 print ' %%test%d = icmp ne i64 %%nextcount%d, 0' % (i, i)
63 print ' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i)
64 print ''
65 print 'after%d:' % i
63 print(' %%nextcount%d = add i64 %%count%d, -1' % (i, i))
64 print(' %%test%d = icmp ne i64 %%nextcount%d, 0' % (i, i))
65 print(' br i1 %%test%d, label %%loop%d, label %%after%d' % (i, i, i))
66 print('')
67 print('after%d:' % i)
6668
67 print ' ret void'
68 print '}'
69 print(' ret void')
70 print('}')
6666 # CHECK: clr %r4, [[REG]]
6767 # CHECK: jgl [[LABEL]]
6868
69 from __future__ import print_function
70
6971 branch_blocks = 8
7072 main_size = 0xffcc
7173
72 print '@global = global i32 0'
74 print('@global = global i32 0')
7375
74 print 'define void @f1(i8 *%base, i8 *%stop, i32 %limit) {'
75 print 'entry:'
76 print ' br label %before0'
77 print ''
76 print('define void @f1(i8 *%base, i8 *%stop, i32 %limit) {')
77 print('entry:')
78 print(' br label %before0')
79 print('')
7880
7981 for i in xrange(branch_blocks):
8082 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
81 print 'before%d:' % i
82 print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
83 print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
84 print ' %%bext%d = sext i8 %%bcur%d to i32' % (i, i)
85 print ' %%btest%d = icmp ult i32 %%limit, %%bext%d' % (i, i)
86 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
87 print ''
83 print('before%d:' % i)
84 print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
85 print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
86 print(' %%bext%d = sext i8 %%bcur%d to i32' % (i, i))
87 print(' %%btest%d = icmp ult i32 %%limit, %%bext%d' % (i, i))
88 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
89 print('')
8890
89 print '%s:' % next
91 print('%s:' % next)
9092 a, b = 1, 1
9193 for i in xrange(0, main_size, 6):
9294 a, b = b, a + b
9395 offset = 4096 + b % 500000
9496 value = a % 256
95 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
96 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
97 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
98 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
9799
98100 for i in xrange(branch_blocks):
99 print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
100 print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
101 print ' %%aext%d = sext i8 %%acur%d to i32' % (i, i)
102 print ' %%atest%d = icmp ult i32 %%limit, %%aext%d' % (i, i)
103 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
104 print ''
105 print 'after%d:' % i
101 print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
102 print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
103 print(' %%aext%d = sext i8 %%acur%d to i32' % (i, i))
104 print(' %%atest%d = icmp ult i32 %%limit, %%aext%d' % (i, i))
105 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
106 print('')
107 print('after%d:' % i)
106108
107 print ' %dummy = load volatile i32, i32 *@global'
108 print ' ret void'
109 print '}'
109 print(' %dummy = load volatile i32, i32 *@global')
110 print(' ret void')
111 print('}')
7070 # CHECK: clgr %r4, [[REG]]
7171 # CHECK: jgl [[LABEL]]
7272
73 from __future__ import print_function
74
7375 branch_blocks = 8
7476 main_size = 0xffcc
7577
76 print '@global = global i32 0'
78 print('@global = global i32 0')
7779
78 print 'define void @f1(i8 *%base, i8 *%stop, i64 %limit) {'
79 print 'entry:'
80 print ' br label %before0'
81 print ''
80 print('define void @f1(i8 *%base, i8 *%stop, i64 %limit) {')
81 print('entry:')
82 print(' br label %before0')
83 print('')
8284
8385 for i in xrange(branch_blocks):
8486 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
85 print 'before%d:' % i
86 print ' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i)
87 print ' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i)
88 print ' %%bext%d = sext i8 %%bcur%d to i64' % (i, i)
89 print ' %%btest%d = icmp ult i64 %%limit, %%bext%d' % (i, i)
90 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
91 print ''
87 print('before%d:' % i)
88 print(' %%bstop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i))
89 print(' %%bcur%d = load i8 , i8 *%%bstop%d' % (i, i))
90 print(' %%bext%d = sext i8 %%bcur%d to i64' % (i, i))
91 print(' %%btest%d = icmp ult i64 %%limit, %%bext%d' % (i, i))
92 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
93 print('')
9294
93 print '%s:' % next
95 print('%s:' % next)
9496 a, b = 1, 1
9597 for i in xrange(0, main_size, 6):
9698 a, b = b, a + b
9799 offset = 4096 + b % 500000
98100 value = a % 256
99 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
100 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
101 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
102 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
101103
102104 for i in xrange(branch_blocks):
103 print ' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25)
104 print ' %%acur%d = load i8 , i8 *%%astop%d' % (i, i)
105 print ' %%aext%d = sext i8 %%acur%d to i64' % (i, i)
106 print ' %%atest%d = icmp ult i64 %%limit, %%aext%d' % (i, i)
107 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
108 print ''
109 print 'after%d:' % i
105 print(' %%astop%d = getelementptr i8, i8 *%%stop, i64 %d' % (i, i + 25))
106 print(' %%acur%d = load i8 , i8 *%%astop%d' % (i, i))
107 print(' %%aext%d = sext i8 %%acur%d to i64' % (i, i))
108 print(' %%atest%d = icmp ult i64 %%limit, %%aext%d' % (i, i))
109 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
110 print('')
111 print('after%d:' % i)
110112
111 print ' %dummy = load volatile i32, i32 *@global'
112 print ' ret void'
113 print '}'
113 print(' %dummy = load volatile i32, i32 *@global')
114 print(' ret void')
115 print('}')
8686 # CHECK: clfi [[REG]], 107
8787 # CHECK: jgl [[LABEL]]
8888
89 from __future__ import print_function
90
8991 branch_blocks = 8
9092 main_size = 0xffc6
9193
92 print '@global = global i32 0'
94 print('@global = global i32 0')
9395
94 print 'define void @f1(i8 *%base, i32 *%stopa, i32 *%stopb) {'
95 print 'entry:'
96 print ' br label %before0'
97 print ''
96 print('define void @f1(i8 *%base, i32 *%stopa, i32 *%stopb) {')
97 print('entry:')
98 print(' br label %before0')
99 print('')
98100
99101 for i in xrange(branch_blocks):
100102 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
101 print 'before%d:' % i
102 print ' %%bcur%da = load i32 , i32 *%%stopa' % i
103 print ' %%bcur%db = load i32 , i32 *%%stopb' % i
104 print ' %%bsub%d = sub i32 %%bcur%da, %%bcur%db' % (i, i, i)
105 print ' %%btest%d = icmp ult i32 %%bsub%d, %d' % (i, i, i + 50)
106 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
107 print ''
103 print('before%d:' % i)
104 print(' %%bcur%da = load i32 , i32 *%%stopa' % i)
105 print(' %%bcur%db = load i32 , i32 *%%stopb' % i)
106 print(' %%bsub%d = sub i32 %%bcur%da, %%bcur%db' % (i, i, i))
107 print(' %%btest%d = icmp ult i32 %%bsub%d, %d' % (i, i, i + 50))
108 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
109 print('')
108110
109 print '%s:' % next
111 print('%s:' % next)
110112 a, b = 1, 1
111113 for i in xrange(0, main_size, 6):
112114 a, b = b, a + b
113115 offset = 4096 + b % 500000
114116 value = a % 256
115 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
116 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
117 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
118 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
117119
118120 for i in xrange(branch_blocks):
119 print ' %%acur%da = load i32 , i32 *%%stopa' % i
120 print ' %%acur%db = load i32 , i32 *%%stopb' % i
121 print ' %%asub%d = sub i32 %%acur%da, %%acur%db' % (i, i, i)
122 print ' %%atest%d = icmp ult i32 %%asub%d, %d' % (i, i, i + 100)
123 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
124 print ''
125 print 'after%d:' % i
121 print(' %%acur%da = load i32 , i32 *%%stopa' % i)
122 print(' %%acur%db = load i32 , i32 *%%stopb' % i)
123 print(' %%asub%d = sub i32 %%acur%da, %%acur%db' % (i, i, i))
124 print(' %%atest%d = icmp ult i32 %%asub%d, %d' % (i, i, i + 100))
125 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
126 print('')
127 print('after%d:' % i)
126128
127 print ' %dummy = load volatile i32, i32 *@global'
128 print ' ret void'
129 print '}'
129 print(' %dummy = load volatile i32, i32 *@global')
130 print(' ret void')
131 print('}')
8686 # CHECK: clgfi [[REG]], 107
8787 # CHECK: jgl [[LABEL]]
8888
89 from __future__ import print_function
90
8991 branch_blocks = 8
9092 main_size = 0xffb4
9193
92 print '@global = global i32 0'
94 print('@global = global i32 0')
9395
94 print 'define void @f1(i8 *%base, i64 *%stopa, i64 *%stopb) {'
95 print 'entry:'
96 print ' br label %before0'
97 print ''
96 print('define void @f1(i8 *%base, i64 *%stopa, i64 *%stopb) {')
97 print('entry:')
98 print(' br label %before0')
99 print('')
98100
99101 for i in xrange(branch_blocks):
100102 next = 'before%d' % (i + 1) if i + 1 < branch_blocks else 'main'
101 print 'before%d:' % i
102 print ' %%bcur%da = load i64 , i64 *%%stopa' % i
103 print ' %%bcur%db = load i64 , i64 *%%stopb' % i
104 print ' %%bsub%d = sub i64 %%bcur%da, %%bcur%db' % (i, i, i)
105 print ' %%btest%d = icmp ult i64 %%bsub%d, %d' % (i, i, i + 50)
106 print ' br i1 %%btest%d, label %%after0, label %%%s' % (i, next)
107 print ''
103 print('before%d:' % i)
104 print(' %%bcur%da = load i64 , i64 *%%stopa' % i)
105 print(' %%bcur%db = load i64 , i64 *%%stopb' % i)
106 print(' %%bsub%d = sub i64 %%bcur%da, %%bcur%db' % (i, i, i))
107 print(' %%btest%d = icmp ult i64 %%bsub%d, %d' % (i, i, i + 50))
108 print(' br i1 %%btest%d, label %%after0, label %%%s' % (i, next))
109 print('')
108110
109 print '%s:' % next
111 print('%s:' % next)
110112 a, b = 1, 1
111113 for i in xrange(0, main_size, 6):
112114 a, b = b, a + b
113115 offset = 4096 + b % 500000
114116 value = a % 256
115 print ' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset)
116 print ' store volatile i8 %d, i8 *%%ptr%d' % (value, i)
117 print(' %%ptr%d = getelementptr i8, i8 *%%base, i64 %d' % (i, offset))
118 print(' store volatile i8 %d, i8 *%%ptr%d' % (value, i))
117119
118120 for i in xrange(branch_blocks):
119 print ' %%acur%da = load i64 , i64 *%%stopa' % i
120 print ' %%acur%db = load i64 , i64 *%%stopb' % i
121 print ' %%asub%d = sub i64 %%acur%da, %%acur%db' % (i, i, i)
122 print ' %%atest%d = icmp ult i64 %%asub%d, %d' % (i, i, i + 100)
123 print ' br i1 %%atest%d, label %%main, label %%after%d' % (i, i)
124 print ''
125 print 'after%d:' % i
121 print(' %%acur%da = load i64 , i64 *%%stopa' % i)
122 print(' %%acur%db = load i64 , i64 *%%stopb' % i)
123 print(' %%asub%d = sub i64 %%acur%da, %%acur%db' % (i, i, i))
124 print(' %%atest%d = icmp ult i64 %%asub%d, %d' % (i, i, i + 100))
125 print(' br i1 %%atest%d, label %%main, label %%after%d' % (i, i))
126 print('')
127 print('after%d:' % i)
126128
127 print ' %dummy = load volatile i32, i32 *@global'
128 print ' ret void'
129 print '}'
129 print(' %dummy = load volatile i32, i32 *@global')
130 print(' ret void')
131 print('}')
1717 # CHECK: lay [[REG:%r[0-5]]], 4096(%r15)
1818 # CHECK: mvc {{[0-9]+}}(8,{{%r[0-9]+}}), 8([[REG]])
1919 # CHECK: br %r14
20
21 from __future__ import print_function
22
2023 count = 500
2124
22 print 'declare void @foo()'
23 print ''
24 print 'define void @f1(i64 *%base0, i64 *%base1) {'
25 print('declare void @foo()')
26 print('')
27 print('define void @f1(i64 *%base0, i64 *%base1) {')
2528
2629 for i in range(count):
27 print ' %%ptr%d = getelementptr i64, i64 *%%base%d, i64 %d' % (i, i % 2, i / 2)
28 print ' %%val%d = load i64 , i64 *%%ptr%d' % (i, i)
29 print ''
30 print(' %%ptr%d = getelementptr i64, i64 *%%base%d, i64 %d' % (i, i % 2, i / 2))
31 print(' %%val%d = load i64 , i64 *%%ptr%d' % (i, i))
32 print('')
3033
31 print ' call void @foo()'
32 print ''
34 print(' call void @foo()')
35 print('')
3336
3437 for i in range(count):
35 print ' store i64 %%val%d, i64 *%%ptr%d' % (i, i)
38 print(' store i64 %%val%d, i64 *%%ptr%d' % (i, i))
3639
37 print ''
38 print ' ret void'
39 print '}'
40 print('')
41 print(' ret void')
42 print('}')
1818 # the first 8168 bytes to be used for the call. 160 of these bytes are
1919 # allocated for the ABI frame. There are also 5 argument registers, one of
2020 # which is used as a base pointer.
21
22 from __future__ import print_function
23
2124 args = (8168 - 160) / 8 + (5 - 1)
2225
23 print 'declare i64 *@foo(i64 *%s)' % (', i64' * args)
24 print 'declare void @bar(i64 *)'
25 print ''
26 print 'define i64 @f1(i64 %foo) {'
27 print 'entry:'
26 print('declare i64 *@foo(i64 *%s)' % (', i64' * args))
27 print('declare void @bar(i64 *)')
28 print('')
29 print('define i64 @f1(i64 %foo) {')
30 print('entry:')
2831
2932 # Make the allocation big, so that it goes at the top of the frame.
30 print ' %array = alloca [1000 x i64]'
31 print ' %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0'
32 print ' %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args)
33 print ''
33 print(' %array = alloca [1000 x i64]')
34 print(' %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0')
35 print(' %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args))
36 print('')
3437
3538 # Make sure all GPRs are used. One is needed for the stack pointer and
3639 # another for %base, so we need 14 live values.
3740 count = 14
3841 for i in range(count):
39 print ' %%ptr%d = getelementptr i64, i64 *%%base, i64 %d' % (i, i / 2)
40 print ' %%val%d = load volatile i64 , i64 *%%ptr%d' % (i, i)
41 print ''
42 print(' %%ptr%d = getelementptr i64, i64 *%%base, i64 %d' % (i, i / 2))
43 print(' %%val%d = load volatile i64 , i64 *%%ptr%d' % (i, i))
44 print('')
4245
4346 # Encourage the register allocator to give preference to these %vals
4447 # by using them several times.
4548 for j in range(4):
4649 for i in range(count):
47 print ' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
48 print ''
50 print(' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i))
51 print('')
4952
5053 # Copy the incoming argument, which we expect to be spilled, to the frame
5154 # index for the alloca area. Also throw in a volatile store, so that this
5255 # block cannot be reordered with the surrounding code.
53 print ' %cond = icmp eq i64 %val0, %val1'
54 print ' br i1 %cond, label %skip, label %fallthru'
55 print ''
56 print 'fallthru:'
57 print ' store i64 %foo, i64 *%area'
58 print ' store volatile i64 %val0, i64 *%ptr0'
59 print ' br label %skip'
60 print ''
61 print 'skip:'
56 print(' %cond = icmp eq i64 %val0, %val1')
57 print(' br i1 %cond, label %skip, label %fallthru')
58 print('')
59 print('fallthru:')
60 print(' store i64 %foo, i64 *%area')
61 print(' store volatile i64 %val0, i64 *%ptr0')
62 print(' br label %skip')
63 print('')
64 print('skip:')
6265
6366 # Use each %val a few more times to emphasise the point, and to make sure
6467 # that they are live across the store of %foo.
6568 for j in range(4):
6669 for i in range(count):
67 print ' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
68 print ''
70 print(' store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i))
71 print('')
6972
70 print ' call void @bar(i64 *%area)'
71 print ' ret i64 0'
72 print '}'
73 print(' call void @bar(i64 *%area)')
74 print(' ret i64 0')
75 print('}')
0 # RUN: python %s | llvm-mc -filetype=obj -triple i686-pc-win32 - | llvm-readobj -h | FileCheck %s
1
2 from __future__ import print_function
13
24 # This test checks that the COFF object emitter can produce objects with
35 # more than 65279 sections.
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import os
35 import sys
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 # Generates ELF, COFF and MachO object files for different architectures
35 # containing all relocations:
2020 --port port_number - specifies the port to use (8001)
2121 --host host_name - host name to bind server to (127.0.0.1)
2222 '''
23
24 from __future__ import print_function
2325
2426 import argparse
2527 import http.server
77 #the comments
88 #10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
99 #than removing all lines for which the lable CONTAINS %tmp.#
10
11 from __future__ import print_function
12
1013 import re
1114 import sys
1215 if( len(sys.argv) < 3 ):
13 print 'usage is: ./DSAclean '
16 print('usage is: ./DSAclean ')
1417 sys.exit(1)
1518 #get a file object
1619 input = open(sys.argv[1], 'r')
2424 #currently the script prints the names it is searching for
2525 #to STDOUT, so you can check to see if they are what you intend
2626
27 from __future__ import print_function
28
2729 import re
2830 import string
2931 import sys
3032
3133
3234 if len(sys.argv) < 3:
33 print 'usage is ./DSAextract \
34 [list of nodes to extract]'
35 print('usage is ./DSAextract \
36 [list of nodes to extract]')
3537
3638 #open the input file
3739 input = open(sys.argv[1], 'r')
7274 #test code
7375 #print '\n'
7476
75 print node_name_set
77 print(node_name_set)
7678
7779 #print node_set
7880
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import argparse
35 import email.mime.multipart
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 def analyze_match_table(path):
35 # Extract the instruction table.
3638 condcode_mnemonics = set(m for m in mnemonics
3739 if 'MCK_CondCode' in mnemonic_flags[m])
3840 noncondcode_mnemonics = mnemonics - condcode_mnemonics
39 print ' || '.join('Mnemonic == "%s"' % m
40 for m in ccout_mnemonics)
41 print ' || '.join('Mnemonic == "%s"' % m
42 for m in noncondcode_mnemonics)
41 print(' || '.join('Mnemonic == "%s"' % m
42 for m in ccout_mnemonics))
43 print(' || '.join('Mnemonic == "%s"' % m
44 for m in noncondcode_mnemonics))
4345
4446 def main():
4547 import sys
99 really behaving linearly.
1010 """
1111
12 from __future__ import print_function
13
1214 import argparse
1315 def main():
1416 parser = argparse.ArgumentParser(description=__doc__)
1618 help="Number of ladder rungs. Must be a multiple of 2")
1719 args = parser.parse_args()
1820 if (args.rungs % 2) != 0:
19 print "Rungs must be a multiple of 2"
21 print("Rungs must be a multiple of 2")
2022 return
21 print "int ladder(int *foo, int *bar, int x) {"
23 print("int ladder(int *foo, int *bar, int x) {")
2224 rung1 = xrange(0, args.rungs, 2)
2325 rung2 = xrange(1, args.rungs, 2)
2426 for i in rung1:
25 print "rung1%d:" % i
26 print "*foo = x++;"
27 print("rung1%d:" % i)
28 print("*foo = x++;")
2729 if i != rung1[-1]:
28 print "if (*bar) goto rung1%d;" % (i+2)
29 print "else goto rung2%d;" % (i+1)
30 print("if (*bar) goto rung1%d;" % (i+2))
31 print("else goto rung2%d;" % (i+1))
3032 else:
31 print "goto rung2%d;" % (i+1)
33 print("goto rung2%d;" % (i+1))
3234 for i in rung2:
33 print "rung2%d:" % i
34 print "*foo = x++;"
35 print("rung2%d:" % i)
36 print("*foo = x++;")
3537 if i != rung2[-1]:
36 print "goto rung2%d;" % (i+2)
38 print("goto rung2%d;" % (i+2))
3739 else:
38 print "return *foo;"
39 print "}"
40 print("return *foo;")
41 print("}")
4042
4143 if __name__ == '__main__':
4244 main()
22 # symbols in the object file, and collect statistics about failed / crashed
33 # demanglings. Useful for stress testing the demangler against a large corpus
44 # of inputs.
5
6 from __future__ import print_function
57
68 import argparse
79 import functools
22 # This script extracts the VPlan digraphs from the vectoriser debug messages
33 # and saves them in individual dot files (one for each plan). Optionally, and
44 # providing 'dot' is installed, it can also render the dot into a PNG file.
5
6 from __future__ import print_function
57
68 import sys
79 import re
0 from __future__ import print_function
1
2 import gdb.printing
13
24 class Iterator:
88 Depends on llvm-objdump being in your path and is tied to the
99 dump format.
1010 """
11
12 from __future__ import print_function
1113
1214 import os
1315 import sys
3133 result = re.search('(call|jmp).*\*', line)
3234 if result != None:
3335 # TODO: Perhaps use cxxfilt to demangle functions?
34 print function
35 print line
36 print(function)
37 print(line)
3638 return
3739
3840 def main(args):
11 #
22 # Common lint functions applicable to multiple types of files.
33
4 from __future__ import print_function
45 import re
56
67 def VerifyLineLength(filename, lines, max_length):
8889 for filename in filenames:
8990 file = open(filename, 'r')
9091 if not file:
91 print 'Cound not open %s' % filename
92 print('Cound not open %s' % filename)
9293 continue
9394 lines = file.readlines()
9495 lint.extend(linter.RunOnFile(filename, lines))
55 # TODO: add unittests for the verifier functions:
66 # http://docs.python.org/library/unittest.html .
77
8 from __future__ import print_function
89 import common_lint
910 import re
1011 import sys
8586 def CppLintMain(filenames):
8687 all_lint = common_lint.RunLintOverAllFiles(CppLint(), filenames)
8788 for lint in all_lint:
88 print '%s:%d:%s' % (lint[0], lint[1], lint[2])
89 print('%s:%d:%s' % (lint[0], lint[1], lint[2]))
8990 return 0
9091
9192
0 from __future__ import print_function
1
2 import errno
13 import itertools
24 import math
0 #!/usr/bin/env python
11
2 from __future__ import print_statement
23 import os
34
45 sorted_environment = sorted(os.environ.items())
56
67 for name,value in sorted_environment:
7 print name,'=',value
8 print(name,'=',value)
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13
24 import os
35 import sys
11 Descriptor objects for entities that are part of the LLVM project.
22 """
33
4 from __future__ import absolute_import
4 from __future__ import absolute_import, print_function
55 try:
66 import configparser
77 except:
460460 info = type_class.parse(subpath,
461461 IniFormatParser(parser.items(section)))
462462 except TypeError:
463 print >>sys.stderr, "error: invalid component %r in %r: %s" % (
464 section, path, "unable to instantiate: %r" % type_name)
463 print("error: invalid component %r in %r: %s" % (
464 section, path, "unable to instantiate: %r" % type_name), file=sys.stderr)
465465 import traceback
466466 traceback.print_exc()
467467 raise SystemExit(1)
44 Emits the number of rules covered or the percentage of rules covered depending
55 on whether --num-rules has been used to specify the total number of rules.
66 """
7 from __future__ import print_function
78
89 import argparse
910 import struct
5859 num_rules = dict(args.num_rules)
5960 for backend, rules_for_backend in covered_rules.items():
6061 if backend in num_rules:
61 print "%s: %3.2f%% of rules covered" % (backend, (float(len(rules_for_backend.keys())) / num_rules[backend]) * 100)
62 print("%s: %3.2f%% of rules covered" % (backend, float(len(rules_for_backend)) / num_rules[backend]) * 100))
6263 else:
63 print "%s: %d rules covered" % (backend, len(rules_for_backend.keys()))
64 print("%s: %d rules covered" % (backend, len(rules_for_backend)))
6465
6566 if __name__ == '__main__':
6667 main()
0 #!/usr/bin/env python
1 from __future__ import print_function
2
13 import re, string, sys, os, time
24
35 DEBUG = 0
2123 fname = ''
2224 for t in r:
2325 if DEBUG:
24 print t
26 print(t)
2527 if t[0] == 'PASS' or t[0] == 'FAIL' :
2628 tmp = t[2].split(testDirName)
2729
2830 if DEBUG:
29 print tmp
31 print(tmp)
3032
3133 if len(tmp) == 2:
3234 fname = tmp[1].strip('\r\n')
4042 test[fname][k] = 'NA'
4143 test[fname][t[1]] = t[0]
4244 if DEBUG:
43 print test[fname][t[1]]
45 print(test[fname][t[1]])
4446 else :
4547 try:
4648 n = t[0].split('RESULT-')[1]
4749
4850 if DEBUG:
49 print n;
51 print(n);
5052
5153 if n == 'llc' or n == 'jit-comptime' or n == 'compile':
5254 test[fname][tp + n] = float(t[2].split(' ')[2])
5355 if DEBUG:
54 print test[fname][tp + n]
56 print(test[fname][tp + n])
5557
5658 elif n.endswith('-time') :
5759 test[fname][exp + n] = float(t[2].strip('\r\n'))
5860 if DEBUG:
59 print test[fname][exp + n]
61 print(test[fname][exp + n])
6062
6163 else :
62 print "ERROR!"
64 print("ERROR!")
6365 sys.exit(1)
6466
6567 except:
7274
7375 for t in sorted(d_old.keys()) :
7476 if DEBUG:
75 print t
77 print(t)
7678
7779 if d_new.has_key(t) :
7880
8284 if d_new[t].has_key(x):
8385 if d_old[t][x] == 'PASS':
8486 if d_new[t][x] != 'PASS':
85 print t + " *** REGRESSION (" + x + ")\n"
87 print(t + " *** REGRESSION (" + x + ")\n")
8688 else:
8789 if d_new[t][x] == 'PASS':
88 print t + " * NEW PASS (" + x + ")\n"
90 print(t + " * NEW PASS (" + x + ")\n")
8991
9092 else :
91 print t + "*** REGRESSION (" + x + ")\n"
93 print(t + "*** REGRESSION (" + x + ")\n")
9294
9395 # For execution time, if there is no result, its a fail.
9496 for x in exectime:
9597 if d_old[t].has_key(tp + x):
9698 if not d_new[t].has_key(tp + x):
97 print t + " *** REGRESSION (" + tp + x + ")\n"
99 print(t + " *** REGRESSION (" + tp + x + ")\n")
98100
99101 else :
100102 if d_new[t].has_key(tp + x):
101 print t + " * NEW PASS (" + tp + x + ")\n"
103 print(t + " * NEW PASS (" + tp + x + ")\n")
102104
103105
104106 for x in comptime:
105107 if d_old[t].has_key(exp + x):
106108 if not d_new[t].has_key(exp + x):
107 print t + " *** REGRESSION (" + exp + x + ")\n"
109 print(t + " *** REGRESSION (" + exp + x + ")\n")
108110
109111 else :
110112 if d_new[t].has_key(exp + x):
111 print t + " * NEW PASS (" + exp + x + ")\n"
113 print(t + " * NEW PASS (" + exp + x + ")\n")
112114
113115 else :
114 print t + ": Removed from test-suite.\n"
116 print(t + ": Removed from test-suite.\n")
115117
116118
117119 #Main
118120 if len(sys.argv) < 3 :
119 print 'Usage:', sys.argv[0], \
120 ' '
121 print('Usage:', sys.argv[0], \
122 ' ')
121123 sys.exit(-1)
122124
123125 d_old = parse(sys.argv[1])
0 #!/usr/bin/env python
1
2 from __future__ import print_function
13 import re, string, sys, os, time, math
24
35 DEBUG = 0
1719 fname = ''
1820 for t in r:
1921 if DEBUG:
20 print t
22 print(t)
2123
2224 if t[0] == 'PASS' or t[0] == 'FAIL' :
2325 tmp = t[2].split('llvm-test/')
2426
2527 if DEBUG:
26 print tmp
28 print(tmp)
2729
2830 if len(tmp) == 2:
2931 fname = tmp[1].strip('\r\n')
4042 n = t[0].split('RESULT-')[1]
4143
4244 if DEBUG:
43 print "n == ", n;
45 print("n == ", n);
4446
4547 if n == 'compile-success':
4648 test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
4850 elif n == 'exec-success':
4951 test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
5052 if DEBUG:
51 print test[fname][string.replace(n, '-success', '')]
53 print(test[fname][string.replace(n, '-success', '')])
5254
5355 else :
5456 # print "ERROR!"
119121 removed += t + "\n"
120122
121123 if len(regressions['compile state']) != 0:
122 print 'REGRESSION: Compilation Failed'
123 print regressions['compile state']
124 print('REGRESSION: Compilation Failed')
125 print(regressions['compile state'])
124126
125127 if len(regressions['exec state']) != 0:
126 print 'REGRESSION: Execution Failed'
127 print regressions['exec state']
128 print('REGRESSION: Execution Failed')
129 print(regressions['exec state'])
128130
129131 if len(regressions['compile time']) != 0:
130 print 'REGRESSION: Compilation Time'
131 print regressions['compile time']
132 print('REGRESSION: Compilation Time')
133 print(regressions['compile time'])
132134
133135 if len(regressions['exec time']) != 0:
134 print 'REGRESSION: Execution Time'
135 print regressions['exec time']
136 print('REGRESSION: Execution Time')
137 print(regressions['exec time'])
136138
137139 if len(passes['compile state']) != 0:
138 print 'NEW PASSES: Compilation'
139 print passes['compile state']
140 print('NEW PASSES: Compilation')
141 print(passes['compile state'])
140142
141143 if len(passes['exec state']) != 0:
142 print 'NEW PASSES: Execution'
143 print passes['exec state']
144 print('NEW PASSES: Execution')
145 print(passes['exec state'])
144146
145147 if len(removed) != 0:
146 print 'REMOVED TESTS'
147 print removed
148 print('REMOVED TESTS')
149 print(removed)
148150
149151 # Main
150152 if len(sys.argv) < 3 :
151 print 'Usage:', sys.argv[0], ' '
153 print('Usage:', sys.argv[0], ' ')
152154 sys.exit(-1)
153155
154156 d_old = parse(sys.argv[1])
1111 set of transforms you want to test, and run the program. If it crashes, it found
1212 a bug.
1313 """
14
15 from __future__ import print_function
1416
1517 import argparse
1618 import itertools
108110
109111 if args.verbose:
110112 # Print out the shuffle sequence in a compact form.
111 print >>sys.stderr, ('Testing shuffle sequence "%s" (v%d%s):' %
112 (args.seed, width, element_type))
113 print(('Testing shuffle sequence "%s" (v%d%s):' %
114 (args.seed, width, element_type)), file=sys.stderr)
113115 for i, shuffles in enumerate(shuffle_tree):
114 print >>sys.stderr, ' tree level %d:' % (i,)
116 print(' tree level %d:' % (i,), file=sys.stderr)
115117 for j, s in enumerate(shuffles):
116 print >>sys.stderr, ' shuffle %d: %s' % (j, s)
117 print >>sys.stderr, ''
118 print(' shuffle %d: %s' % (j, s), file=sys.stderr)
119 print('', file=sys.stderr)
118120
119121 # Symbolically evaluate the shuffle tree.
120122 inputs = [[int(j % element_modulus)
127129 for j in s]
128130 for i, s in enumerate(shuffles)]
129131 if len(results) != 1:
130 print >>sys.stderr, 'ERROR: Bad results: %s' % (results,)
132 print('ERROR: Bad results: %s' % (results,), file=sys.stderr)
131133 sys.exit(1)
132134 result = results[0]
133135
134136 if args.verbose:
135 print >>sys.stderr, 'Which transforms:'
136 print >>sys.stderr, ' from: %s' % (inputs,)
137 print >>sys.stderr, ' into: %s' % (result,)
138 print >>sys.stderr, ''
137 print('Which transforms:', file=sys.stderr)
138 print(' from: %s' % (inputs,), file=sys.stderr)
139 print(' into: %s' % (result,), file=sys.stderr)
140 print('', file=sys.stderr)
139141
140142 # The IR uses silly names for floating point types. We also need a same-size
141143 # integer type.
149151
150152 # Now we need to generate IR for the shuffle function.
151153 subst = {'N': width, 'T': element_type, 'IT': integral_element_type}
152 print """
154 print("""
153155 define internal fastcc <%(N)d x %(T)s> @test(%(arguments)s) noinline nounwind {
154156 entry:""" % dict(subst,
155157 arguments=', '.join(
156158 ['<%(N)d x %(T)s> %%s.0.%(i)d' % dict(subst, i=i)
157 for i in xrange(args.max_shuffle_height + 1)]))
159 for i in xrange(args.max_shuffle_height + 1)])))
158160
159161 for i, shuffles in enumerate(shuffle_tree):
160162 for j, s in enumerate(shuffles):
161 print """
163 print("""
162164 %%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>
163165 """.strip('\n') % dict(subst, i=i, next_i=i + 1, j=j, next_j=j + 1,
164166 S=', '.join(['i32 ' + (str(si) if si != -1 else 'undef')
165 for si in s]))
166
167 print """
167 for si in s])))
168
169 print("""
168170 ret <%(N)d x %(T)s> %%s.%(i)d.0
169171 }
170 """ % dict(subst, i=len(shuffle_tree))
172 """ % dict(subst, i=len(shuffle_tree)))
171173
172174 # Generate some string constants that we can use to report errors.
173175 for i, r in enumerate(result):
175177 s = ('FAIL(%(seed)s): lane %(lane)d, expected %(result)d, found %%d\n\\0A' %
176178 {'seed': args.seed, 'lane': i, 'result': r})
177179 s += ''.join(['\\00' for _ in itertools.repeat(None, 128 - len(s) + 2)])
178 print """
180 print("""
179181 @error.%(i)d = private unnamed_addr global [128 x i8] c"%(s)s"
180 """.strip() % {'i': i, 's': s}
182 """.strip() % {'i': i, 's': s})
181183
182184 # Define a wrapper function which is marked 'optnone' to prevent
183185 # interprocedural optimizations from deleting the test.
184 print """
186 print("""
185187 define internal fastcc <%(N)d x %(T)s> @test_wrapper(%(arguments)s) optnone noinline {
186188 %%result = call fastcc <%(N)d x %(T)s> @test(%(arguments)s)
187189 ret <%(N)d x %(T)s> %%result
188190 }
189191 """ % dict(subst,
190192 arguments=', '.join(['<%(N)d x %(T)s> %%s.%(i)d' % dict(subst, i=i)
191 for i in xrange(args.max_shuffle_height + 1)]))
193 for i in xrange(args.max_shuffle_height + 1)])))
192194
193195 # Finally, generate a main function which will trap if any lanes are mapped
194196 # incorrectly (in an observable way).
195 print """
197 print("""
196198 define i32 @main() {
197199 entry:
198200 ; Create a scratch space to print error messages.
211213 '(<%(N)d x %(IT)s> <%(input)s> to <%(N)d x %(T)s>)' %
212214 dict(subst, input=', '.join(['%(IT)s %(i)d' % dict(subst, i=i)
213215 for i in input])))
214 for input in inputs]))
216 for input in inputs])))
215217
216218 # Test that each non-undef result lane contains the expected value.
217219 for i, r in enumerate(result):
218220 if r == -1:
219 print """
221 print("""
220222 test.%(i)d:
221223 ; Skip this lane, its value is undef.
222224 br label %%test.%(next_i)d
223 """ % dict(subst, i=i, next_i=i + 1)
225 """ % dict(subst, i=i, next_i=i + 1))
224226 else:
225 print """
227 print("""
226228 test.%(i)d:
227229 %%v.%(i)d = extractelement <%(N)d x %(IT)s> %%v.cast, i32 %(i)d
228230 %%cmp.%(i)d = icmp ne %(IT)s %%v.%(i)d, %(r)d
237239 call i32 @write(i32 2, i8* %%str.ptr, i32 %%length.%(i)d)
238240 call void @llvm.trap()
239241 unreachable
240 """ % dict(subst, i=i, next_i=i + 1, r=r)
241
242 print """
242 """ % dict(subst, i=i, next_i=i + 1, r=r))
243
244 print("""
243245 test.%d:
244246 ret i32 0
245247 }
248250 declare i32 @write(i32, i8*, i32)
249251 declare i32 @sprintf(i8*, i8*, ...)
250252 declare void @llvm.trap() noreturn nounwind
251 """ % (len(result),)
253 """ % (len(result),))
252254
253255 if __name__ == '__main__':
254256 main()
1212 set of transforms you want to test, and run the program. If it crashes, it found
1313 a bug (an error message with the expected and actual result is printed).
1414 """
15 from __future__ import print_function
1516
1617 import random
1718 import uuid
144145
145146 def calc_value(self):
146147 if self.value != None:
147 print 'Trying to calculate the value of a shuffle instruction twice'
148 print('Trying to calculate the value of a shuffle instruction twice')
148149 exit(1)
149150
150151 result = []
178179
179180 def calc_value(self):
180181 if self.value != None:
181 print 'Trying to calculate the value of a select instruction twice'
182 print('Trying to calculate the value of a select instruction twice')
182183 exit(1)
183184
184185 result = []
342343 help='Choose specific number of vector elements to be tested. (default: random)')
343344 args = parser.parse_args()
344345
345 print '; The seed used for this test is ' + args.seed
346 print('; The seed used for this test is ' + args.seed)
346347
347348 assert args.min_num_inputs < args.max_num_inputs , "Minimum value greater than maximum."
348349 assert args.type in [None, 'i8', 'i16', 'i32', 'i64', 'f32', 'f64'], "Illegal type."
361362
362363 # print the actual test function by dumping the generated instructions.
363364 insts_str = ''.join([inst.dump() for inst in insts])
364 print test_template.format(ty = ty.dump(), inputs = inputs_str,
365 instructions = insts_str, last_name = res.name)
365 print(test_template.format(ty = ty.dump(), inputs = inputs_str,
366 instructions = insts_str, last_name = res.name))
366367
367368 # Print the error message templates as global strings
368369 for i in range(len(res.value)):
369370 pad = ''.join(['\\00']*(31 - len(str(i)) - len(str(res.value[i]))))
370 print error_template.format(lane = str(i), exp = str(res.value[i]),
371 padding = pad)
371 print(error_template.format(lane = str(i), exp = str(res.value[i]),
372 padding = pad))
372373
373374 # Prepare the runtime checks and failure handlers.
374375 scalar_ty = ty.get_scalar_type()
394395 inputs_values = [', '.join([scalar_ty.dump() + ' ' + str(i) for i in inp]) for inp in inputs_values]
395396 inputs = ', '.join([ty.dump() + ' <' + inp + '>' for inp in inputs_values])
396397
397 print main_template.format(ty = ty.dump(), inputs = inputs, check_die = check_die)
398 print(main_template.format(ty = ty.dump(), inputs = inputs, check_die = check_die))
398399
399400
400401 if __name__ == '__main__':
1515 Right now this generates a function which implements simple case folding (C+S
1616 entries).
1717 """
18
19 from __future__ import print_function
1820
1921 import sys
2022 import re
115117
116118 dump_block(current_block)
117119
118 print '//===---------- Support/UnicodeCaseFold.cpp -------------------------------===//'
119 print '//'
120 print '// This file was generated by utils/unicode-case-fold.py from the Unicode'
121 print '// case folding database at'
122 print '// ', sys.argv[1]
123 print '//'
124 print '// To regenerate this file, run:'
125 print '// utils/unicode-case-fold.py \\'
126 print '// "{}" \\'.format(sys.argv[1])
127 print '// > lib/Support/UnicodeCaseFold.cpp'
128 print '//'
129 print '//===----------------------------------------------------------------------===//'
130 print ''
131 print '#include "llvm/Support/Unicode.h"'
132 print ''
133 print "int llvm::sys::unicode::foldCharSimple(int C) {"
134 print body
135 print " return C;"
136 print "}"
120 print('//===---------- Support/UnicodeCaseFold.cpp -------------------------------===//')
121 print('//')
122 print('// This file was generated by utils/unicode-case-fold.py from the Unicode')
123 print('// case folding database at')
124 print('// ', sys.argv[1])
125 print('//')
126 print('// To regenerate this file, run:')
127 print('// utils/unicode-case-fold.py \\')
128 print('// "{}" \\'.format(sys.argv[1]))
129 print('// > lib/Support/UnicodeCaseFold.cpp')
130 print('//')
131 print('//===----------------------------------------------------------------------===//')
132 print('')
133 print('#include "llvm/Support/Unicode.h"')
134 print('')
135 print("int llvm::sys::unicode::foldCharSimple(int C) {")
136 print(body)
137 print(" return C;")
138 print("}")
2727 The script is designed to make adding checks to a test case fast, it is *not*
2828 designed to be authoratitive about what constitutes a good test!
2929 """
30
31 from __future__ import print_function
3032
3133 import argparse
3234 import itertools
6567
6668 opt_basename = os.path.basename(args.opt_binary)
6769 if (opt_basename != "opt"):
68 print >>sys.stderr, 'ERROR: Unexpected opt name: ' + opt_basename
70 print('ERROR: Unexpected opt name: ' + opt_basename, file=sys.stderr)
6971 sys.exit(1)
7072
7173 for test in args.tests:
7274 if args.verbose:
73 print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
75 print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
7476 with open(test) as f:
7577 input_lines = [l.rstrip() for l in f]
7678
8486 run_lines.append(l)
8587
8688 if args.verbose:
87 print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
89 print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
8890 for l in run_lines:
89 print >>sys.stderr, ' RUN: ' + l
91 print(' RUN: ' + l, file=sys.stderr)
9092
9193 prefix_list = []
9294 for l in run_lines:
9395 (tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
9496
9597 if not tool_cmd.startswith(opt_basename + ' '):
96 print >>sys.stderr, 'WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l)
98 print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
9799 continue
98100
99101 if not filecheck_cmd.startswith('FileCheck '):
100 print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
102 print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
101103 continue
102104
103105 tool_cmd_args = tool_cmd[len(opt_basename):].strip()
118120 func_dict.update({prefix: dict()})
119121 for prefixes, opt_args in prefix_list:
120122 if args.verbose:
121 print >>sys.stderr, 'Extracted opt cmd: ' + opt_basename + ' ' + opt_args
122 print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
123 print('Extracted opt cmd: ' + opt_basename + ' ' + opt_args, file=sys.stderr)
124 print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
123125
124126 raw_tool_outputs = common.invoke_tool(args.opt_binary, opt_args, test)
125127
133135 is_in_function_start = False
134136 prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
135137 if args.verbose:
136 print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
138 print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
137139 output_lines = []
138140 output_lines.append(autogenerated_note)
139141
180182 is_in_function = is_in_function_start = True
181183
182184 if args.verbose:
183 print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
185 print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
184186
185187 with open(test, 'wb') as f:
186188 f.writelines([l + '\n' for l in output_lines])
55 FileCheck patterns. It can either update all of the tests in the file or
66 a single test function.
77 """
8
9 from __future__ import print_function
810
911 import argparse
1012 import os # Used to advertise this file's name ("autogenerated_note").
4143
4244 for test in args.tests:
4345 if args.verbose:
44 print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
46 print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
4547 with open(test) as f:
4648 input_lines = [l.rstrip() for l in f]
4749
6264 run_lines.append(l)
6365
6466 if args.verbose:
65 print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
67 print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
6668 for l in run_lines:
67 print >>sys.stderr, ' RUN: ' + l
69 print(' RUN: ' + l, file=sys.stderr)
6870
6971 run_list = []
7072 for l in run_lines:
8082 if len(commands) > 1:
8183 filecheck_cmd = commands[1]
8284 if not llc_cmd.startswith('llc '):
83 print >>sys.stderr, 'WARNING: Skipping non-llc RUN line: ' + l
85 print('WARNING: Skipping non-llc RUN line: ' + l, file=sys.stderr)
8486 continue
8587
8688 if not filecheck_cmd.startswith('FileCheck '):
87 print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
89 print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
8890 continue
8991
9092 llc_cmd_args = llc_cmd[len('llc'):].strip()
106108 func_dict.update({prefix: dict()})
107109 for prefixes, llc_args, triple_in_cmd in run_list:
108110 if args.verbose:
109 print >>sys.stderr, 'Extracted LLC cmd: llc ' + llc_args
110 print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
111 print('Extracted LLC cmd: llc ' + llc_args, file=sys.stderr)
112 print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
111113
112114 raw_tool_output = common.invoke_tool(args.llc_binary, llc_args, test)
113115 if not (triple_in_cmd or triple_in_ir):
114 print >>sys.stderr, "Cannot find a triple. Assume 'x86'"
116 print("Cannot find a triple. Assume 'x86'", file=sys.stderr)
115117
116118 asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
117119 triple_in_cmd or triple_in_ir or 'x86', prefixes, func_dict)
121123 func_name = None
122124 prefix_set = set([prefix for p in run_list for prefix in p[0]])
123125 if args.verbose:
124 print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
126 print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
125127 output_lines = []
126128 output_lines.append(autogenerated_note)
127129
166168 is_in_function = is_in_function_start = True
167169
168170 if args.verbose:
169 print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
171 print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
170172
171173 with open(test, 'wb') as f:
172174 f.writelines([l + '\n' for l in output_lines])
2727 The script is designed to make adding checks to a test case fast, it is *not*
2828 designed to be authoratitive about what constitutes a good test!
2929 """
30
31 from __future__ import print_function
3032
3133 import argparse
3234 import itertools
6567
6668 opt_basename = os.path.basename(args.opt_binary)
6769 if (opt_basename != "opt"):
68 print >>sys.stderr, 'ERROR: Unexpected opt name: ' + opt_basename
70 print('ERROR: Unexpected opt name: ' + opt_basename, file=sys.stderr)
6971 sys.exit(1)
7072
7173 for test in args.tests:
7274 if args.verbose:
73 print >>sys.stderr, 'Scanning for RUN lines in test file: %s' % (test,)
75 print('Scanning for RUN lines in test file: %s' % (test,), file=sys.stderr)
7476 with open(test) as f:
7577 input_lines = [l.rstrip() for l in f]
7678
8486 run_lines.append(l)
8587
8688 if args.verbose:
87 print >>sys.stderr, 'Found %d RUN lines:' % (len(run_lines),)
89 print('Found %d RUN lines:' % (len(run_lines),), file=sys.stderr)
8890 for l in run_lines:
89 print >>sys.stderr, ' RUN: ' + l
91 print(' RUN: ' + l, file=sys.stderr)
9092
9193 prefix_list = []
9294 for l in run_lines:
9395 (tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
9496
9597 if not tool_cmd.startswith(opt_basename + ' '):
96 print >>sys.stderr, 'WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l)
98 print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
9799 continue
98100
99101 if not filecheck_cmd.startswith('FileCheck '):
100 print >>sys.stderr, 'WARNING: Skipping non-FileChecked RUN line: ' + l
102 print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
101103 continue
102104
103105 tool_cmd_args = tool_cmd[len(opt_basename):].strip()
118120 func_dict.update({prefix: dict()})
119121 for prefixes, opt_args in prefix_list:
120122 if args.verbose:
121 print >>sys.stderr, 'Extracted opt cmd: ' + opt_basename + ' ' + opt_args
122 print >>sys.stderr, 'Extracted FileCheck prefixes: ' + str(prefixes)
123 print('Extracted opt cmd: ' + opt_basename + ' ' + opt_args, file=sys.stderr)
124 print('Extracted FileCheck prefixes: ' + str(prefixes), file=sys.stderr)
123125
124126 raw_tool_output = common.invoke_tool(args.opt_binary, opt_args, test)
125127 common.build_function_body_dictionary(
130132 is_in_function_start = False
131133 prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
132134 if args.verbose:
133 print >>sys.stderr, 'Rewriting FileCheck prefixes: %s' % (prefix_set,)
135 print('Rewriting FileCheck prefixes: %s' % (prefix_set,), file=sys.stderr)
134136 output_lines = []
135137 output_lines.append(autogenerated_note)
136138
177179 is_in_function = is_in_function_start = True
178180
179181 if args.verbose:
180 print>>sys.stderr, 'Writing %d lines to %s...' % (len(output_lines), test)
182 print('Writing %d lines to %s...' % (len(output_lines), test), file=sys.stderr)
181183
182184 with open(test, 'wb') as f:
183185 f.writelines([l + '\n' for l in output_lines])
1919
2020 """
2121
22 from __future__ import print_function
2223 import os
2324
2425 code_owners = {}
9697 import sys
9798
9899 if len(sys.argv) < 2:
99 print "usage " + sys.argv[0] + " file_or_folder"
100 print("usage " + sys.argv[0] + " file_or_folder")
100101 exit(-1)
101102
102103 # the path we are checking
104105
105106 # check if this is real path
106107 if not os.path.exists(path):
107 print "path (" + path + ") does not exist"
108 print("path (" + path + ") does not exist")
108109 exit(-1)
109110
110111 owners_name = find_owners(path)
111112
112113 # be grammatically correct
113 print "The owner(s) of the (" + path + ") is(are) : " + str(owners_name)
114 print("The owner(s) of the (" + path + ") is(are) : " + str(owners_name))
114115
115116 exit(0)
116117
118119 # not yet used
119120 root = "."
120121 for dir,subdirList,fileList in os.walk( root , topdown=False ) :
121 print "dir :" , dir
122 print("dir :" , dir)
122123 for fname in fileList :
123 print "-" , fname
124 print
124 print("-" , fname)
125 print()