diff options
| author | Manuel Drehwald <git@manuel.drehwald.info> | 2025-07-02 16:36:30 -0700 | 
|---|---|---|
| committer | Manuel Drehwald <git@manuel.drehwald.info> | 2025-07-18 16:30:42 -0700 | 
| commit | 4a1a5a42952d05533fd4309ad0f3fe290abbf57c (patch) | |
| tree | 728fe4c846fdb1f36c3c0248a4410b25144cdc8f /compiler/rustc_codegen_llvm/src/common.rs | |
| parent | 5958ebe829429e3595e8211e6cb1b0328d515ab7 (diff) | |
| download | rust-4a1a5a42952d05533fd4309ad0f3fe290abbf57c.tar.gz rust-4a1a5a42952d05533fd4309ad0f3fe290abbf57c.zip | |
gpu host code generation
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/common.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/common.rs | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index f9ab96b5789..f29fefb66f0 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -118,6 +118,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> { r } } + + pub(crate) fn const_null(&self, t: &'ll Type) -> &'ll Value { + unsafe { llvm::LLVMConstNull(t) } + } } impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> { @@ -377,6 +381,11 @@ pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> & } } +pub(crate) fn named_struct<'ll>(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value { + let len = c_uint::try_from(elts.len()).expect("LLVMConstStructInContext elements len overflow"); + unsafe { llvm::LLVMConstNamedStruct(ty, elts.as_ptr(), len) } +} + fn struct_in_context<'ll>( llcx: &'ll llvm::Context, elts: &[&'ll Value], | 
