]>
git.proxmox.com Git - rustc.git/blob - src/rustllvm/PassWrapper.cpp
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 // Pass conversion fns
16 typedef struct LLVMOpaquePass
*LLVMPassRef
;
18 inline Pass
*unwrap(LLVMPassRef P
) {
19 return reinterpret_cast<Pass
*>(P
);
22 inline LLVMPassRef
wrap(const Pass
*P
) {
23 return reinterpret_cast<LLVMPassRef
>(const_cast<Pass
*>(P
));
27 inline T
*unwrap(LLVMPassRef P
) {
29 assert(Q
&& "Invalid cast!");
33 extern "C" void LLVMInitializePasses() {
34 PassRegistry
&Registry
= *PassRegistry::getPassRegistry();
35 initializeCore(Registry
);
36 initializeCodeGen(Registry
);
37 initializeScalarOpts(Registry
);
38 initializeVectorization(Registry
);
39 initializeIPO(Registry
);
40 initializeAnalysis(Registry
);
41 initializeIPA(Registry
);
42 initializeTransformUtils(Registry
);
43 initializeInstCombine(Registry
);
44 initializeInstrumentation(Registry
);
45 initializeTarget(Registry
);
48 extern "C" void LLVMAddPass(LLVMPassManagerRef PM
, LLVMPassRef P
) {
49 PassManagerBase
* pm
= unwrap(PM
);
55 extern "C" LLVMPassRef
LLVMCreatePass(const char * PassName
) {
56 StringRef
SR(PassName
);
57 PassRegistry
* PR
= PassRegistry::getPassRegistry();
59 const PassInfo
* PI
= PR
->getPassInfo(SR
);
61 return wrap(PI
->createPass());
63 return (LLVMPassRef
)0;
67 extern "C" void LLVMDestroyPass(LLVMPassRef PassRef
) {
68 Pass
*p
= unwrap(PassRef
);