rustllvm: Add a binding to the LLVM standard module passes

This commit is contained in:
Patrick Walton 2011-05-06 12:02:04 -07:00
parent 5e2088f2fa
commit d089d9f9ed
4 changed files with 36 additions and 1 deletions

View File

@ -3,7 +3,7 @@
######################################################################
RUSTLLVM_LIB_CS := $(addprefix rustllvm/, \
MachOObjectFile.cpp Passes.cpp)
MachOObjectFile.cpp Passes.cpp Passes2.cpp)
RUSTLLVM_OBJS_CS := $(addprefix rustllvm/, RustWrapper.cpp)

View File

@ -802,6 +802,16 @@ native mod llvm = llvm_lib {
fn LLVMAddTypeBasedAliasAnalysisPass(PassManagerRef PM);
fn LLVMAddBasicAliasAnalysisPass(PassManagerRef PM);
// FIXME: Native stubs don't allow this many arguments yet.
/*fn LLVMAddStandardModulePasses(PassManagerRef PM,
uint OptimizationLevel,
Bool OptimizeSize,
Bool UnitAtATime,
Bool UnrollLoops,
Bool SimplifyLibCalls,
Bool HaveExceptions,
uint InliningThreshold);*/
/** Destroys a memory buffer. */
fn LLVMDisposeMemoryBuffer(MemoryBufferRef MemBuf);

24
src/rustllvm/Passes2.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/Support/StandardPasses.h"
#include "llvm/PassManager.h"
#include "llvm-c/Core.h"
#include <cstdlib>
using namespace llvm;
extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
unsigned int OptimizationLevel, bool OptimizeSize, bool UnitAtATime,
bool UnrollLoops, bool SimplifyLibCalls, bool HaveExceptions,
unsigned int InliningThreshold) {
Pass *InliningPass;
if (InliningThreshold)
InliningPass = createFunctionInliningPass(InliningThreshold);
else
InliningPass = NULL;
createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
UnitAtATime, UnrollLoops, SimplifyLibCalls,
HaveExceptions, InliningPass);
}

View File

@ -68,6 +68,7 @@ LLVMAddScalarReplAggregatesPass
LLVMAddScalarReplAggregatesPassSSA
LLVMAddScalarReplAggregatesPassWithThreshold
LLVMAddSimplifyLibCallsPass
LLVMAddStandardModulePasses
LLVMAddStripDeadPrototypesPass
LLVMAddStripSymbolsPass
LLVMAddTailCallEliminationPass