hi, i am struggling to understand how MRMDestReg is used in X86. in X86InstrFormat.td, we have this: class Format<bits<7> val> { bits<7> Value val; } def MRMDestReg : Format<3> i think eventually, MRMDestReg is mapped back to ModMRM byte. but this still doesnt make sense to me why MRMDestReg is defined this way, and how it is mapped back to ModRM byte. any hint please? thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140424/2568625f/attachment.html>
Craig Topper
2014-Apr-24 05:46 UTC
[LLVMdev] how to interpret MRMDestReg in X86InstrFormat.td?
MRMDestReg means that 2 register operands are encoded in the modrm byte of the instruction. Operand 0 will be encoded in the r/m field. The other operand will be encoded in the reg field. And the mod field will be 0b11. The format<3> just represent a enum value that represents this encoding form. MRMSrcReg is similar but operand 0 is in reg and operand 1 is in r/m. MRMDestMem means that operand 0 is memory and is encoded in mod and r/m. And operand 1 is in reg. MRMSrcMem means that operand 0 is a register in reg. Operand 1 is memory in mod and r/m. MRM0r means that a single register operand is encoded in mod(0b11) and r/m. Reg will be explicitly 0. MRM0m means that a single memory operand is encoded in mod(not 0b11) and r/m. Reg will be explicitly 0. There are additional formats for specifying nearly the entire modrm byte. Plus some other variations. The translation from the encoding enum into mod rm byte is in X86MCCodeEmitter.cpp. On Wed, Apr 23, 2014 at 8:30 PM, Jun Koi <junkoi2004 at gmail.com> wrote:> hi, > > i am struggling to understand how MRMDestReg is used in X86. > > in X86InstrFormat.td, we have this: > > > class Format<bits<7> val> { > bits<7> Value > val; > > } > def MRMDestReg : Format<3> > > > i think eventually, MRMDestReg is mapped back to ModMRM byte. but this > still doesnt make sense to me why MRMDestReg is defined this way, and how > it is mapped back to ModRM byte. > > any hint please? > > thanks! > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- ~Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140423/0a7e2260/attachment.html>
On Thu, Apr 24, 2014 at 1:46 PM, Craig Topper <craig.topper at gmail.com>wrote:> MRMDestReg means that 2 register operands are encoded in the modrm byte of > the instruction. Operand 0 will be encoded in the r/m field. The other > operand will be encoded in the reg field. And the mod field will be 0b11. > > The format<3> just represent a enum value that represents this encoding > form. > > MRMSrcReg is similar but operand 0 is in reg and operand 1 is in r/m. > > MRMDestMem means that operand 0 is memory and is encoded in mod and r/m. > And operand 1 is in reg. > > MRMSrcMem means that operand 0 is a register in reg. Operand 1 is memory > in mod and r/m. > > MRM0r means that a single register operand is encoded in mod(0b11) and > r/m. Reg will be explicitly 0. > > MRM0m means that a single memory operand is encoded in mod(not 0b11) and > r/m. Reg will be explicitly 0. > > There are additional formats for specifying nearly the entire modrm byte. > Plus some other variations. > > The translation from the encoding enum into mod rm byte is in > X86MCCodeEmitter.cpp. > >awesome! but why there are 2 X86MCCodeEmitter.cp? lib/Target/X86/X86CodeEmitter.cpp lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp this is confused, as a quick glance can tell me that there are a lot of overlap between these 2 files. thanks. Jun> On Wed, Apr 23, 2014 at 8:30 PM, Jun Koi <junkoi2004 at gmail.com> wrote: > >> hi, >> >> i am struggling to understand how MRMDestReg is used in X86. >> >> in X86InstrFormat.td, we have this: >> >> >> class Format<bits<7> val> { >> bits<7> Value >> val; >> >> } >> def MRMDestReg : Format<3> >> >> >> i think eventually, MRMDestReg is mapped back to ModMRM byte. but this >> still doesnt make sense to me why MRMDestReg is defined this way, and how >> it is mapped back to ModRM byte. >> >> any hint please? >> >> thanks! >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > > -- > ~Craig >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140424/99d179ef/attachment.html>
Reasonably Related Threads
- x86 instruction format which takes a single 64-bit immediate
- Issues in Vector Add Instruction Machine Code Emission
- Issues in Vector Add Instruction Machine Code Emission
- Issues in Vector Add Instruction Machine Code Emission
- Issues in Vector Add Instruction Machine Code Emission