how to interpret MRMDestReg in X86InstrFormat.td?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to interpret MRMDestReg in X86InstrFormat.td?

Jun Koi
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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: how to interpret MRMDestReg in X86InstrFormat.td?

Craig Topper
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
~Craig

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: how to interpret MRMDestReg in X86InstrFormat.td?

Jun Koi



On Thu, Apr 24, 2014 at 1:46 PM, Craig Topper <[hidden email]> 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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
~Craig


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: how to interpret MRMDestReg in X86InstrFormat.td?

Craig Topper
Yes the files are almost completely identical. The MC one is used by normal compilation. It's also used by MCJIT. The other one is only used by the "old JIT" which has yet to be completely replaced by MCJIT. Support for newer instructions like AVX2 and especially AVX512 may be incomplete in the X86CodeEmitter.cpp.


On Thu, Apr 24, 2014 at 1:45 AM, Jun Koi <[hidden email]> wrote:



On Thu, Apr 24, 2014 at 1:46 PM, Craig Topper <[hidden email]> 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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
~Craig




--
~Craig

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev