0

can someone explain what is the difference between the arm instructions prfm and prfum and usage of these ?

PRFUM https://developer.arm.com/documentation/dui0802/b/PRFUM

PRFM https://developer.arm.com/documentation/dui0801/g/A64-Data-Transfer-Instructions/PRFM--literal-

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Thomas
  • 489
  • 1
  • 8
  • 13
  • Same as the difference between `ldr` and `ldur`, I think. [LDUR and STUR in ARM v8](https://stackoverflow.com/q/52894765). Or is the scale factor `1` anyway, like for byte loads? In that case no diff? – Peter Cordes Jun 24 '21 at 17:12
  • The manuals don't go into detail on the machine code, but PRFM mentions a +-1MiB offset from the current position, so maybe it's using line-size as the scale factor with PC-relative instead of a register. – Peter Cordes Jun 24 '21 at 17:18
  • what part of the arm documentation do you not understand? please post the confusing sections and what you think they mean or dont mean – old_timer Jun 24 '21 at 19:53

1 Answers1

4

For questions like this, your primary source is the ARMv8 Architecture Reference manual. I happen to have the edition E.a at hand, so page numbers are going to refer to that edition.

On Page C6-1136, PRFM (immediate) is described. It allows to prefetch data that is at an offset that is a multiple of 8 in the range of 0 to +32760 relative to the value in a base register.

On Page C6-1142, PRFUM is described. It allows to prefetch data that is at any kind of offset (not just multiples of 8) in the range -256 to +255 relative to the value in a base register.

So if you need (for some reasons, like working with strings) to prefetch with byte accuracy, or you need to prefetch with a negative offset, you have to use PRFUM. On the other hand, if you want to prefetch with an offset of 256 or higher, you have to use PRFM.

Michael Karcher
  • 3,803
  • 1
  • 14
  • 25
  • At least the GNU assembler will automatically encode `PRFUM` if you write something like `PRFM PLDL1KEEP, [X0, #37]`, so you don't actually have to pay attention to the distinction. You can just think of it as two different addressing modes available to `PRFM`. It does the same with `LDR/LDUR`, `STR/STUR`. – Nate Eldredge Jun 26 '21 at 00:22
  • 1
    So this is another example of the official ARM instuctions providing a 1:1 mapping between binary opcodes and assembly language source text. There are two ways to encode an operation that can be described by `PRFM PLDL1KEEP, [X0, #32]`. To provide unique disassembler output, one of the encodings is called `PRFM`, whereas the other one is called `PRFUM`. For convenience, helpful assemblers like gas unify the two instructions with different addressing capabilities so the programmer doesn't have to worry. – Michael Karcher Jun 26 '21 at 08:49