annotate bin/ldmd @ 1170:e40c65bd8c5d

Allow specific optimization passes to be requested from the command line. Now you can run "`ldc test.d -c -mem2reg -simplifycfg`" if you feel the urge. The -O<N> options are still supported, and are inserted in the passes list in the position where they appear on the command line. (so -simplifycfg -O1 -instcombine does the "right thing") One small change: -inline is renamed to -enable-inlining due to a naming conflict with the option to add the -inline pass. -inline now inserts the inlining pass in the position specified, not in the middle of -O<N>. (ldmd has been updated to translate -inline to -enable-inlining)
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 29 Mar 2009 15:46:55 +0200
parents 599e3d6d0dbd
children 17268b0a3ab0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
986
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
1 #! /usr/bin/env bash
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
2
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
3 # Default to 'ldc' next to this file
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
4 LDC=`basename "$0"`/ldc
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
5 if [ ! -x "$LDC" ]; then
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
6 # If that doesn't work, assume this script was called via $PATH
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
7 # and do the same for ldc
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
8 if which ldc &> /dev/null; then
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
9 LDC=ldc
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
10 else
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
11 echo 'ldc not found, check your installation' >/dev/stderr
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
12 exit 1
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
13 fi
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
14 fi
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
15
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
16 declare -a ARGS
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
17 IDX=0
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
18 for arg; do
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
19 case "$arg" in
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
20 -C*)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
21 # turn -Cfoo into -foo.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
22 # Useful for passing -inline to ldc, for instance.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
23 arg="-${arg:2}"
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
24 ;;
986
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
25 -debug|-debug=*|-version=*)
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
26 arg="-d$arg"
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
27 ;;
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
28 -inline)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
29 arg="-enable-inlining"
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 1060
diff changeset
30 ;;
986
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
31 -fPIC)
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
32 arg="-relocation-model=pic"
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
33 ;;
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
34 --a|--b|--c|--f|--r|--w|--x|--y)
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
35 # "Hidden debug switches"
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
36 # Are these ever used?
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
37 arg="-hidden-debug${arg:1}"
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
38 ;;
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
39 esac
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
40 ARGS[IDX++]="$arg"
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
41 done
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
42
a8cb25d478c4 Use LLVM-style command line (instead of DMD-style)
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
43 exec "$LDC" "${ARGS[@]}"