@@ -6,8 +6,7 @@ pub(super) mod isle;
66use crate :: data_value:: DataValue ;
77use crate :: ir:: {
88 condcodes:: { CondCode , FloatCC , IntCC } ,
9- types, AbiParam , ExternalName , Inst as IRInst , InstructionData , LibCall , Opcode , Signature ,
10- Type ,
9+ types, ExternalName , Inst as IRInst , InstructionData , LibCall , Opcode , Type ,
1110} ;
1211use crate :: isa:: x64:: abi:: * ;
1312use crate :: isa:: x64:: inst:: args:: * ;
@@ -573,29 +572,13 @@ fn emit_fcmp<C: LowerCtx<I = Inst>>(
573572 cond_result
574573}
575574
576- fn make_libcall_sig < C : LowerCtx < I = Inst > > (
577- ctx : & mut C ,
578- insn : IRInst ,
579- call_conv : CallConv ,
580- ) -> Signature {
581- let mut sig = Signature :: new ( call_conv) ;
582- for i in 0 ..ctx. num_inputs ( insn) {
583- sig. params . push ( AbiParam :: new ( ctx. input_ty ( insn, i) ) ) ;
584- }
585- for i in 0 ..ctx. num_outputs ( insn) {
586- sig. returns . push ( AbiParam :: new ( ctx. output_ty ( insn, i) ) ) ;
587- }
588- sig
589- }
590-
591575fn emit_vm_call < C : LowerCtx < I = Inst > > (
592576 ctx : & mut C ,
593577 flags : & Flags ,
594578 triple : & Triple ,
595579 libcall : LibCall ,
596- insn : IRInst ,
597- inputs : SmallVec < [ InsnInput ; 4 ] > ,
598- outputs : SmallVec < [ InsnOutput ; 2 ] > ,
580+ inputs : & [ Reg ] ,
581+ outputs : & [ Writable < Reg > ] ,
599582) -> CodegenResult < ( ) > {
600583 let extname = ExternalName :: LibCall ( libcall) ;
601584
@@ -607,7 +590,7 @@ fn emit_vm_call<C: LowerCtx<I = Inst>>(
607590
608591 // TODO avoid recreating signatures for every single Libcall function.
609592 let call_conv = CallConv :: for_libcall ( flags, CallConv :: triple_default ( triple) ) ;
610- let sig = make_libcall_sig ( ctx , insn , call_conv) ;
593+ let sig = libcall . signature ( call_conv) ;
611594 let caller_conv = ctx. abi ( ) . call_conv ( ) ;
612595
613596 let mut abi = X64ABICaller :: from_func ( & sig, & extname, dist, caller_conv, flags) ?;
@@ -617,14 +600,12 @@ fn emit_vm_call<C: LowerCtx<I = Inst>>(
617600 assert_eq ! ( inputs. len( ) , abi. num_args( ) ) ;
618601
619602 for ( i, input) in inputs. iter ( ) . enumerate ( ) {
620- let arg_reg = put_input_in_reg ( ctx, * input) ;
621- abi. emit_copy_regs_to_arg ( ctx, i, ValueRegs :: one ( arg_reg) ) ;
603+ abi. emit_copy_regs_to_arg ( ctx, i, ValueRegs :: one ( * input) ) ;
622604 }
623605
624606 abi. emit_call ( ctx) ;
625607 for ( i, output) in outputs. iter ( ) . enumerate ( ) {
626- let retval_reg = get_output_reg ( ctx, * output) . only_reg ( ) . unwrap ( ) ;
627- abi. emit_copy_retval_to_regs ( ctx, i, ValueRegs :: one ( retval_reg) ) ;
608+ abi. emit_copy_retval_to_regs ( ctx, i, ValueRegs :: one ( * output) ) ;
628609 }
629610 abi. emit_stack_post_adjust ( ctx) ;
630611
@@ -810,7 +791,7 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
810791 None
811792 } ;
812793
813- if let Ok ( ( ) ) = isle:: lower ( ctx, flags, isa_flags, & outputs, insn) {
794+ if let Ok ( ( ) ) = isle:: lower ( ctx, triple , flags, isa_flags, & outputs, insn) {
814795 return Ok ( ( ) ) ;
815796 }
816797
@@ -884,6 +865,7 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
884865 | Opcode :: FvpromoteLow
885866 | Opcode :: Fdemote
886867 | Opcode :: Fvdemote
868+ | Opcode :: Fma
887869 | Opcode :: Icmp
888870 | Opcode :: Fcmp
889871 | Opcode :: Load
@@ -1974,7 +1956,11 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
19741956 ty, op
19751957 ) ,
19761958 } ;
1977- emit_vm_call ( ctx, flags, triple, libcall, insn, inputs, outputs) ?;
1959+
1960+ let input = put_input_in_reg ( ctx, inputs[ 0 ] ) ;
1961+ let dst = get_output_reg ( ctx, outputs[ 0 ] ) . only_reg ( ) . unwrap ( ) ;
1962+
1963+ emit_vm_call ( ctx, flags, triple, libcall, & [ input] , & [ dst] ) ?;
19781964 }
19791965 }
19801966
@@ -2726,8 +2712,6 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
27262712
27272713 Opcode :: Cls => unimplemented ! ( "Cls not supported" ) ,
27282714
2729- Opcode :: Fma => implemented_in_isle ( ctx) ,
2730-
27312715 Opcode :: BorNot | Opcode :: BxorNot => {
27322716 unimplemented ! ( "or-not / xor-not opcodes not implemented" ) ;
27332717 }
0 commit comments