diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 4bd2e0f50f9..47b7772bb62 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -1285,6 +1285,15 @@ def int_aarch64_sve_dup : AdvSIMD_SVE_DUP_Intrinsic; def int_aarch64_sve_index : AdvSIMD_SVE_Index_Intrinsic; +// +// Address calculation +// + +def int_aarch64_sve_adrb : AdvSIMD_2VectorArg_Intrinsic; +def int_aarch64_sve_adrh : AdvSIMD_2VectorArg_Intrinsic; +def int_aarch64_sve_adrw : AdvSIMD_2VectorArg_Intrinsic; +def int_aarch64_sve_adrd : AdvSIMD_2VectorArg_Intrinsic; + // // Integer arithmetic // diff --git a/lib/Target/AArch64/AArch64SVEInstrInfo.td b/lib/Target/AArch64/AArch64SVEInstrInfo.td index d5cd0405f6c..2974fe12399 100644 --- a/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ b/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -917,6 +917,24 @@ multiclass sve_prefetch; defm ADR_LSL_ZZZ_D : sve_int_bin_cons_misc_0_a_64_lsl<0b11, "adr">; + def : Pat<(nxv4i32 (int_aarch64_sve_adrb nxv4i32:$Op1, nxv4i32:$Op2)), + (ADR_LSL_ZZZ_S_0 $Op1, $Op2)>; + def : Pat<(nxv4i32 (int_aarch64_sve_adrh nxv4i32:$Op1, nxv4i32:$Op2)), + (ADR_LSL_ZZZ_S_1 $Op1, $Op2)>; + def : Pat<(nxv4i32 (int_aarch64_sve_adrw nxv4i32:$Op1, nxv4i32:$Op2)), + (ADR_LSL_ZZZ_S_2 $Op1, $Op2)>; + def : Pat<(nxv4i32 (int_aarch64_sve_adrd nxv4i32:$Op1, nxv4i32:$Op2)), + (ADR_LSL_ZZZ_S_3 $Op1, $Op2)>; + + def : Pat<(nxv2i64 (int_aarch64_sve_adrb nxv2i64:$Op1, nxv2i64:$Op2)), + (ADR_LSL_ZZZ_D_0 $Op1, $Op2)>; + def : Pat<(nxv2i64 (int_aarch64_sve_adrh nxv2i64:$Op1, nxv2i64:$Op2)), + (ADR_LSL_ZZZ_D_1 $Op1, $Op2)>; + def : Pat<(nxv2i64 (int_aarch64_sve_adrw nxv2i64:$Op1, nxv2i64:$Op2)), + (ADR_LSL_ZZZ_D_2 $Op1, $Op2)>; + def : Pat<(nxv2i64 (int_aarch64_sve_adrd nxv2i64:$Op1, nxv2i64:$Op2)), + (ADR_LSL_ZZZ_D_3 $Op1, $Op2)>; + defm TBL_ZZZ : sve_int_perm_tbl<"tbl", AArch64tbl>; defm ZIP1_ZZZ : sve_int_perm_bin_perm_zz<0b000, "zip1", AArch64zip1>; diff --git a/test/CodeGen/AArch64/sve-intrinsics-adr.ll b/test/CodeGen/AArch64/sve-intrinsics-adr.ll new file mode 100644 index 00000000000..461a860d819 --- /dev/null +++ b/test/CodeGen/AArch64/sve-intrinsics-adr.ll @@ -0,0 +1,101 @@ +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -verify-machineinstrs < %s | FileCheck %s + +; +; ADRB +; + +define @adrb_i32( %a, %b) { +; CHECK-LABEL: adrb_i32: +; CHECK: adr z0.s, [z0.s, z1.s] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrb.nxv4i32( %a, + %b) + ret %out +} + +define @adrb_i64( %a, %b) { +; CHECK-LABEL: adrb_i64: +; CHECK: adr z0.d, [z0.d, z1.d] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrb.nxv2i64( %a, + %b) + ret %out +} + +; +; ADRH +; + +define @adrh_i32( %a, %b) { +; CHECK-LABEL: adrh_i32: +; CHECK: adr z0.s, [z0.s, z1.s, lsl #1] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrh.nxv4i32( %a, + %b) + ret %out +} + +define @adrh_i64( %a, %b) { +; CHECK-LABEL: adrh_i64: +; CHECK: adr z0.d, [z0.d, z1.d, lsl #1] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrh.nxv2i64( %a, + %b) + ret %out +} + +; +; ADRW +; + +define @adrw_i32( %a, %b) { +; CHECK-LABEL: adrw_i32: +; CHECK: adr z0.s, [z0.s, z1.s, lsl #2] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrw.nxv4i32( %a, + %b) + ret %out +} + +define @adrw_i64( %a, %b) { +; CHECK-LABEL: adrw_i64: +; CHECK: adr z0.d, [z0.d, z1.d, lsl #2] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrw.nxv2i64( %a, + %b) + ret %out +} + +; +; ADRD +; + +define @adrd_i32( %a, %b) { +; CHECK-LABEL: adrd_i32: +; CHECK: adr z0.s, [z0.s, z1.s, lsl #3] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrd.nxv4i32( %a, + %b) + ret %out +} + +define @adrd_i64( %a, %b) { +; CHECK-LABEL: adrd_i64: +; CHECK: adr z0.d, [z0.d, z1.d, lsl #3] +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.adrd.nxv2i64( %a, + %b) + ret %out +} + +declare @llvm.aarch64.sve.adrb.nxv4i32(, ) +declare @llvm.aarch64.sve.adrb.nxv2i64(, ) + +declare @llvm.aarch64.sve.adrh.nxv4i32(, ) +declare @llvm.aarch64.sve.adrh.nxv2i64(, ) + +declare @llvm.aarch64.sve.adrw.nxv4i32(, ) +declare @llvm.aarch64.sve.adrw.nxv2i64(, ) + +declare @llvm.aarch64.sve.adrd.nxv4i32(, ) +declare @llvm.aarch64.sve.adrd.nxv2i64(, )