aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/src/pass/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ptx/src/pass/mod.rs')
-rw-r--r--ptx/src/pass/mod.rs30
1 files changed, 9 insertions, 21 deletions
diff --git a/ptx/src/pass/mod.rs b/ptx/src/pass/mod.rs
index 2be6297..3aa3b0a 100644
--- a/ptx/src/pass/mod.rs
+++ b/ptx/src/pass/mod.rs
@@ -16,6 +16,7 @@ use std::{
mod convert_dynamic_shared_memory_usage;
mod convert_to_stateful_memory_access;
mod convert_to_typed;
+pub(crate) mod emit_llvm;
mod emit_spirv;
mod expand_arguments;
mod extract_globals;
@@ -30,7 +31,7 @@ static ZLUDA_PTX_IMPL_INTEL: &'static [u8] = include_bytes!("../../lib/zluda_ptx
static ZLUDA_PTX_IMPL_AMD: &'static [u8] = include_bytes!("../../lib/zluda_ptx_impl.bc");
const ZLUDA_PTX_PREFIX: &'static str = "__zluda_ptx_impl__";
-pub fn to_spirv_module<'input>(ast: ast::Module<'input>) -> Result<Module, TranslateError> {
+pub fn to_llvm_module<'input>(ast: ast::Module<'input>) -> Result<Module, TranslateError> {
let mut id_defs = GlobalStringIdResolver::<'input>::new(SpirvWord(1));
let mut ptx_impl_imports = HashMap::new();
let directives = ast
@@ -56,17 +57,10 @@ pub fn to_spirv_module<'input>(ast: ast::Module<'input>) -> Result<Module, Trans
})?;
normalize_variable_decls(&mut directives);
let denorm_information = compute_denorm_information(&directives);
- let (spirv, kernel_info, build_options) =
- emit_spirv::run(builder, &id_defs, call_map, denorm_information, directives)?;
+ let llvm_ir = emit_llvm::run(&id_defs, call_map, directives)?;
Ok(Module {
- spirv,
- kernel_info,
- should_link_ptx_impl: if must_link_ptx_impl {
- Some((ZLUDA_PTX_IMPL_INTEL, ZLUDA_PTX_IMPL_AMD))
- } else {
- None
- },
- build_options,
+ llvm_ir,
+ kernel_info: HashMap::new(),
})
}
@@ -187,22 +181,14 @@ fn to_ssa<'input, 'b>(
}
pub struct Module {
- pub spirv: dr::Module,
+ pub llvm_ir: emit_llvm::MemoryBuffer,
pub kernel_info: HashMap<String, KernelInfo>,
- pub should_link_ptx_impl: Option<(&'static [u8], &'static [u8])>,
- pub build_options: CString,
-}
-
-impl Module {
- pub fn assemble(&self) -> Vec<u32> {
- self.spirv.assemble()
- }
}
struct GlobalStringIdResolver<'input> {
current_id: SpirvWord,
variables: HashMap<Cow<'input, str>, SpirvWord>,
- reverse_variables: HashMap<SpirvWord, &'input str>,
+ pub(crate) reverse_variables: HashMap<SpirvWord, &'input str>,
variables_type_check: HashMap<SpirvWord, Option<(ast::Type, ast::StateSpace, bool)>>,
special_registers: SpecialRegistersMap,
fns: HashMap<SpirvWord, FnSigMapper<'input>>,
@@ -611,6 +597,7 @@ fn error_unreachable() -> TranslateError {
TranslateError::Unreachable
}
+#[cfg(debug_assertions)]
fn error_unknown_symbol() -> TranslateError {
panic!()
}
@@ -620,6 +607,7 @@ fn error_unknown_symbol() -> TranslateError {
TranslateError::UnknownSymbol
}
+#[cfg(debug_assertions)]
fn error_mismatched_type() -> TranslateError {
panic!()
}