|
1 | 1 | use std::assert_matches::assert_matches;
|
2 | 2 | use std::cmp::Ordering;
|
3 | 3 |
|
4 |
| -use rustc_abi::{self as abi, Align, Float, HasDataLayout, Primitive, Size}; |
| 4 | +use rustc_abi::{self as abi, AddressSpace, Align, Float, HasDataLayout, Primitive, Size}; |
5 | 5 | use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh};
|
6 | 6 | use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
7 | 7 | use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization};
|
@@ -551,6 +551,25 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
551 | 551 | return Ok(());
|
552 | 552 | }
|
553 | 553 |
|
| 554 | + sym::dynamic_shared_memory => { |
| 555 | + // TODO Allow only on nvptx and amdgpu |
| 556 | + // TODO create only one global per module, take the maximum alignment of all calls |
| 557 | + let global = self.declare_global_in_addrspace( |
| 558 | + "", |
| 559 | + self.type_array(self.type_i8(), 0), |
| 560 | + AddressSpace::SHARED, |
| 561 | + ); |
| 562 | + // TODO Set alignment |
| 563 | + let ty::RawPtr(inner_ty, _) = ret_ty.kind() else { unreachable!() }; |
| 564 | + let alignment = self.align_of(*inner_ty).bytes() as u32; |
| 565 | + unsafe { |
| 566 | + if alignment > llvm::LLVMGetAlignment(global) { |
| 567 | + llvm::LLVMSetAlignment(global, alignment); |
| 568 | + } |
| 569 | + } |
| 570 | + self.cx().const_pointercast(global, self.type_ptr()) |
| 571 | + } |
| 572 | + |
554 | 573 | _ if name.as_str().starts_with("simd_") => {
|
555 | 574 | // Unpack non-power-of-2 #[repr(packed, simd)] arguments.
|
556 | 575 | // This gives them the expected layout of a regular #[repr(simd)] vector.
|
|
0 commit comments