2008-03-16 16:32:40 +00:00
|
|
|
//===-- Scalar.cpp --------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-10-07 17:55:47 +00:00
|
|
|
// This file implements common infrastructure for libLLVMScalarOpts.a, which
|
|
|
|
// implements several scalar transformations over the LLVM intermediate
|
|
|
|
// representation, including the C bindings for that library.
|
2008-03-16 16:32:40 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm-c/Transforms/Scalar.h"
|
2010-10-07 17:55:47 +00:00
|
|
|
#include "llvm-c/Initialization.h"
|
|
|
|
#include "llvm/InitializePasses.h"
|
2008-03-16 16:32:40 +00:00
|
|
|
#include "llvm/PassManager.h"
|
2011-04-13 15:44:58 +00:00
|
|
|
#include "llvm/Analysis/Passes.h"
|
2010-03-11 23:06:07 +00:00
|
|
|
#include "llvm/Analysis/Verifier.h"
|
|
|
|
#include "llvm/Target/TargetData.h"
|
2008-03-16 16:32:40 +00:00
|
|
|
#include "llvm/Transforms/Scalar.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-10-07 17:55:47 +00:00
|
|
|
/// initializeScalarOptsPasses - Initialize all passes linked into the
|
|
|
|
/// ScalarOpts library.
|
|
|
|
void llvm::initializeScalarOpts(PassRegistry &Registry) {
|
|
|
|
initializeADCEPass(Registry);
|
|
|
|
initializeBlockPlacementPass(Registry);
|
|
|
|
initializeCodeGenPreparePass(Registry);
|
|
|
|
initializeConstantPropagationPass(Registry);
|
|
|
|
initializeCorrelatedValuePropagationPass(Registry);
|
|
|
|
initializeDCEPass(Registry);
|
|
|
|
initializeDeadInstEliminationPass(Registry);
|
|
|
|
initializeDSEPass(Registry);
|
|
|
|
initializeGVNPass(Registry);
|
2011-01-02 21:47:05 +00:00
|
|
|
initializeEarlyCSEPass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeIndVarSimplifyPass(Registry);
|
|
|
|
initializeJumpThreadingPass(Registry);
|
|
|
|
initializeLICMPass(Registry);
|
|
|
|
initializeLoopDeletionPass(Registry);
|
2011-01-03 00:25:16 +00:00
|
|
|
initializeLoopInstSimplifyPass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeLoopRotatePass(Registry);
|
|
|
|
initializeLoopStrengthReducePass(Registry);
|
|
|
|
initializeLoopUnrollPass(Registry);
|
|
|
|
initializeLoopUnswitchPass(Registry);
|
2010-12-26 19:32:44 +00:00
|
|
|
initializeLoopIdiomRecognizePass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeLowerAtomicPass(Registry);
|
2011-07-06 18:22:43 +00:00
|
|
|
initializeLowerExpectIntrinsicPass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeMemCpyOptPass(Registry);
|
2011-06-15 23:37:01 +00:00
|
|
|
initializeObjCARCAliasAnalysisPass(Registry);
|
2012-01-17 20:52:24 +00:00
|
|
|
initializeObjCARCAPElimPass(Registry);
|
2011-06-15 23:37:01 +00:00
|
|
|
initializeObjCARCExpandPass(Registry);
|
|
|
|
initializeObjCARCContractPass(Registry);
|
|
|
|
initializeObjCARCOptPass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeReassociatePass(Registry);
|
|
|
|
initializeRegToMemPass(Registry);
|
|
|
|
initializeSCCPPass(Registry);
|
|
|
|
initializeIPSCCPPass(Registry);
|
2011-01-18 03:53:26 +00:00
|
|
|
initializeSROA_DTPass(Registry);
|
2011-01-14 08:13:00 +00:00
|
|
|
initializeSROA_SSAUpPass(Registry);
|
2010-10-07 17:55:47 +00:00
|
|
|
initializeCFGSimplifyPassPass(Registry);
|
|
|
|
initializeSimplifyLibCallsPass(Registry);
|
|
|
|
initializeSinkingPass(Registry);
|
|
|
|
initializeTailCallElimPass(Registry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) {
|
|
|
|
initializeScalarOpts(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createAggressiveDCEPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createCFGSimplificationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createDeadStoreEliminationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddGVNPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createGVNPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createIndVarSimplifyPass());
|
2008-03-16 16:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createInstructionCombiningPass());
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createJumpThreadingPass());
|
2008-03-20 17:16:03 +00:00
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddLICMPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLICMPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLoopDeletionPass());
|
|
|
|
}
|
|
|
|
|
2011-04-07 18:20:46 +00:00
|
|
|
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLoopIdiomPass());
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLoopRotatePass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLoopUnrollPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLoopUnswitchPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createMemCpyOptPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createPromoteMemoryToRegisterPass());
|
2008-03-20 17:16:03 +00:00
|
|
|
}
|
|
|
|
|
2008-03-16 16:32:40 +00:00
|
|
|
void LLVMAddReassociatePass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createReassociatePass());
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddSCCPPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createSCCPPass());
|
2008-03-16 16:32:40 +00:00
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createScalarReplAggregatesPass());
|
|
|
|
}
|
|
|
|
|
2011-04-07 18:20:46 +00:00
|
|
|
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createScalarReplAggregatesPass(-1, false));
|
|
|
|
}
|
|
|
|
|
2010-03-11 23:06:07 +00:00
|
|
|
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
|
|
|
|
int Threshold) {
|
|
|
|
unwrap(PM)->add(createScalarReplAggregatesPass(Threshold));
|
|
|
|
}
|
|
|
|
|
2009-03-06 16:52:18 +00:00
|
|
|
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createSimplifyLibCallsPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createTailCallEliminationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createConstantPropagationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createDemoteRegisterToMemoryPass());
|
2008-03-16 16:32:40 +00:00
|
|
|
}
|
2010-03-11 23:06:07 +00:00
|
|
|
|
|
|
|
void LLVMAddVerifierPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createVerifierPass());
|
|
|
|
}
|
2011-04-07 18:20:46 +00:00
|
|
|
|
|
|
|
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createCorrelatedValuePropagationPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createEarlyCSEPass());
|
|
|
|
}
|
2011-04-13 15:44:58 +00:00
|
|
|
|
|
|
|
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createTypeBasedAliasAnalysisPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createBasicAliasAnalysisPass());
|
|
|
|
}
|
2011-07-25 20:57:59 +00:00
|
|
|
|
|
|
|
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLowerExpectIntrinsicPass());
|
|
|
|
}
|