#!/usr/bin/env perl use strict; use warnings; # This script moves IR from the old syntax to the new one. # The three biggest changes is to: # 1. Move "load type object" to "load type, type* object" # 2. Move "GEP type object" to "GEP type, type* object" # 3. Clean up metadata if (!$ARGV[0] or !-f $ARGV[0]) { die "Syntax: llvm-irtonew file.ll\n"; } open(FH, $ARGV[0]) || die "Can't open file '$ARGV[0]': $!\n"; foreach my $line () { $line =~ s/ load (.*)\* %/ load $1, $1* %/; $line =~ s/ getelementptr (.*)\* %/ getelementptr $1, $1* %/; $line =~ s/,? ?!.*//; print $line; } close FH;