about summary refs log tree commit diff
path: root/src/librustc/plugin
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2015-04-08 12:52:58 -0700
committerKeegan McAllister <kmcallister@mozilla.com>2015-04-08 14:01:59 -0700
commit0cb937944664f7a52895c87f9007fcdface78a7e (patch)
treee2f903e1ea74da556af4616e19f0218436fa762e /src/librustc/plugin
parent30e7e6e8b0389d407f8b46ab605a9e3475a851d5 (diff)
downloadrust-0cb937944664f7a52895c87f9007fcdface78a7e.tar.gz
rust-0cb937944664f7a52895c87f9007fcdface78a7e.zip
Allow plugins to register LLVM passes
Diffstat (limited to 'src/librustc/plugin')
-rw-r--r--src/librustc/plugin/registry.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs
index a73ed04ac0a..322b5d3a8cf 100644
--- a/src/librustc/plugin/registry.rs
+++ b/src/librustc/plugin/registry.rs
@@ -22,6 +22,7 @@ use syntax::ptr::P;
 use syntax::ast;
 
 use std::collections::HashMap;
+use std::borrow::ToOwned;
 
 /// Structure used to register plugins.
 ///
@@ -50,6 +51,9 @@ pub struct Registry<'a> {
 
     #[doc(hidden)]
     pub lint_groups: HashMap<&'static str, Vec<LintId>>,
+
+    #[doc(hidden)]
+    pub llvm_passes: Vec<String>,
 }
 
 impl<'a> Registry<'a> {
@@ -62,6 +66,7 @@ impl<'a> Registry<'a> {
             syntax_exts: vec!(),
             lint_passes: vec!(),
             lint_groups: HashMap::new(),
+            llvm_passes: vec!(),
         }
     }
 
@@ -116,4 +121,13 @@ impl<'a> Registry<'a> {
     pub fn register_lint_group(&mut self, name: &'static str, to: Vec<&'static Lint>) {
         self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect());
     }
+
+    /// Register an LLVM pass.
+    ///
+    /// Registration with LLVM itself is handled through static C++ objects with
+    /// constructors. This method simply adds a name to the list of passes to
+    /// execute.
+    pub fn register_llvm_pass(&mut self, name: &str) {
+        self.llvm_passes.push(name.to_owned());
+    }
 }