Implement the machinery to create a TargetIsa.

Add an isa::lookup() function which serves as a target registry for creating
Box<TargetIsa> trait objects.

An isa::Builder makes it possible to confugure the trait object before it is
created.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-11 11:39:42 -07:00
parent 8c48739afd
commit aeb376227e
3 changed files with 94 additions and 5 deletions

View File

@@ -1,3 +1,37 @@
//! RISC-V Instruction Set Architecture.
pub mod settings;
use super::super::settings as shared_settings;
use super::Builder as IsaBuilder;
use super::{TargetIsa, Encoding};
use ir::dfg::DataFlowGraph;
use ir::entities::Inst;
#[allow(dead_code)]
struct Isa {
shared_flags: shared_settings::Flags,
isa_flags: settings::Flags,
}
pub fn isa_builder() -> IsaBuilder {
IsaBuilder {
setup: settings::builder(),
constructor: isa_constructor,
}
}
fn isa_constructor(shared_flags: shared_settings::Flags,
builder: shared_settings::Builder)
-> Box<TargetIsa> {
Box::new(Isa {
shared_flags: shared_flags,
isa_flags: settings::Flags::new(builder),
})
}
impl TargetIsa for Isa {
fn encode(&self, _: &DataFlowGraph, _: &Inst) -> Option<Encoding> {
unimplemented!()
}
}