aboutsummaryrefslogtreecommitdiff
path: root/helpers/llvm-irtonew
blob: 4e798a415ade5a6e36aadeb15b0bb9bf9d974bd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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 (<FH>) {
  $line =~ s/ load (.*)\* %/ load $1, $1* %/;
  $line =~ s/ getelementptr (.*)\* %/ getelementptr $1, $1* %/;
  $line =~ s/,? ?!.*//;
  print $line;
}
close FH;