[opt][PassInfo] Allow opt to run passes that need target machine.
authorQuentin Colombet <qcolombet@apple.com>
Thu, 16 Jan 2014 21:44:34 +0000 (21:44 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Thu, 16 Jan 2014 21:44:34 +0000 (21:44 +0000)
commit9b24eeee01a7e7225280ad90b44e06158cdb0806
tree0773b72ad9486c9028e54b9f18408eeb741b7ae6
parent7c41150e851bf4e79f796e0b3a933112d78dd567
[opt][PassInfo] Allow opt to run passes that need target machine.

When registering a pass, a pass can now specify a second construct that takes as
argument a pointer to TargetMachine.
The PassInfo class has been updated to reflect that possibility.
If such a constructor exists opt will use it instead of the default constructor
when instantiating the pass.

Since such IR passes are supposed to be rare, no specific support has been
added to this commit to allow an easy registration of such a pass.
In other words, for such pass, the initialization function has to be
hand-written (see CodeGenPrepare for instance).

Now, codegenprepare can be tested using opt:
opt -codegenprepare -mtriple=mytriple input.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199430 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/PassSupport.h
lib/IR/PassRegistry.cpp
lib/Transforms/Scalar/CodeGenPrepare.cpp
tools/opt/opt.cpp