Allow plugins to register LLVM passes
This commit is contained in:
parent
30e7e6e8b0
commit
0cb9379446
6 changed files with 79 additions and 1 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ pub struct Session {
|
|||
pub working_dir: PathBuf,
|
||||
pub lint_store: RefCell<lint::LintStore>,
|
||||
pub lints: RefCell<NodeMap<Vec<(lint::LintId, codemap::Span, String)>>>,
|
||||
pub plugin_llvm_passes: RefCell<Vec<String>>,
|
||||
pub crate_types: RefCell<Vec<config::CrateType>>,
|
||||
pub crate_metadata: RefCell<Vec<String>>,
|
||||
pub features: RefCell<feature_gate::Features>,
|
||||
|
|
@ -391,6 +392,7 @@ pub fn build_session_(sopts: config::Options,
|
|||
working_dir: env::current_dir().unwrap(),
|
||||
lint_store: RefCell::new(lint::LintStore::new()),
|
||||
lints: RefCell::new(NodeMap()),
|
||||
plugin_llvm_passes: RefCell::new(Vec::new()),
|
||||
crate_types: RefCell::new(Vec::new()),
|
||||
crate_metadata: RefCell::new(Vec::new()),
|
||||
features: RefCell::new(feature_gate::Features::new()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue