[X86][MC] Support enhanced relaxation for branch align
authorShengchen Kan <shengchen.kan@intel.com>
Tue, 7 Apr 2020 04:27:45 +0000 (12:27 +0800)
committerShengchen Kan <shengchen.kan@intel.com>
Wed, 8 Apr 2020 11:08:19 +0000 (19:08 +0800)
commit916044d819c8e383fe1cd99190e3ff572d80f48f
tree5ac6b61bd866839d6042ce890b7e600edb264312
parent893df2032d480bf791a69fe965c3ca4ef500145b
[X86][MC] Support enhanced relaxation for branch align

Summary:
Since D75300 has been landed, I want to support enhanced relaxation when we need to align branches and allow prefix padding. "Enhanced Relaxtion" means we allow an instruction that could not be traditionally relaxed to be emitted into RelaxableFragment so that we increase its length by adding prefixes for optimization.

The motivation is straightforward, RelaxFragment is mostly for relative jumps and we can not increase the length of jumps when we need to align them, so if we need to achieve D75300's purpose (reducing the bytes of nops) when need to align jumps, we have to make more instructions "relaxable".

Reviewers: reames, MaskRay, craig.topper, LuoYuanke, jyknight

Reviewed By: reames

Subscribers: hiraditya, llvm-commits, annita.zhang

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76286
llvm/include/llvm/MC/MCAsmBackend.h
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
llvm/test/MC/X86/align-branch-enhanced-relaxation.s [new file with mode: 0644]