diff --git a/cranelift/codegen/src/isa/aarch64/inst.isle b/cranelift/codegen/src/isa/aarch64/inst.isle index 61f164a3ac..5b8c3eb683 100644 --- a/cranelift/codegen/src/isa/aarch64/inst.isle +++ b/cranelift/codegen/src/isa/aarch64/inst.isle @@ -2417,6 +2417,13 @@ (_ Unit (emit (MInst.VecLoadReplicate dst src size flags)))) dst)) +;; Helper for emitting `MInst.LoadExtName` instructions. +(decl load_ext_name (BoxExternalName i64) Reg) +(rule (load_ext_name extname offset) + (let ((dst WritableReg (temp_writable_reg $I64)) + (_ Unit (emit (MInst.LoadExtName dst extname offset)))) + dst)) + ;; Helper for emitting `MInst.LoadAddr` instructions. (decl load_addr (AMode) Reg) (rule (load_addr addr) diff --git a/cranelift/codegen/src/isa/aarch64/lower.isle b/cranelift/codegen/src/isa/aarch64/lower.isle index 0cee3acc08..e7e736089a 100644 --- a/cranelift/codegen/src/isa/aarch64/lower.isle +++ b/cranelift/codegen/src/isa/aarch64/lower.isle @@ -1832,6 +1832,16 @@ (rule (lower (debugtrap)) (side_effect (brk))) +;;;; Rules for `func_addr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule (lower (func_addr (func_ref_data _ extname _))) + (load_ext_name (box_external_name extname) 0)) + +;;;; Rules for `symbol_value` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule (lower (symbol_value (symbol_value_data extname _ offset))) + (load_ext_name (box_external_name extname) offset)) + ;;; Rules for `get_{frame,stack}_pointer` and `get_return_address` ;;;;;;;;;;;;; (rule (lower (get_frame_pointer)) diff --git a/cranelift/codegen/src/isa/aarch64/lower_inst.rs b/cranelift/codegen/src/isa/aarch64/lower_inst.rs index 69e795c018..7696ae0610 100644 --- a/cranelift/codegen/src/isa/aarch64/lower_inst.rs +++ b/cranelift/codegen/src/isa/aarch64/lower_inst.rs @@ -569,31 +569,13 @@ pub(crate) fn lower_insn_to_regs( panic!("trapz / trapnz / resumable_trapnz should have been removed by legalization!"); } - Opcode::FuncAddr => { - let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap(); - let (extname, _) = ctx.call_target(insn).unwrap(); - let extname = extname.clone(); - ctx.emit(Inst::LoadExtName { - rd, - name: Box::new(extname), - offset: 0, - }); - } + Opcode::FuncAddr => implemented_in_isle(ctx), Opcode::GlobalValue => { panic!("global_value should have been removed by legalization!"); } - Opcode::SymbolValue => { - let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap(); - let (extname, _, offset) = ctx.symbol_value(insn).unwrap(); - let extname = extname.clone(); - ctx.emit(Inst::LoadExtName { - rd, - name: Box::new(extname), - offset, - }); - } + Opcode::SymbolValue => implemented_in_isle(ctx), Opcode::Call | Opcode::CallIndirect => { let caller_conv = ctx.abi().call_conv();