[llvm] 9f92d46 - Revert "[NFC][X86] Refine code in X86AsmBackend"
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 08:48:53 PDT 2020
When reverting *please* state why.
Philip
On 4/2/20 12:58 AM, Shengchen Kan via llvm-commits wrote:
> Author: Shengchen Kan
> Date: 2020-04-02T15:57:06+08:00
> New Revision: 9f92d4612fa3fc41cd1ab60ec905db7b69ca2ccc
>
> URL: https://github.com/llvm/llvm-project/commit/9f92d4612fa3fc41cd1ab60ec905db7b69ca2ccc
> DIFF: https://github.com/llvm/llvm-project/commit/9f92d4612fa3fc41cd1ab60ec905db7b69ca2ccc.diff
>
> LOG: Revert "[NFC][X86] Refine code in X86AsmBackend"
>
> This reverts commit a157cde0ac0a804b49f50df0a6faae7416ac3fb4.
>
> Added:
>
>
> Modified:
> llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
> index 26d7856d78eb..c2eb78bd056d 100644
> --- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
> +++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
> @@ -494,23 +494,6 @@ static bool hasInterruptDelaySlot(const MCInst &Inst) {
> return false;
> }
>
> -/// \returns the fragment size if it has instructions, otherwise returns 0.
> -static size_t getSizeForInstFragment(const MCFragment *F) {
> - if (!F)
> - return 0;
> - // MCEncodedFragmentWithContents being templated makes this tricky.
> - switch (F->getKind()) {
> - default:
> - llvm_unreachable("Unknown fragment with instructions!");
> - case MCFragment::FT_Data:
> - return cast<MCDataFragment>(*F).getContents().size();
> - case MCFragment::FT_Relaxable:
> - return cast<MCRelaxableFragment>(*F).getContents().size();
> - case MCFragment::FT_CompactEncodedInst:
> - return cast<MCCompactEncodedInstFragment>(*F).getContents().size();
> - }
> -}
> -
> /// Check if the instruction to be emitted is right after any data.
> static bool
> isRightAfterData(MCFragment *CurrentFragment,
> @@ -520,7 +503,7 @@ isRightAfterData(MCFragment *CurrentFragment,
> // added into the previous fragment, we need to skip them since they
> // have no contents.
> for (; isa_and_nonnull<MCDataFragment>(F); F = F->getPrevNode())
> - if (getSizeForInstFragment(F) != 0)
> + if (cast<MCDataFragment>(F)->getContents().size() != 0)
> break;
>
> // Since data is always emitted into a DataFragment, our check strategy is
> @@ -535,11 +518,28 @@ isRightAfterData(MCFragment *CurrentFragment,
> // - If the fragment is not a DataFragment, returns false.
> if (auto *DF = dyn_cast_or_null<MCDataFragment>(F))
> return DF != PrevInstPosition.first ||
> - getSizeForInstFragment(DF) != PrevInstPosition.second;
> + DF->getContents().size() != PrevInstPosition.second;
>
> return false;
> }
>
> +/// \returns the fragment size if it has instructions, otherwise returns 0.
> +static size_t getSizeForInstFragment(const MCFragment *F) {
> + if (!F || !F->hasInstructions())
> + return 0;
> + // MCEncodedFragmentWithContents being templated makes this tricky.
> + switch (F->getKind()) {
> + default:
> + llvm_unreachable("Unknown fragment with instructions!");
> + case MCFragment::FT_Data:
> + return cast<MCDataFragment>(*F).getContents().size();
> + case MCFragment::FT_Relaxable:
> + return cast<MCRelaxableFragment>(*F).getContents().size();
> + case MCFragment::FT_CompactEncodedInst:
> + return cast<MCCompactEncodedInstFragment>(*F).getContents().size();
> + }
> +}
> +
> /// Check if the instruction operand needs to be aligned.
> bool X86AsmBackend::needAlignInst(const MCInst &Inst) const {
> const MCInstrDesc &InstDesc = MCII->get(Inst.getOpcode());
> @@ -880,7 +880,7 @@ bool X86AsmBackend::padInstructionViaPrefix(MCRelaxableFragment &RF,
> if (!isFullyRelaxed(RF))
> return false;
>
> - const unsigned OldSize = getSizeForInstFragment(&RF);
> + const unsigned OldSize = RF.getContents().size();
> if (OldSize == 15)
> return false;
>
> @@ -922,7 +922,7 @@ bool X86AsmBackend::padInstructionViaRelaxation(MCRelaxableFragment &RF,
> SmallString<15> Code;
> raw_svector_ostream VecOS(Code);
> Emitter.encodeInstruction(Relaxed, VecOS, Fixups, *RF.getSubtargetInfo());
> - const unsigned OldSize = getSizeForInstFragment(&RF);
> + const unsigned OldSize = RF.getContents().size();
> const unsigned NewSize = Code.size();
> assert(NewSize >= OldSize && "size decrease during relaxation?");
> unsigned Delta = NewSize - OldSize;
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list