Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | # This script moves IR from the old syntax to the new one. |
| 7 | # The three biggest changes is to: |
| 8 | # 1. Move "load type object" to "load type, type* object" |
| 9 | # 2. Move "GEP type object" to "GEP type, type* object" |
| 10 | # 3. Clean up metadata |
| 11 | |
| 12 | if (!$ARGV[0] or !-f $ARGV[0]) { |
| 13 | die "Syntax: llvm-irtonew file.ll\n"; |
| 14 | } |
| 15 | open(FH, $ARGV[0]) || die "Can't open file '$ARGV[0]': $!\n"; |
| 16 | foreach my $line (<FH>) { |
| 17 | $line =~ s/ load (.*)\* %/ load $1, $1* %/; |
| 18 | $line =~ s/ getelementptr (.*)\* %/ getelementptr $1, $1* %/; |
| 19 | $line =~ s/,? ?!.*//; |
| 20 | print $line; |
| 21 | } |
| 22 | close FH; |