diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h @@ -135,14 +135,24 @@ std::unique_ptr createX86WinCOFFObjectWriter(bool Is64Bit); -/// Returns the sub or super register of a specific X86 register. -/// e.g. getX86SubSuperRegister(X86::EAX, 16) returns X86::AX. -/// Aborts on error. -MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false); - -/// Returns the sub or super register of a specific X86 register. -/// Like getX86SubSuperRegister() but returns 0 on error. -MCRegister getX86SubSuperRegisterOrZero(MCRegister, unsigned, +/// \param Reg speicifed register. +/// \param Size the bit size of returned register. +/// \param High requires the high register. +/// +/// \returns the sub or super register of a specific X86 register, if the +/// 8-bit high register does not exist, a 16-bit register will be attempted +/// to return. +MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size, + bool High = false); + +/// \param Reg speicifed register. +/// \param Size the bit size of returned register. +/// \param High requires the high register. +/// +/// \returns the sub or super register of a specific X86 register, if the +/// 8-bit high register does not exist, a 16-bit register will be attempted +/// to return. X86::NoRegister will be returned if there is no such a register. +MCRegister getX86SubSuperRegisterOrZero(MCRegister Reg, unsigned Size, bool High = false); } // End llvm namespace diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -749,15 +749,7 @@ case 8: if (High) { switch (Reg.id()) { - default: return getX86SubSuperRegisterOrZero(Reg, 64); - case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI: - return X86::SI; - case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI: - return X86::DI; - case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP: - return X86::BP; - case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP: - return X86::SP; + default: return getX86SubSuperRegisterOrZero(Reg, 16); case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX: return X86::AH; case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX: @@ -915,10 +907,9 @@ } } -MCRegister llvm::getX86SubSuperRegister(MCRegister Reg, unsigned Size, bool High) { +MCRegister llvm::getX86SubSuperRegister(MCRegister Reg, unsigned Size, + bool High) { MCRegister Res = getX86SubSuperRegisterOrZero(Reg, Size, High); - assert(Res != X86::NoRegister && "Unexpected register or VT"); + assert(Res != X86::NoRegister && "Unexpected register or size"); return Res; } - -