File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1416,6 +1416,36 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
14161416 ret. write_cvalue ( fx, res) ;
14171417 }
14181418
1419+ "llvm.x86.rdtsc" => {
1420+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_rdtsc&ig_expand=5273
1421+
1422+ let res_place = CPlace :: new_stack_slot (
1423+ fx,
1424+ fx. layout_of ( Ty :: new_tup ( fx. tcx , & [ fx. tcx . types . u32 , fx. tcx . types . u32 ] ) ) ,
1425+ ) ;
1426+ let eax_place = res_place. place_field ( fx, FieldIdx :: new ( 0 ) ) ;
1427+ let edx_place = res_place. place_field ( fx, FieldIdx :: new ( 1 ) ) ;
1428+ codegen_inline_asm_inner (
1429+ fx,
1430+ & [ InlineAsmTemplatePiece :: String ( "rdtsc" . to_string ( ) ) ] ,
1431+ & [
1432+ CInlineAsmOperand :: Out {
1433+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: ax) ) ,
1434+ late : true ,
1435+ place : Some ( eax_place) ,
1436+ } ,
1437+ CInlineAsmOperand :: Out {
1438+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: dx) ) ,
1439+ late : true ,
1440+ place : Some ( edx_place) ,
1441+ } ,
1442+ ] ,
1443+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: NOMEM ,
1444+ ) ;
1445+ let res = res_place. to_cvalue ( fx) ;
1446+ ret. write_cvalue_transmute ( fx, res) ;
1447+ }
1448+
14191449 _ => {
14201450 fx. tcx
14211451 . dcx ( )
You can’t perform that action at this time.
0 commit comments