From: Craig Topper Date: Tue, 28 Jul 2020 17:46:04 +0000 (-0700) Subject: [X86] Simplify some code in emitMemModRMByte. NFCI X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91b8c1fd0f31a548b75acb3de4dbee09847e19e5;p=platform%2Fupstream%2Fllvm.git [X86] Simplify some code in emitMemModRMByte. NFCI --- diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp index 900b4d7..25f1089 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp @@ -605,23 +605,14 @@ void X86MCCodeEmitter::emitMemModRMByte(const MCInst &MI, unsigned Op, static const unsigned SSTable[] = {~0U, 0, 1, ~0U, 2, ~0U, ~0U, ~0U, 3}; unsigned SS = SSTable[Scale.getImm()]; - if (BaseReg == 0) { - // Handle the SIB byte for the case where there is no base, see Intel - // Manual 2A, table 2-7. The displacement has already been output. - unsigned IndexRegNo; - if (IndexReg.getReg()) - IndexRegNo = getX86RegNum(IndexReg); - else // Examples: [ESP+1*+4] or [scaled idx]+disp32 (MOD=0,BASE=5) - IndexRegNo = 4; - emitSIBByte(SS, IndexRegNo, 5, OS); - } else { - unsigned IndexRegNo; - if (IndexReg.getReg()) - IndexRegNo = getX86RegNum(IndexReg); - else - IndexRegNo = 4; // For example [ESP+1*+4] - emitSIBByte(SS, IndexRegNo, getX86RegNum(Base), OS); - } + unsigned IndexRegNo = IndexReg.getReg() ? getX86RegNum(IndexReg) : 4; + + // Handle the SIB byte for the case where there is no base, see Intel + // Manual 2A, table 2-7. The displacement has already been output. + if (BaseReg == 0) + BaseRegNo = 5; + + emitSIBByte(SS, IndexRegNo, BaseRegNo, OS); // Do we need to output a displacement? if (ForceDisp8)