Fixed compile errors

This commit is contained in:
Sylvester Hesp 2022-09-07 14:43:58 +02:00 committed by Eduard-Mihai Burtescu
parent 0b700b9485
commit fff9e0cec3
3 changed files with 27 additions and 9 deletions

View File

@ -981,14 +981,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// ignore
}
fn type_metadata(&mut self, _function: Self::Function, _typeid: String) {
// ignore
}
fn typeid_metadata(&mut self, _typeid: String) -> Self::Value {
todo!()
}
fn store(&mut self, val: Self::Value, ptr: Self::Value, _align: Align) -> Self::Value {
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
SpirvType::Pointer { pointee } => pointee,

View File

@ -18,7 +18,7 @@ use rustc_codegen_ssa::mir::operand::OperandValue;
use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::traits::{
AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods,
DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods,
DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods,
};
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_middle::mir::coverage::{
@ -439,3 +439,13 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, 'tcx> {
self.cx.handle_fn_abi_err(err, span, fn_abi_request)
}
}
impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> {
fn set_type_metadata(&self, _function: Self::Function, _typeid: String) {
// ignore
}
fn typeid_metadata(&self, _typeid: String) -> Self::Value {
todo!()
}
}

View File

@ -289,6 +289,22 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
self.get_fn_addr(fn_instance.polymorphize(self.tcx)),
self.data_layout().instruction_address_space,
),
GlobalAlloc::VTable(vty, trait_ref) => {
let alloc = self
.tcx
.global_alloc(self.tcx.vtable_allocation((vty, trait_ref)))
.unwrap_memory();
let pointee = match self.lookup_type(ty) {
SpirvType::Pointer { pointee } => pointee,
other => self.tcx.sess.fatal(&format!(
"GlobalAlloc::VTable type not implemented: {}",
other.debug(ty, self)
)),
};
let init = self.create_const_alloc(alloc, pointee);
let value = self.static_addr_of(init, alloc.inner().align, None);
(value, AddressSpace::DATA)
}
GlobalAlloc::Static(def_id) => {
assert!(self.tcx.is_static(def_id));
assert!(!self.tcx.is_thread_local_static(def_id));