blob: 4e798a415ade5a6e36aadeb15b0bb9bf9d974bd8 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env perl
2
3use strict;
4use 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
12if (!$ARGV[0] or !-f $ARGV[0]) {
13 die "Syntax: llvm-irtonew file.ll\n";
14}
15open(FH, $ARGV[0]) || die "Can't open file '$ARGV[0]': $!\n";
16foreach my $line (<FH>) {
17 $line =~ s/ load (.*)\* %/ load $1, $1* %/;
18 $line =~ s/ getelementptr (.*)\* %/ getelementptr $1, $1* %/;
19 $line =~ s/,? ?!.*//;
20 print $line;
21}
22close FH;