@@ -15,6 +15,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
1515 args : & [ mir:: Operand < ' tcx > ] ,
1616 ret : CPlace < ' tcx > ,
1717 target : Option < BasicBlock > ,
18+ span : Span ,
1819) {
1920 match intrinsic {
2021 "llvm.x86.sse2.pause" | "llvm.aarch64.isb" => {
@@ -718,6 +719,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
718719 }
719720
720721 "llvm.x86.pclmulqdq" => {
722+ // FIXME use inline asm
721723 // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_clmulepi64_si128&ig_expand=772
722724 intrinsic_args ! ( fx, args => ( a, b, imm8) ; intrinsic) ;
723725
@@ -779,6 +781,160 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
779781 ret. place_lane ( fx, 1 ) . to_ptr ( ) . store ( fx, res2, MemFlags :: trusted ( ) ) ;
780782 }
781783
784+ "llvm.x86.aesni.aeskeygenassist" => {
785+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aeskeygenassist_si128&ig_expand=261
786+ intrinsic_args ! ( fx, args => ( a, _imm8) ; intrinsic) ;
787+
788+ let a = a. load_scalar ( fx) ;
789+
790+ let imm8 = if let Some ( imm8) = crate :: constant:: mir_operand_get_const_val ( fx, & args[ 1 ] )
791+ {
792+ imm8
793+ } else {
794+ fx. tcx . sess . span_fatal (
795+ span,
796+ "Index argument for `_mm_aeskeygenassist_si128` is not a constant" ,
797+ ) ;
798+ } ;
799+
800+ let imm8 = imm8. try_to_u8 ( ) . unwrap_or_else ( |_| panic ! ( "kind not scalar: {:?}" , imm8) ) ;
801+
802+ codegen_inline_asm_inner (
803+ fx,
804+ & [ InlineAsmTemplatePiece :: String ( format ! ( "aeskeygenassist xmm0, xmm0, {imm8}" ) ) ] ,
805+ & [ CInlineAsmOperand :: InOut {
806+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
807+ _late : true ,
808+ in_value : a,
809+ out_place : Some ( ret) ,
810+ } ] ,
811+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
812+ ) ;
813+ }
814+
815+ "llvm.x86.aesni.aesimc" => {
816+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesimc_si128&ig_expand=260
817+ intrinsic_args ! ( fx, args => ( a) ; intrinsic) ;
818+
819+ let a = a. load_scalar ( fx) ;
820+
821+ codegen_inline_asm_inner (
822+ fx,
823+ & [ InlineAsmTemplatePiece :: String ( "aesimc xmm0, xmm0" . to_string ( ) ) ] ,
824+ & [ CInlineAsmOperand :: InOut {
825+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
826+ _late : true ,
827+ in_value : a,
828+ out_place : Some ( ret) ,
829+ } ] ,
830+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
831+ ) ;
832+ }
833+
834+ "llvm.x86.aesni.aesenc" => {
835+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesenc_si128&ig_expand=252
836+ intrinsic_args ! ( fx, args => ( a, round_key) ; intrinsic) ;
837+
838+ let a = a. load_scalar ( fx) ;
839+ let round_key = round_key. load_scalar ( fx) ;
840+
841+ codegen_inline_asm_inner (
842+ fx,
843+ & [ InlineAsmTemplatePiece :: String ( "aesenc xmm0, xmm1" . to_string ( ) ) ] ,
844+ & [
845+ CInlineAsmOperand :: InOut {
846+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
847+ _late : true ,
848+ in_value : a,
849+ out_place : Some ( ret) ,
850+ } ,
851+ CInlineAsmOperand :: In {
852+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm1) ) ,
853+ value : round_key,
854+ } ,
855+ ] ,
856+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
857+ ) ;
858+ }
859+
860+ "llvm.x86.aesni.aesenclast" => {
861+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesenclast_si128&ig_expand=257
862+ intrinsic_args ! ( fx, args => ( a, round_key) ; intrinsic) ;
863+
864+ let a = a. load_scalar ( fx) ;
865+ let round_key = round_key. load_scalar ( fx) ;
866+
867+ codegen_inline_asm_inner (
868+ fx,
869+ & [ InlineAsmTemplatePiece :: String ( "aesenclast xmm0, xmm1" . to_string ( ) ) ] ,
870+ & [
871+ CInlineAsmOperand :: InOut {
872+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
873+ _late : true ,
874+ in_value : a,
875+ out_place : Some ( ret) ,
876+ } ,
877+ CInlineAsmOperand :: In {
878+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm1) ) ,
879+ value : round_key,
880+ } ,
881+ ] ,
882+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
883+ ) ;
884+ }
885+
886+ "llvm.x86.aesni.aesdec" => {
887+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesdec_si128&ig_expand=242
888+ intrinsic_args ! ( fx, args => ( a, round_key) ; intrinsic) ;
889+
890+ let a = a. load_scalar ( fx) ;
891+ let round_key = round_key. load_scalar ( fx) ;
892+
893+ codegen_inline_asm_inner (
894+ fx,
895+ & [ InlineAsmTemplatePiece :: String ( "aesdec xmm0, xmm1" . to_string ( ) ) ] ,
896+ & [
897+ CInlineAsmOperand :: InOut {
898+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
899+ _late : true ,
900+ in_value : a,
901+ out_place : Some ( ret) ,
902+ } ,
903+ CInlineAsmOperand :: In {
904+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm1) ) ,
905+ value : round_key,
906+ } ,
907+ ] ,
908+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
909+ ) ;
910+ }
911+
912+ "llvm.x86.aesni.aesdeclast" => {
913+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesdeclast_si128&ig_expand=247
914+ intrinsic_args ! ( fx, args => ( a, round_key) ; intrinsic) ;
915+
916+ let a = a. load_scalar ( fx) ;
917+ let round_key = round_key. load_scalar ( fx) ;
918+
919+ codegen_inline_asm_inner (
920+ fx,
921+ & [ InlineAsmTemplatePiece :: String ( "aesdeclast xmm0, xmm1" . to_string ( ) ) ] ,
922+ & [
923+ CInlineAsmOperand :: InOut {
924+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm0) ) ,
925+ _late : true ,
926+ in_value : a,
927+ out_place : Some ( ret) ,
928+ } ,
929+ CInlineAsmOperand :: In {
930+ reg : InlineAsmRegOrRegClass :: Reg ( InlineAsmReg :: X86 ( X86InlineAsmReg :: xmm1) ) ,
931+ value : round_key,
932+ } ,
933+ ] ,
934+ InlineAsmOptions :: NOSTACK | InlineAsmOptions :: PURE | InlineAsmOptions :: NOMEM ,
935+ ) ;
936+ }
937+
782938 "llvm.x86.avx.ptestz.256" => {
783939 // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_testz_si256&ig_expand=6945
784940 intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
0 commit comments