A known limitation for Future CPU is that the new prefixed instructions may not cross 64 Byte boundaries.
All instructions are already 4 byte aligned so the only situation where this can occur is when the prefix is in one 64 byte block and the instruction that is prefixed is at the top of the next 64 byte block. To fix this case PPCELFStreamer was added to intercept EmitInstruction. When a prefixed instruction is emitted we try to align it to 64 Bytes by adding a maximum of 4 bytes. If the prefixed instruction crosses the 64 Byte boundary then the alignment would trigger and a 4 byte nop would be added to push the instruction into the next 64 byte block.
Details
- Reviewers
power-llvm-team nemanjai hfinkel Yi-Hong.Lyu - Group Reviewers
Restricted Project - Commits
- rGf00be8da62b8: [PowerPC][Future] Prefixed Instructions 64 Byte Boundary Support
Diff Detail
Event Timeline
Other than a few minor nits, LGTM.
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp | ||
---|---|---|
14 | Maybe this should | |
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.h | ||
29 | Perhaps a comment about why we need this: // We need to keep track of the last label we emitted (only one) because // depending on whether the label is on the same line as an aligned // instruction or not, the label may refer to the instruction or the nop. | |
llvm/test/MC/PowerPC/ppc64-prefix-align.s | ||
58 | Would it be possible to add branches to LAB1 and LAB2 to show that one of them will branch to the nop and the other one won't? |
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp | ||
---|---|---|
24 | PPCMCCodeEmitter.h should be put later than PPCInstrInfo.h | |
46 | You can just initialized LastLabel in member initializer lists so the constructor could be empty. | |
107 | Remove parameter bool RelaxAll since it is unused. | |
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp | ||
17 | "PPCELFStreamer.h" should be put before "PPCTargetStreamer.h". | |
112 | Argument RelaxAll is not necessary since you no longer use it. | |
llvm/lib/Target/PowerPC/PPCInstrInfo.h | ||
70 | Why do you want to shift left NewDef_Shift+3 instead of NewDef_Shift+2? |
Perhaps a comment about why we need this: