initialize 'dag' variable and interpret asmstring in tablegen .td file

llvm/lib/Target/X86/X86InstrInfo.td:

class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string

: Instruction {

    ....
    dag OperandList = ops;
    string AsmString = AsmStr;
}

def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
                   "mov{l} {$src, $dst|$dst, $src}">;

I cannot find any document on initializing the 'dag' type variable,
and I cannot understand the syntax of "asmstring" either.

how does the x86 asmwrite interpret the "AsmString" ?

llvm/lib/Target/X86/X86InstrInfo.td:
class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string
> : Instruction {
   ....
   dag OperandList = ops;
   string AsmString = AsmStr;
}

def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
                  "mov{l} {$src, $dst|$dst, $src}">;

I cannot find any document on initializing the 'dag' type variable,
and I cannot understand the syntax of "asmstring" either.

The DAG operator is just a nested set of parens, e.g. (X (Y Z), Q), where X,Y,Z,Q are tblgen defs. This is described here:
http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html#values

how does the x86 asmwrite interpret the "AsmString" ?

The X86 has two asm formats: Intel and AT&T. Things in {}'s get split up and treated as one or the other. The 0 part is AT&T, the 1th part is Intel. It might make it more clear to just say that this string:

      "mov{l} {$src, $dst|$dst, $src}"

is fully equivalent to this one:

      "{movl $src, $dst|mov $dst, $src}"

No other targets support multiple output formats, so they don't have to worry about this.

-Chris

The macro $src, $dest used in Instruction::AsmString must be
"declared" in Instruction::OperandList, right?

$$ has special meaning?

The macro $src, $dest used in Instruction::AsmString must be
"declared" in Instruction::OperandList, right?

Yes, these refer to the arguments of the machine instruction.

$$ has special meaning?

$$ = $ in the output file.

-Chris