about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-05-06 12:02:04 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-05-06 12:38:00 -0700
commitd089d9f9ed01464940ef6e383ec239bbd5612e8c (patch)
treebbf2f7067e12ab91ae9536dd49fe49e6bfbebb9d /src
parent5e2088f2faf5e53ebf8af52d9bd7e034c5fc61c2 (diff)
downloadrust-d089d9f9ed01464940ef6e383ec239bbd5612e8c.tar.gz
rust-d089d9f9ed01464940ef6e383ec239bbd5612e8c.zip
rustllvm: Add a binding to the LLVM standard module passes
Diffstat (limited to 'src')
-rw-r--r--src/comp/lib/llvm.rs10
-rw-r--r--src/rustllvm/Passes2.cpp24
-rw-r--r--src/rustllvm/rustllvm.def.in1
3 files changed, 35 insertions, 0 deletions
diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs
index f825e05db21..1d2529ccf00 100644
--- a/src/comp/lib/llvm.rs
+++ b/src/comp/lib/llvm.rs
@@ -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);
 
diff --git a/src/rustllvm/Passes2.cpp b/src/rustllvm/Passes2.cpp
new file mode 100644
index 00000000000..a0a6a20c5c4
--- /dev/null
+++ b/src/rustllvm/Passes2.cpp
@@ -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);
+}
+
+
diff --git a/src/rustllvm/rustllvm.def.in b/src/rustllvm/rustllvm.def.in
index 748c77aa7bc..e52f2908415 100644
--- a/src/rustllvm/rustllvm.def.in
+++ b/src/rustllvm/rustllvm.def.in
@@ -68,6 +68,7 @@ LLVMAddScalarReplAggregatesPass
 LLVMAddScalarReplAggregatesPassSSA
 LLVMAddScalarReplAggregatesPassWithThreshold
 LLVMAddSimplifyLibCallsPass
+LLVMAddStandardModulePasses
 LLVMAddStripDeadPrototypesPass
 LLVMAddStripSymbolsPass
 LLVMAddTailCallEliminationPass