llvm.org GIT mirror llvm / 6abfcfe
[x86] Allow address-size overrides for SCAS{8,16,32,64} (PR9385) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199805 91177308-0d34-0410-b5e6-96231b3b80d8 David Woodhouse 6 years ago
3 changed file(s) with 48 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
23602360 Name == "stosl" || Name == "stosd" || Name == "stosq"))
23612361 Operands.push_back(DefaultMemDIOperand(NameLoc));
23622362
2363 // Transform "scas[bwlq]" into "scas[bwlq] ($DIREG)" for appropriate
2364 // values of $DIREG according to the mode. It would be nice if this
2365 // could be achieved with InstAlias in the tables.
2366 if (Name.startswith("scas") && Operands.size() == 1 &&
2367 (Name == "scas" || Name == "scasb" || Name == "scasw" ||
2368 Name == "scasl" || Name == "scasd" || Name == "scasq"))
2369 Operands.push_back(DefaultMemDIOperand(NameLoc));
2370
23632371 // FIXME: Hack to handle recognize s{hr,ar,hl} $1, . Canonicalize to
23642372 // "shift ".
23652373 if ((Name.startswith("shr") || Name.startswith("sar") ||
11561156 def STOSQ : RI<0xAB, RawFrmDst, (outs dstidx64:$dst), (ins),
11571157 "stosq\t{%rax, $dst|$dst, rax}", [], IIC_STOS>;
11581158
1159 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scasb", [], IIC_SCAS>;
1160 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scasw", [], IIC_SCAS>, OpSize;
1161 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l|d}", [], IIC_SCAS>,
1162 OpSize16;
1163 def SCAS64 : RI<0xAF, RawFrm, (outs), (ins), "scasq", [], IIC_SCAS>;
1159 def SCAS8 : I<0xAE, RawFrmDst, (outs), (ins dstidx8:$dst),
1160 "scasb\t{$dst, %al|al, $dst}", [], IIC_SCAS>;
1161 def SCAS16 : I<0xAF, RawFrmDst, (outs), (ins dstidx16:$dst),
1162 "scasw\t{$dst, %ax|ax, $dst}", [], IIC_SCAS>, OpSize;
1163 def SCAS32 : I<0xAF, RawFrmDst, (outs), (ins dstidx32:$dst),
1164 "scas{l|d}\t{$dst, %eax|eax, $dst}", [], IIC_SCAS>, OpSize16;
1165 def SCAS64 : RI<0xAF, RawFrmDst, (outs), (ins dstidx64:$dst),
1166 "scasq\t{$dst, %rax|rax, $dst}", [], IIC_SCAS>;
11641167
11651168 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmpsb", [], IIC_CMPS>;
11661169 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmpsw", [], IIC_CMPS>, OpSize;
24312434 def : InstAlias<"stos {%eax, $dst|$dst, eax}", (STOSL dstidx32:$dst), 0>;
24322435 def : InstAlias<"stos {%rax, $dst|$dst, rax}", (STOSQ dstidx64:$dst), 0>, Requires<[In64BitMode]>;
24332436
2437 // scas aliases. Accept the destination being omitted because it's implicit
2438 // in the mnemonic, or the mnemonic suffix being omitted because it's implicit
2439 // in the destination.
2440 def : InstAlias<"scasb $dst", (SCAS8 dstidx8:$dst), 0>;
2441 def : InstAlias<"scasw $dst", (SCAS16 dstidx16:$dst), 0>;
2442 def : InstAlias<"scas{l|d} $dst", (SCAS32 dstidx32:$dst), 0>;
2443 def : InstAlias<"scasq $dst", (SCAS64 dstidx64:$dst), 0>, Requires<[In64BitMode]>;
2444 def : InstAlias<"scas {$dst, %al|al, $dst}", (SCAS8 dstidx8:$dst), 0>;
2445 def : InstAlias<"scas {$dst, %ax|ax, $dst}", (SCAS16 dstidx16:$dst), 0>;
2446 def : InstAlias<"scas {$dst, %eax|eax, $dst}", (SCAS32 dstidx32:$dst), 0>;
2447 def : InstAlias<"scas {$dst, %rax|rax, $dst}", (SCAS64 dstidx64:$dst), 0>, Requires<[In64BitMode]>;
2448
24342449 // div and idiv aliases for explicit A register.
24352450 def : InstAlias<"div{b}\t{$src, %al|al, $src}", (DIV8r GR8 :$src)>;
24362451 def : InstAlias<"div{w}\t{$src, %ax|ax, $src}", (DIV16r GR16:$src)>;
7373 // 64: stosq %rax, %es:(%edi) # encoding: [0x48,0x67,0xab]
7474 // ERR32: only available in 64-bit mode
7575 // ERR16: only available in 64-bit mode
76
77 scas %es:(%edi), %al
78 // 64: scasb %es:(%edi), %al # encoding: [0x67,0xae]
79 // 32: scasb %es:(%edi), %al # encoding: [0xae]
80 // 16: scasb %es:(%edi), %al # encoding: [0x67,0xae]
81
82 scasq %es:(%edi)
83 // 64: scasq %es:(%edi), %rax # encoding: [0x48,0x67,0xaf]
84 // ERR32: 64-bit
85 // ERR16: 64-bit
86
87 scasl %es:(%edi), %al
88 // ERR64: invalid operand
89 // ERR32: invalid operand
90 // ERR16: invalid operand
91
92 scas %es:(%di), %ax
93 // ERR64: invalid 16-bit base register
94 // 16: scasw %es:(%di), %ax # encoding: [0xaf]
95 // 32: scasw %es:(%di), %ax # encoding: [0x66,0x67,0xaf]