@@ -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_codegen_ssa:: base:: { compare_simd_types, wants_msvc_seh} ;
11
13
use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
12
14
use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
@@ -22,6 +24,7 @@ use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
22
24
use rustc_target:: spec:: PanicStrategy ;
23
25
24
26
use std:: cmp:: Ordering ;
27
+ use std:: ffi:: CStr ;
25
28
use std:: iter;
26
29
27
30
fn get_simple_intrinsic ( cx : & CodegenCx < ' ll , ' _ > , name : Symbol ) -> Option < & ' ll Value > {
@@ -73,6 +76,9 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<&'ll Va
73
76
Some ( cx. get_intrinsic ( & llvm_name) )
74
77
}
75
78
79
+ const EMPTY_C_STR : & CStr = unsafe { CStr :: from_bytes_with_nul_unchecked ( b"\0 " ) } ;
80
+ const UNNAMED : * const c_char = EMPTY_C_STR . as_ptr ( ) ;
81
+
76
82
impl IntrinsicCallMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
77
83
fn codegen_intrinsic_call (
78
84
& mut self ,
@@ -303,6 +309,27 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
303
309
}
304
310
}
305
311
312
+ sym:: amdgcn_dispatch_ptr => {
313
+ // This intrinsic returns a pointer in the const addr space
314
+ // which can't be encoded in source level Rust.
315
+
316
+ let f = self . cx ( ) . get_intrinsic ( "llvm.amdgcn.dispatch.ptr" ) ;
317
+ let val = self . call ( f, & [ ] , None ) ;
318
+ // XXX Needs the proper address space patch
319
+ unsafe { llvm:: LLVMBuildAddrSpaceCast ( self . llbuilder , val,
320
+ llret_ty, UNNAMED ) }
321
+ }
322
+ sym:: amdgcn_queue_ptr => {
323
+ // This intrinsic returns a pointer in the const addr space
324
+ // which can't be encoded in source level Rust.
325
+
326
+ let f = self . cx ( ) . get_intrinsic ( "llvm.amdgcn.queue.ptr" ) ;
327
+ let val = self . call ( f, & [ ] , None ) ;
328
+ // XXX Needs the proper address space patch
329
+ unsafe { llvm:: LLVMBuildAddrSpaceCast ( self . llbuilder , val,
330
+ llret_ty, UNNAMED ) }
331
+ }
332
+
306
333
_ => bug ! ( "unknown intrinsic '{}'" , name) ,
307
334
} ;
308
335
0 commit comments