mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Add changes to compile rust-gpu on the latest nightly (#212)
* Update DILocation and update trait impls for nightly * rustc_codegen_spirv: Update mir Scalar handling to nightly 2020-11-043a7970848c
df4d717d0b
* More changes to compile on the latest nightly * Remove unused import warnings Co-authored-by: Marijn Suijten <marijns95@gmail.com>
This commit is contained in:
parent
32c2ea58bc
commit
cf52d51199
@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_hir::LlvmInlineAsmInner;
|
||||
use rustc_middle::mir::coverage::{
|
||||
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionIndex, Op,
|
||||
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionId, Op,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
|
||||
@ -214,29 +214,29 @@ impl<'a, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'tcx> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn add_counter_region(
|
||||
fn set_function_source_hash(&mut self, _: rustc_middle::ty::Instance<'tcx>, _: u64) -> bool {
|
||||
todo!()
|
||||
}
|
||||
fn add_coverage_counter(
|
||||
&mut self,
|
||||
_instance: Instance<'tcx>,
|
||||
_function_source_hash: u64,
|
||||
_id: CounterValueReference,
|
||||
_region: CodeRegion,
|
||||
_: Instance<'tcx>,
|
||||
_: CounterValueReference,
|
||||
_: CodeRegion,
|
||||
) -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn add_counter_expression_region(
|
||||
fn add_coverage_counter_expression(
|
||||
&mut self,
|
||||
_instance: Instance<'tcx>,
|
||||
_id: InjectedExpressionIndex,
|
||||
_lhs: ExpressionOperandId,
|
||||
_op: Op,
|
||||
_rhs: ExpressionOperandId,
|
||||
_region: CodeRegion,
|
||||
_: Instance<'tcx>,
|
||||
_: InjectedExpressionId,
|
||||
_: ExpressionOperandId,
|
||||
_: Op,
|
||||
_: ExpressionOperandId,
|
||||
_: Option<CodeRegion>,
|
||||
) -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn add_unreachable_region(&mut self, _instance: Instance<'tcx>, _region: CodeRegion) -> bool {
|
||||
fn add_coverage_unreachable(&mut self, _: Instance<'tcx>, _: CodeRegion) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@ -245,17 +245,16 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> {
|
||||
fn dbg_var_addr(
|
||||
&mut self,
|
||||
_dbg_var: Self::DIVariable,
|
||||
_scope_metadata: Self::DIScope,
|
||||
_scope_metadata: Self::DILocation,
|
||||
_variable_alloca: Self::Value,
|
||||
_direct_offset: Size,
|
||||
// NB: each offset implies a deref (i.e. they're steps in a pointer chain).
|
||||
_indirect_offsets: &[Size],
|
||||
_span: Span,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn set_source_location(&mut self, _scope: Self::DIScope, _span: Span) {
|
||||
fn set_dbg_loc(&mut self, _: Self::DILocation) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@ -375,6 +374,7 @@ impl<'a, 'tcx> BackendTypes for Builder<'a, 'tcx> {
|
||||
|
||||
type DIScope = <CodegenCx<'tcx> as BackendTypes>::DIScope;
|
||||
type DIVariable = <CodegenCx<'tcx> as BackendTypes>::DIVariable;
|
||||
type DILocation = <CodegenCx<'tcx> as BackendTypes>::DILocation;
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HasCodegen<'tcx> for Builder<'a, 'tcx> {
|
||||
|
@ -208,10 +208,12 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
|
||||
ty: Self::Type,
|
||||
) -> Self::Value {
|
||||
match scalar {
|
||||
Scalar::Raw { data, size } => match layout.value {
|
||||
Primitive::Int(int_size, int_signedness) => {
|
||||
assert_eq!(size as u64, int_size.size().bytes());
|
||||
match self.lookup_type(ty) {
|
||||
Scalar::Int(int) => {
|
||||
assert_eq!(int.size(), layout.value.size(&self.tcx));
|
||||
let data = int.to_bits(int.size()).unwrap();
|
||||
|
||||
match layout.value {
|
||||
Primitive::Int(int_size, int_signedness) => match self.lookup_type(ty) {
|
||||
SpirvType::Integer(width, spirv_signedness) => {
|
||||
assert_eq!(width as u64, int_size.size().bits());
|
||||
if !self.kernel_mode {
|
||||
@ -231,20 +233,22 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
|
||||
"scalar_to_backend Primitive::Int not supported on type {}",
|
||||
other.debug(ty, self)
|
||||
)),
|
||||
},
|
||||
Primitive::F32 => {
|
||||
let res = self.constant_f32(f32::from_bits(data as u32));
|
||||
assert_eq!(res.ty, ty);
|
||||
res
|
||||
}
|
||||
Primitive::F64 => {
|
||||
let res = self.constant_f64(f64::from_bits(data as u64));
|
||||
assert_eq!(res.ty, ty);
|
||||
res
|
||||
}
|
||||
Primitive::Pointer => {
|
||||
bug!("scalar_to_backend Primitive::Ptr is an invalid state")
|
||||
}
|
||||
}
|
||||
Primitive::F32 => {
|
||||
let res = self.constant_f32(f32::from_bits(data as u32));
|
||||
assert_eq!(res.ty, ty);
|
||||
res
|
||||
}
|
||||
Primitive::F64 => {
|
||||
let res = self.constant_f64(f64::from_bits(data as u64));
|
||||
assert_eq!(res.ty, ty);
|
||||
res
|
||||
}
|
||||
Primitive::Pointer => bug!("scalar_to_backend Primitive::Ptr is an invalid state"),
|
||||
},
|
||||
}
|
||||
Scalar::Ptr(ptr) => {
|
||||
let (base_addr, _base_addr_space) = match self.tcx.global_alloc(ptr.alloc_id) {
|
||||
GlobalAlloc::Memory(alloc) => {
|
||||
|
@ -20,9 +20,9 @@ use rustc_hir::GlobalAsm;
|
||||
use rustc_middle::mir::mono::CodegenUnit;
|
||||
use rustc_middle::mir::Body;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
|
||||
use rustc_middle::ty::{Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt, TyS};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::SourceFile;
|
||||
@ -240,6 +240,7 @@ impl<'tcx> BackendTypes for CodegenCx<'tcx> {
|
||||
type Funclet = ();
|
||||
|
||||
type DIScope = ();
|
||||
type DILocation = ();
|
||||
type DIVariable = ();
|
||||
}
|
||||
|
||||
@ -326,13 +327,26 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
||||
// Ignore.
|
||||
}
|
||||
|
||||
fn dbg_scope_fn(
|
||||
&self,
|
||||
_: rustc_middle::ty::Instance<'tcx>,
|
||||
_: &FnAbi<'tcx, &'tcx TyS<'tcx>>,
|
||||
_: Option<Self::Function>,
|
||||
) -> Self::DIScope {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn dbg_loc(&self, _: Self::DIScope, _: Option<Self::DILocation>, _: Span) -> Self::DILocation {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn create_function_debug_context(
|
||||
&self,
|
||||
_instance: Instance<'tcx>,
|
||||
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
_llfn: Self::Function,
|
||||
_mir: &Body<'_>,
|
||||
) -> Option<FunctionDebugContext<Self::DIScope>> {
|
||||
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
|
||||
// TODO: This is ignored. Do we want to implement this at some point?
|
||||
None
|
||||
}
|
||||
@ -341,7 +355,6 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
||||
&self,
|
||||
_scope_metadata: Self::DIScope,
|
||||
_file: &SourceFile,
|
||||
_defining_crate: CrateNum,
|
||||
) -> Self::DIScope {
|
||||
todo!()
|
||||
}
|
||||
@ -352,7 +365,6 @@ impl<'tcx> DebugInfoMethods<'tcx> for CodegenCx<'tcx> {
|
||||
|
||||
fn create_dbg_var(
|
||||
&self,
|
||||
_dbg_context: &FunctionDebugContext<Self::DIScope>,
|
||||
_variable_name: Symbol,
|
||||
_variable_type: Ty<'tcx>,
|
||||
_scope_metadata: Self::DIScope,
|
||||
|
@ -151,23 +151,19 @@ fn is_blocklisted_fn(symbol_name: &str) -> bool {
|
||||
fn target_options() -> Target {
|
||||
Target {
|
||||
llvm_target: "no-llvm".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
pointer_width: 32,
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_os: "unknown".to_string(),
|
||||
target_env: String::new(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".to_string(),
|
||||
arch: "spirv".to_string(),
|
||||
linker_flavor: LinkerFlavor::Ld,
|
||||
options: TargetOptions {
|
||||
allows_weak_linkage: false,
|
||||
crt_static_allows_dylibs: true,
|
||||
dll_prefix: "".to_string(),
|
||||
dll_suffix: ".spv".to_string(),
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
emit_debug_gdb_scripts: false,
|
||||
allows_weak_linkage: false,
|
||||
dynamic_linking: true,
|
||||
crt_static_allows_dylibs: true,
|
||||
emit_debug_gdb_scripts: false,
|
||||
linker_flavor: LinkerFlavor::Ld,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
target_os: "unknown".to_string(),
|
||||
// TODO: Investigate if main_needs_argc_argv is useful (for building exes)
|
||||
main_needs_argc_argv: false,
|
||||
..Default::default()
|
||||
|
@ -52,6 +52,7 @@ static SRC_PREFIX: &str = r#"#![no_std]
|
||||
#![feature(lang_items, register_attr)]
|
||||
#![register_attr(spirv)]
|
||||
use core::panic::PanicInfo;
|
||||
#[allow(unused_imports)]
|
||||
use spirv_std::*;
|
||||
#[panic_handler]
|
||||
fn panic(_: &PanicInfo) -> ! {
|
||||
|
@ -80,7 +80,7 @@ impl Optimizer for CompiledOptimizer {
|
||||
ctx: *mut std::ffi::c_void,
|
||||
) {
|
||||
unsafe {
|
||||
let ctx: &mut Ctx<'_> = &mut *(ctx as *mut Ctx);
|
||||
let ctx: &mut Ctx<'_> = &mut *(ctx as *mut Ctx<'_>);
|
||||
|
||||
let msg = error::Message::from_parts(level, source, source_pos, msg);
|
||||
|
||||
|
@ -9,7 +9,7 @@ use ash::extensions::ext::DebugUtils;
|
||||
use ash::extensions::khr::{Surface, Swapchain};
|
||||
use ash::util::*;
|
||||
use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
||||
use ash::{vk, Device, Entry, Instance};
|
||||
use ash::{vk, Device, Instance};
|
||||
use std::borrow::Cow;
|
||||
use std::default::Default;
|
||||
use std::ffi::{CStr, CString};
|
||||
@ -159,7 +159,7 @@ pub struct ExampleBase {
|
||||
#[cfg(target_os = "macos")]
|
||||
pub entry: ash_molten::MoltenEntry,
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub entry: Entry,
|
||||
pub entry: ash::Entry,
|
||||
pub instance: Instance,
|
||||
pub device: Device,
|
||||
pub surface_loader: Surface,
|
||||
@ -240,7 +240,7 @@ impl ExampleBase {
|
||||
if #[cfg(target_os = "macos")] {
|
||||
let entry = ash_molten::MoltenEntry::load().unwrap();
|
||||
} else {
|
||||
let entry = Entry::new().unwrap();
|
||||
let entry = ash::Entry::new().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
nightly-2020-10-25
|
||||
nightly-2020-11-09
|
||||
|
Loading…
Reference in New Issue
Block a user