Subtract with tag
This instruction subtracts an immediate value scaled by the Tag Granule from the address in the source register, modifies the Logical Address Tag of the address using an immediate value, and writes the result to the destination register. Tags specified in GCR_EL1.Exclude are excluded from the possible outputs when modifying the Logical Address Tag.
Variants: FEAT_MTE (ARMv8.5)
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | (0) | (0) | ||||||||||||||||||||
sf | op | S | imm6 | op3 | imm4 | Rn | Rd |
---|
SUBG <Xd|SP>, <Xn|SP>, #<uimm6>, #<uimm4>
if !IsFeatureImplemented(FEAT_MTE) then EndOfDecode(Decode_UNDEF); constant integer d = UInt(Rd); constant integer n = UInt(Rn); constant bits(4) tag_offset = imm4; constant bits(64) offset = LSL(ZeroExtend(imm6, 64), LOG2_TAG_GRANULE);
constant bits(64) operand1 = if n == 31 then SP[64] else X[n, 64]; constant bits(4) start_tag = AArch64.AllocationTagFromAddress(operand1); constant bits(16) exclude = GCR_EL1.Exclude; bits(64) result; bits(4) rtag; if AArch64.AllocationTagAccessIsEnabled(PSTATE.EL) then rtag = AArch64.ChooseNonExcludedTag(start_tag, tag_offset, exclude); else rtag = '0000'; (result, -) = AddWithCarry(operand1, NOT(offset), '1'); result = AArch64.AddressWithAllocationTag(result, rtag); if d == 31 then SP[64] = result; else X[d, 64] = result;