From 13660715e677919d9a89dc6a3a77532593c3c7f6 Mon Sep 17 00:00:00 2001 From: tyb0807 Date: Tue, 18 Jan 2022 19:24:11 +0000 Subject: [PATCH] [AArch64] Modeling NZCV read/write for MOPS instructions According to the specification, MOPS instructions define/use NZCV flags as part of their semantics (see discussion in https://reviews.llvm.org/D116157). More specifically, the specification of the MOPS extension states that each memcpy/memset/memmov operation will be performed by a series of three MOPS instructions P, M and E. The P instruction writes to the NZCV flags, while the others (M and E) reads from the NZCV flags. This is part 2/4 of a series of patches split from https://reviews.llvm.org/D117405 to facilitate reviewing. Differential Revision: https://reviews.llvm.org/D117757 --- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 36 +++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 740ebd52b85f..91baf4cd11e0 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -8333,23 +8333,33 @@ let Predicates = [HasLS64] in { } let Predicates = [HasMOPS] in { - defm CPYFP : MOPSMemoryCopyInsns<0b00, "cpyfp">; - defm CPYFM : MOPSMemoryCopyInsns<0b01, "cpyfm">; - defm CPYFE : MOPSMemoryCopyInsns<0b10, "cpyfe">; + let Defs = [NZCV] in { + defm CPYFP : MOPSMemoryCopyInsns<0b00, "cpyfp">; - defm CPYP : MOPSMemoryMoveInsns<0b00, "cpyp">; - defm CPYM : MOPSMemoryMoveInsns<0b01, "cpym">; - defm CPYE : MOPSMemoryMoveInsns<0b10, "cpye">; + defm CPYP : MOPSMemoryMoveInsns<0b00, "cpyp">; - defm SETP : MOPSMemorySetInsns<0b00, "setp">; - defm SETM : MOPSMemorySetInsns<0b01, "setm">; - defm SETE : MOPSMemorySetInsns<0b10, "sete">; + defm SETP : MOPSMemorySetInsns<0b00, "setp">; + } + let Uses = [NZCV] in { + defm CPYFM : MOPSMemoryCopyInsns<0b01, "cpyfm">; + defm CPYFE : MOPSMemoryCopyInsns<0b10, "cpyfe">; + + defm CPYM : MOPSMemoryMoveInsns<0b01, "cpym">; + defm CPYE : MOPSMemoryMoveInsns<0b10, "cpye">; + + defm SETM : MOPSMemorySetInsns<0b01, "setm">; + defm SETE : MOPSMemorySetInsns<0b10, "sete">; + } } let Predicates = [HasMOPS, HasMTE] in { - defm SETGP : MOPSMemorySetTaggingInsns<0b00, "setgp">; - defm SETGM : MOPSMemorySetTaggingInsns<0b01, "setgm">; - // Can't use SETGE because it's a reserved name in TargetSelectionDAG.td - defm MOPSSETGE : MOPSMemorySetTaggingInsns<0b10, "setge">; + let Defs = [NZCV] in { + defm SETGP : MOPSMemorySetTaggingInsns<0b00, "setgp">; + } + let Uses = [NZCV] in { + defm SETGM : MOPSMemorySetTaggingInsns<0b01, "setgm">; + // Can't use SETGE because it's a reserved name in TargetSelectionDAG.td + defm MOPSSETGE : MOPSMemorySetTaggingInsns<0b10, "setge">; + } } let Defs = [X16, X17], mayStore = 1, isCodeGenOnly = 1 in