@@ -7,6 +7,8 @@ use crate::type_of::LayoutLlvmExt;
7
7
use crate :: va_arg:: emit_va_arg;
8
8
use crate :: value:: Value ;
9
9
10
+ use libc:: c_char;
11
+
10
12
use rustc_ast as ast;
11
13
use rustc_codegen_ssa:: base:: { compare_simd_types, wants_msvc_seh} ;
12
14
use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
@@ -25,6 +27,7 @@ use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
25
27
use rustc_target:: spec:: PanicStrategy ;
26
28
27
29
use std:: cmp:: Ordering ;
30
+ use std:: ffi:: CStr ;
28
31
use std:: iter;
29
32
30
33
fn get_simple_intrinsic ( cx : & CodegenCx < ' ll , ' _ > , name : Symbol ) -> Option < & ' ll Value > {
@@ -78,6 +81,9 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<&'ll Va
78
81
Some ( cx. get_intrinsic ( & llvm_name) )
79
82
}
80
83
84
+ const EMPTY_C_STR : & CStr = unsafe { CStr :: from_bytes_with_nul_unchecked ( b"\0 " ) } ;
85
+ const UNNAMED : * const c_char = EMPTY_C_STR . as_ptr ( ) ;
86
+
81
87
impl IntrinsicCallMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
82
88
fn codegen_intrinsic_call (
83
89
& mut self ,
@@ -757,6 +763,26 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
757
763
// this is where the signed magic happens (notice the `s` in `exactsdiv`)
758
764
self . exactsdiv ( d, pointee_size)
759
765
}
766
+ sym:: amdgcn_dispatch_ptr => {
767
+ // This intrinsic returns a pointer in the const addr space
768
+ // which can't be encoded in source level Rust.
769
+
770
+ let f = self . cx ( ) . get_intrinsic ( "llvm.amdgcn.dispatch.ptr" ) ;
771
+ let val = self . call ( f, & [ ] , None ) ;
772
+ // XXX Needs the proper address space patch
773
+ unsafe { llvm:: LLVMBuildAddrSpaceCast ( self . llbuilder , val,
774
+ llret_ty, UNNAMED ) }
775
+ }
776
+ sym:: amdgcn_queue_ptr => {
777
+ // This intrinsic returns a pointer in the const addr space
778
+ // which can't be encoded in source level Rust.
779
+
780
+ let f = self . cx ( ) . get_intrinsic ( "llvm.amdgcn.queue.ptr" ) ;
781
+ let val = self . call ( f, & [ ] , None ) ;
782
+ // XXX Needs the proper address space patch
783
+ unsafe { llvm:: LLVMBuildAddrSpaceCast ( self . llbuilder , val,
784
+ llret_ty, UNNAMED ) }
785
+ }
760
786
761
787
_ => bug ! ( "unknown intrinsic '{}'" , name) ,
762
788
} ;
0 commit comments