2012-02-18 20:03:15 +08:00
|
|
|
//===-- X86InstrArithmetic.td - Integer Arithmetic Instrs --*- tablegen -*-===//
|
|
|
|
//
|
2010-10-06 00:39:12 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2012-02-18 20:03:15 +08:00
|
|
|
//
|
2010-10-06 00:39:12 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file describes the integer arithmetic instructions in the X86
|
|
|
|
// architecture.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// LEA - Load Effective Address
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteLEA] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
let neverHasSideEffects = 1 in
|
|
|
|
def LEA16r : I<0x8D, MRMSrcMem,
|
|
|
|
(outs GR16:$dst), (ins i32mem:$src),
|
2012-02-02 07:20:51 +08:00
|
|
|
"lea{w}\t{$src|$dst}, {$dst|$src}", [], IIC_LEA_16>, OpSize;
|
2010-10-06 00:39:12 +08:00
|
|
|
let isReMaterializable = 1 in
|
|
|
|
def LEA32r : I<0x8D, MRMSrcMem,
|
|
|
|
(outs GR32:$dst), (ins i32mem:$src),
|
|
|
|
"lea{l}\t{$src|$dst}, {$dst|$src}",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, lea32addr:$src)], IIC_LEA>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
|
|
|
def LEA64_32r : I<0x8D, MRMSrcMem,
|
|
|
|
(outs GR32:$dst), (ins lea64_32mem:$src),
|
|
|
|
"lea{l}\t{$src|$dst}, {$dst|$src}",
|
2013-02-02 03:28:09 +08:00
|
|
|
[(set GR32:$dst, lea64_32addr:$src)], IIC_LEA>,
|
2012-02-02 07:20:51 +08:00
|
|
|
Requires<[In64BitMode]>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
|
|
|
let isReMaterializable = 1 in
|
2013-02-02 03:28:09 +08:00
|
|
|
def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src),
|
2010-10-06 00:39:12 +08:00
|
|
|
"lea{q}\t{$src|$dst}, {$dst|$src}",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR64:$dst, lea64addr:$src)], IIC_LEA>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Fixed-Register Multiplication and Division Instructions.
|
|
|
|
//
|
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
// SchedModel info for instruction that loads one value and gets the second
|
|
|
|
// (and possibly third) value from a register.
|
|
|
|
// This is used for instructions that put the memory operands before other
|
|
|
|
// uses.
|
|
|
|
class SchedLoadReg<SchedWrite SW> : Sched<[SW,
|
|
|
|
// Memory operand.
|
|
|
|
ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
|
|
|
|
// Register reads (implicit or explicit).
|
|
|
|
ReadAfterLd, ReadAfterLd]>;
|
|
|
|
|
2010-10-06 00:39:12 +08:00
|
|
|
// Extra precision multiplication
|
|
|
|
|
|
|
|
// AL is really implied by AX, but the registers in Defs must match the
|
|
|
|
// SDNode results (i8, i32).
|
2013-03-19 05:32:39 +08:00
|
|
|
// AL,AH = AL*GR8
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AL,EFLAGS,AX], Uses = [AL] in
|
|
|
|
def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
|
|
|
|
// FIXME: Used for 8-bit mul, ignore result upper 8 bits.
|
|
|
|
// This probably ought to be moved to a def : Pat<> if the
|
|
|
|
// syntax can be accepted.
|
|
|
|
[(set AL, (mul AL, GR8:$src)),
|
2013-03-19 05:32:39 +08:00
|
|
|
(implicit EFLAGS)], IIC_MUL8>, Sched<[WriteIMul]>;
|
|
|
|
// AX,DX = AX*GR16
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
|
|
|
|
def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
|
2012-12-27 06:19:23 +08:00
|
|
|
"mul{w}\t$src",
|
2013-03-19 05:32:39 +08:00
|
|
|
[], IIC_MUL16_REG>, OpSize, Sched<[WriteIMul]>;
|
|
|
|
// EAX,EDX = EAX*GR32
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
|
|
|
|
def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"mul{l}\t$src",
|
2012-02-02 07:20:51 +08:00
|
|
|
[/*(set EAX, EDX, EFLAGS, (X86umul_flag EAX, GR32:$src))*/],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_MUL32_REG>, Sched<[WriteIMul]>;
|
|
|
|
// RAX,RDX = RAX*GR64
|
2010-10-06 04:23:31 +08:00
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in
|
|
|
|
def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"mul{q}\t$src",
|
2012-02-02 07:20:51 +08:00
|
|
|
[/*(set RAX, RDX, EFLAGS, (X86umul_flag RAX, GR64:$src))*/],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_MUL64>, Sched<[WriteIMul]>;
|
|
|
|
// AL,AH = AL*[mem8]
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AL,EFLAGS,AX], Uses = [AL] in
|
|
|
|
def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
|
|
|
|
"mul{b}\t$src",
|
|
|
|
// FIXME: Used for 8-bit mul, ignore result upper 8 bits.
|
|
|
|
// This probably ought to be moved to a def : Pat<> if the
|
|
|
|
// syntax can be accepted.
|
|
|
|
[(set AL, (mul AL, (loadi8 addr:$src))),
|
2013-03-19 05:32:39 +08:00
|
|
|
(implicit EFLAGS)], IIC_MUL8>, SchedLoadReg<WriteIMulLd>;
|
|
|
|
// AX,DX = AX*[mem16]
|
2010-10-06 00:39:12 +08:00
|
|
|
let mayLoad = 1, neverHasSideEffects = 1 in {
|
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX] in
|
|
|
|
def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
|
|
|
|
"mul{w}\t$src",
|
2013-03-19 05:32:39 +08:00
|
|
|
[], IIC_MUL16_MEM>, OpSize, SchedLoadReg<WriteIMulLd>;
|
|
|
|
// EAX,EDX = EAX*[mem32]
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
|
|
|
|
def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
|
|
|
|
"mul{l}\t$src",
|
2013-03-19 05:32:39 +08:00
|
|
|
[], IIC_MUL32_MEM>, SchedLoadReg<WriteIMulLd>;
|
|
|
|
// RAX,RDX = RAX*[mem64]
|
2011-10-23 07:13:53 +08:00
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in
|
2010-10-06 04:23:31 +08:00
|
|
|
def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"mul{q}\t$src", [], IIC_MUL64>, SchedLoadReg<WriteIMulLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let neverHasSideEffects = 1 in {
|
2013-03-19 05:32:39 +08:00
|
|
|
// AL,AH = AL*GR8
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AL,EFLAGS,AX], Uses = [AL] in
|
2012-04-09 23:32:22 +08:00
|
|
|
def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", [],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_IMUL8>, Sched<[WriteIMul]>;
|
|
|
|
// AX,DX = AX*GR16
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX] in
|
2012-04-09 23:32:22 +08:00
|
|
|
def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", [],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_IMUL16_RR>, OpSize, Sched<[WriteIMul]>;
|
|
|
|
// EAX,EDX = EAX*GR32
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
|
2012-04-09 23:32:22 +08:00
|
|
|
def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", [],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_IMUL32_RR>, Sched<[WriteIMul]>;
|
|
|
|
// RAX,RDX = RAX*GR64
|
2011-10-23 07:13:53 +08:00
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in
|
2012-04-09 23:32:22 +08:00
|
|
|
def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), "imul{q}\t$src", [],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_IMUL64_RR>, Sched<[WriteIMul]>;
|
2010-10-06 04:23:31 +08:00
|
|
|
|
2010-10-06 00:39:12 +08:00
|
|
|
let mayLoad = 1 in {
|
2013-03-19 05:32:39 +08:00
|
|
|
// AL,AH = AL*[mem8]
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AL,EFLAGS,AX], Uses = [AL] in
|
|
|
|
def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"imul{b}\t$src", [], IIC_IMUL8>, SchedLoadReg<WriteIMulLd>;
|
|
|
|
// AX,DX = AX*[mem16]
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX] in
|
|
|
|
def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"imul{w}\t$src", [], IIC_IMUL16_MEM>, OpSize,
|
|
|
|
SchedLoadReg<WriteIMulLd>;
|
|
|
|
// EAX,EDX = EAX*[mem32]
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
|
|
|
|
def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"imul{l}\t$src", [], IIC_IMUL32_MEM>, SchedLoadReg<WriteIMulLd>;
|
|
|
|
// RAX,RDX = RAX*[mem64]
|
2011-10-23 07:13:53 +08:00
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX] in
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"imul{q}\t$src", [], IIC_IMUL64>, SchedLoadReg<WriteIMulLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
}
|
|
|
|
} // neverHasSideEffects
|
|
|
|
|
2010-10-06 04:23:31 +08:00
|
|
|
|
|
|
|
let Defs = [EFLAGS] in {
|
|
|
|
let Constraints = "$src1 = $dst" in {
|
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let isCommutable = 1, SchedRW = [WriteIMul] in {
|
|
|
|
// X = IMUL Y, Z --> X = IMUL Z, Y
|
2010-10-06 04:23:31 +08:00
|
|
|
// Register-Register Signed Integer Multiply
|
|
|
|
def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
|
|
|
|
"imul{w}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR16:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR16:$src1, GR16:$src2))], IIC_IMUL16_RR>,
|
|
|
|
TB, OpSize;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
|
|
|
|
"imul{l}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR32:$src1, GR32:$src2))], IIC_IMUL32_RR>,
|
|
|
|
TB;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst),
|
|
|
|
(ins GR64:$src1, GR64:$src2),
|
|
|
|
"imul{q}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR64:$src1, GR64:$src2))], IIC_IMUL64_RR>,
|
|
|
|
TB;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // isCommutable, SchedRW
|
2010-10-06 04:23:31 +08:00
|
|
|
|
|
|
|
// Register-Memory Signed Integer Multiply
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteIMulLd, ReadAfterLd] in {
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
|
|
|
|
(ins GR16:$src1, i16mem:$src2),
|
|
|
|
"imul{w}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR16:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR16:$src1, (load addr:$src2)))],
|
|
|
|
IIC_IMUL16_RM>,
|
2010-10-06 04:23:31 +08:00
|
|
|
TB, OpSize;
|
2012-12-27 06:19:23 +08:00
|
|
|
def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
|
2010-10-06 04:23:31 +08:00
|
|
|
(ins GR32:$src1, i32mem:$src2),
|
|
|
|
"imul{l}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR32:$src1, (load addr:$src2)))],
|
|
|
|
IIC_IMUL32_RM>,
|
|
|
|
TB;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst),
|
|
|
|
(ins GR64:$src1, i64mem:$src2),
|
|
|
|
"imul{q}\t{$src2, $dst|$dst, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR64:$src1, (load addr:$src2)))],
|
|
|
|
IIC_IMUL64_RM>,
|
|
|
|
TB;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 04:23:31 +08:00
|
|
|
} // Constraints = "$src1 = $dst"
|
|
|
|
|
|
|
|
} // Defs = [EFLAGS]
|
|
|
|
|
2011-04-15 13:18:47 +08:00
|
|
|
// Surprisingly enough, these are not two address instructions!
|
2010-10-06 04:23:31 +08:00
|
|
|
let Defs = [EFLAGS] in {
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteIMul] in {
|
2010-10-06 04:23:31 +08:00
|
|
|
// Register-Integer Signed Integer Multiply
|
|
|
|
def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
|
|
|
|
(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
|
|
|
|
"imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
2012-12-27 06:19:23 +08:00
|
|
|
[(set GR16:$dst, EFLAGS,
|
|
|
|
(X86smul_flag GR16:$src1, imm:$src2))],
|
2012-02-02 07:20:51 +08:00
|
|
|
IIC_IMUL16_RRI>, OpSize;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
|
|
|
|
(outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
|
|
|
|
"imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR16:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR16:$src1, i16immSExt8:$src2))],
|
|
|
|
IIC_IMUL16_RRI>,
|
2010-10-06 04:23:31 +08:00
|
|
|
OpSize;
|
|
|
|
def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
|
|
|
|
(outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
|
|
|
|
"imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR32:$src1, imm:$src2))],
|
|
|
|
IIC_IMUL32_RRI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
|
|
|
|
(outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
|
|
|
|
"imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR32:$src1, i32immSExt8:$src2))],
|
|
|
|
IIC_IMUL32_RRI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32
|
|
|
|
(outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2),
|
|
|
|
"imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR64:$src1, i64immSExt32:$src2))],
|
|
|
|
IIC_IMUL64_RRI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8
|
|
|
|
(outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2),
|
|
|
|
"imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag GR64:$src1, i64immSExt8:$src2))],
|
|
|
|
IIC_IMUL64_RRI>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 04:23:31 +08:00
|
|
|
|
|
|
|
// Memory-Integer Signed Integer Multiply
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteIMulLd] in {
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
|
|
|
|
(outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
|
|
|
|
"imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR16:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag (load addr:$src1), imm:$src2))],
|
|
|
|
IIC_IMUL16_RMI>,
|
2010-10-06 04:23:31 +08:00
|
|
|
OpSize;
|
|
|
|
def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
|
|
|
|
(outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
|
|
|
|
"imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR16:$dst, EFLAGS,
|
|
|
|
(X86smul_flag (load addr:$src1),
|
2012-02-02 07:20:51 +08:00
|
|
|
i16immSExt8:$src2))], IIC_IMUL16_RMI>,
|
|
|
|
OpSize;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
|
|
|
|
(outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
|
|
|
|
"imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
2012-02-02 07:20:51 +08:00
|
|
|
(X86smul_flag (load addr:$src1), imm:$src2))],
|
|
|
|
IIC_IMUL32_RMI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
|
|
|
|
(outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
|
|
|
|
"imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR32:$dst, EFLAGS,
|
|
|
|
(X86smul_flag (load addr:$src1),
|
2012-02-02 07:20:51 +08:00
|
|
|
i32immSExt8:$src2))],
|
|
|
|
IIC_IMUL32_RMI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32
|
|
|
|
(outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2),
|
|
|
|
"imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
|
|
|
(X86smul_flag (load addr:$src1),
|
2012-02-02 07:20:51 +08:00
|
|
|
i64immSExt32:$src2))],
|
|
|
|
IIC_IMUL64_RMI>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8
|
|
|
|
(outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2),
|
|
|
|
"imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
|
|
|
|
[(set GR64:$dst, EFLAGS,
|
|
|
|
(X86smul_flag (load addr:$src1),
|
2012-02-02 07:20:51 +08:00
|
|
|
i64immSExt8:$src2))],
|
|
|
|
IIC_IMUL64_RMI>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 04:23:31 +08:00
|
|
|
} // Defs = [EFLAGS]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-06 00:39:12 +08:00
|
|
|
// unsigned division/remainder
|
2013-01-05 15:39:25 +08:00
|
|
|
let hasSideEffects = 1 in { // so that we don't speculatively execute
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteIDiv] in {
|
2013-06-12 07:41:44 +08:00
|
|
|
let Defs = [AL,AH,EFLAGS], Uses = [AX] in
|
2010-10-06 00:39:12 +08:00
|
|
|
def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
|
2012-02-02 07:20:51 +08:00
|
|
|
"div{b}\t$src", [], IIC_DIV8_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
|
|
|
|
def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
|
2012-02-02 07:20:51 +08:00
|
|
|
"div{w}\t$src", [], IIC_DIV16>, OpSize;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
|
|
|
|
def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
|
2012-02-02 07:20:51 +08:00
|
|
|
"div{l}\t$src", [], IIC_DIV32>;
|
2010-10-06 04:23:31 +08:00
|
|
|
// RDX:RAX/r64 = RAX,RDX
|
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in
|
|
|
|
def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src),
|
2012-02-02 07:20:51 +08:00
|
|
|
"div{q}\t$src", [], IIC_DIV64>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 04:23:31 +08:00
|
|
|
|
2010-10-06 00:39:12 +08:00
|
|
|
let mayLoad = 1 in {
|
2013-06-12 07:41:44 +08:00
|
|
|
let Defs = [AL,AH,EFLAGS], Uses = [AX] in
|
2010-10-06 00:39:12 +08:00
|
|
|
def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
|
2013-03-19 05:32:39 +08:00
|
|
|
"div{b}\t$src", [], IIC_DIV8_MEM>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
|
|
|
|
def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
|
2013-03-19 05:32:39 +08:00
|
|
|
"div{w}\t$src", [], IIC_DIV16>, OpSize,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 04:23:31 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in // EDX:EAX/[mem32] = EAX,EDX
|
2010-10-06 00:39:12 +08:00
|
|
|
def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"div{l}\t$src", [], IIC_DIV32>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 04:23:31 +08:00
|
|
|
// RDX:RAX/[mem64] = RAX,RDX
|
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in
|
|
|
|
def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"div{q}\t$src", [], IIC_DIV64>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Signed division/remainder.
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteIDiv] in {
|
2013-06-12 07:41:44 +08:00
|
|
|
let Defs = [AL,AH,EFLAGS], Uses = [AX] in
|
2010-10-06 00:39:12 +08:00
|
|
|
def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
|
2012-02-02 07:20:51 +08:00
|
|
|
"idiv{b}\t$src", [], IIC_IDIV8>;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
|
|
|
|
def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
|
2012-02-02 07:20:51 +08:00
|
|
|
"idiv{w}\t$src", [], IIC_IDIV16>, OpSize;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
|
|
|
|
def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
|
2012-02-02 07:20:51 +08:00
|
|
|
"idiv{l}\t$src", [], IIC_IDIV32>;
|
2010-10-06 04:23:31 +08:00
|
|
|
// RDX:RAX/r64 = RAX,RDX
|
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in
|
|
|
|
def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src),
|
2012-02-02 07:20:51 +08:00
|
|
|
"idiv{q}\t$src", [], IIC_IDIV64>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2011-10-23 07:13:53 +08:00
|
|
|
|
|
|
|
let mayLoad = 1 in {
|
2013-06-12 07:41:44 +08:00
|
|
|
let Defs = [AL,AH,EFLAGS], Uses = [AX] in
|
2010-10-06 00:39:12 +08:00
|
|
|
def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
|
2013-03-19 05:32:39 +08:00
|
|
|
"idiv{b}\t$src", [], IIC_IDIV8>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
|
|
|
|
def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
|
2013-03-19 05:32:39 +08:00
|
|
|
"idiv{w}\t$src", [], IIC_IDIV16>, OpSize,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 04:23:31 +08:00
|
|
|
let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in // EDX:EAX/[mem32] = EAX,EDX
|
2012-12-27 06:19:23 +08:00
|
|
|
def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"idiv{l}\t$src", [], IIC_IDIV32>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 04:23:31 +08:00
|
|
|
let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in // RDX:RAX/[mem64] = RAX,RDX
|
|
|
|
def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src),
|
2013-03-19 05:32:39 +08:00
|
|
|
"idiv{q}\t$src", [], IIC_IDIV64>,
|
|
|
|
SchedLoadReg<WriteIDivLd>;
|
2010-10-06 00:39:12 +08:00
|
|
|
}
|
2012-12-27 11:01:18 +08:00
|
|
|
} // hasSideEffects = 0
|
2010-10-06 00:39:12 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Two address Instructions.
|
|
|
|
//
|
|
|
|
|
|
|
|
// unary instructions
|
|
|
|
let CodeSize = 2 in {
|
|
|
|
let Defs = [EFLAGS] in {
|
2013-03-19 05:32:39 +08:00
|
|
|
let Constraints = "$src1 = $dst", SchedRW = [WriteALU] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
|
|
|
|
"neg{b}\t$dst",
|
|
|
|
[(set GR8:$dst, (ineg GR8:$src1)),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
|
|
|
|
"neg{w}\t$dst",
|
|
|
|
[(set GR16:$dst, (ineg GR16:$src1)),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_REG>, OpSize;
|
2010-10-06 00:39:12 +08:00
|
|
|
def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
|
|
|
|
"neg{l}\t$dst",
|
|
|
|
[(set GR32:$dst, (ineg GR32:$src1)),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_REG>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src1), "neg{q}\t$dst",
|
|
|
|
[(set GR64:$dst, (ineg GR64:$src1)),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_REG>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // Constraints = "$src1 = $dst", SchedRW
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
// Read-modify-write negate.
|
|
|
|
let SchedRW = [WriteALULd, WriteRMW] in {
|
2010-10-06 00:52:25 +08:00
|
|
|
def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
|
|
|
|
"neg{b}\t$dst",
|
|
|
|
[(store (ineg (loadi8 addr:$dst)), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2010-10-06 00:52:25 +08:00
|
|
|
def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
|
|
|
|
"neg{w}\t$dst",
|
|
|
|
[(store (ineg (loadi16 addr:$dst)), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>, OpSize;
|
2010-10-06 00:52:25 +08:00
|
|
|
def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
|
|
|
|
"neg{l}\t$dst",
|
|
|
|
[(store (ineg (loadi32 addr:$dst)), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst",
|
|
|
|
[(store (ineg (loadi64 addr:$dst)), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
} // Defs = [EFLAGS]
|
|
|
|
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2010-10-06 05:09:45 +08:00
|
|
|
// Note: NOT does not set EFLAGS!
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let Constraints = "$src1 = $dst", SchedRW = [WriteALU] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
// Match xor -1 to not. Favors these over a move imm + xor to save code size.
|
|
|
|
let AddedComplexity = 15 in {
|
|
|
|
def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
|
|
|
|
"not{b}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR8:$dst, (not GR8:$src1))], IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
|
|
|
|
"not{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR16:$dst, (not GR16:$src1))], IIC_UNARY_REG>, OpSize;
|
2010-10-06 00:39:12 +08:00
|
|
|
def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
|
|
|
|
"not{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, (not GR32:$src1))], IIC_UNARY_REG>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src1), "not{q}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR64:$dst, (not GR64:$src1))], IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
}
|
2013-03-19 05:32:39 +08:00
|
|
|
} // Constraints = "$src1 = $dst", SchedRW
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let SchedRW = [WriteALULd, WriteRMW] in {
|
2010-10-06 00:52:25 +08:00
|
|
|
def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
|
|
|
|
"not{b}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(store (not (loadi8 addr:$dst)), addr:$dst)], IIC_UNARY_MEM>;
|
2010-10-06 00:52:25 +08:00
|
|
|
def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
|
|
|
|
"not{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(store (not (loadi16 addr:$dst)), addr:$dst)], IIC_UNARY_MEM>,
|
|
|
|
OpSize;
|
2010-10-06 00:52:25 +08:00
|
|
|
def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
|
|
|
|
"not{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(store (not (loadi32 addr:$dst)), addr:$dst)], IIC_UNARY_MEM>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(store (not (loadi64 addr:$dst)), addr:$dst)], IIC_UNARY_MEM>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
} // CodeSize
|
|
|
|
|
|
|
|
// TODO: inc/dec is slow for P4, but fast for Pentium-M.
|
|
|
|
let Defs = [EFLAGS] in {
|
2013-03-19 05:32:39 +08:00
|
|
|
let Constraints = "$src1 = $dst", SchedRW = [WriteALU] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
let CodeSize = 2 in
|
|
|
|
def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
|
|
|
|
"inc{b}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))],
|
|
|
|
IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
|
|
|
let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
|
2012-12-27 06:19:23 +08:00
|
|
|
def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
|
2010-10-06 00:39:12 +08:00
|
|
|
"inc{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))], IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
|
2010-10-06 00:39:12 +08:00
|
|
|
"inc{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src1), "inc{q}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR64:$dst, EFLAGS, (X86inc_flag GR64:$src1))],
|
|
|
|
IIC_UNARY_REG>;
|
2010-10-06 04:35:37 +08:00
|
|
|
} // isConvertibleToThreeAddress = 1, CodeSize = 1
|
|
|
|
|
|
|
|
|
|
|
|
// In 64-bit mode, single byte INC and DEC cannot be encoded.
|
|
|
|
let isConvertibleToThreeAddress = 1, CodeSize = 2 in {
|
|
|
|
// Can transform into LEA.
|
2012-12-27 06:19:23 +08:00
|
|
|
def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
|
2010-10-06 04:35:37 +08:00
|
|
|
"inc{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2010-10-06 04:35:37 +08:00
|
|
|
OpSize, Requires<[In64BitMode]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
|
2010-10-06 04:35:37 +08:00
|
|
|
"inc{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2010-10-06 04:35:37 +08:00
|
|
|
Requires<[In64BitMode]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
|
2010-10-06 04:35:37 +08:00
|
|
|
"dec{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2010-10-06 04:35:37 +08:00
|
|
|
OpSize, Requires<[In64BitMode]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
|
2010-10-06 04:35:37 +08:00
|
|
|
"dec{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2010-10-06 04:35:37 +08:00
|
|
|
Requires<[In64BitMode]>;
|
|
|
|
} // isConvertibleToThreeAddress = 1, CodeSize = 2
|
|
|
|
|
2014-01-05 12:32:42 +08:00
|
|
|
let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0,
|
|
|
|
CodeSize = 2 in {
|
2013-10-07 12:28:06 +08:00
|
|
|
def INC32_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
|
|
|
|
"inc{w}\t$dst", [], IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2013-10-07 12:28:06 +08:00
|
|
|
def INC32_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
|
|
|
|
"inc{l}\t$dst", [], IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2013-10-07 12:28:06 +08:00
|
|
|
def DEC32_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
|
|
|
|
"dec{w}\t$dst", [], IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2013-10-07 12:28:06 +08:00
|
|
|
def DEC32_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
|
|
|
|
"dec{l}\t$dst", [], IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2014-01-05 12:32:42 +08:00
|
|
|
} // isCodeGenOnly = 1, ForceDisassemble = 1, HasSideEffects = 0, CodeSize = 2
|
2013-10-07 12:28:06 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
} // Constraints = "$src1 = $dst", SchedRW
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let CodeSize = 2, SchedRW = [WriteALULd, WriteRMW] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
|
|
|
|
[(store (add (loadi8 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
|
|
|
|
[(store (add (loadi16 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
|
|
|
|
[(store (add (loadi32 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst",
|
|
|
|
[(store (add (loadi64 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 04:35:37 +08:00
|
|
|
// These are duplicates of their 32-bit counterparts. Only needed so X86 knows
|
|
|
|
// how to unfold them.
|
|
|
|
// FIXME: What is this for??
|
|
|
|
def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
|
|
|
|
[(store (add (loadi16 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2010-10-06 04:35:37 +08:00
|
|
|
OpSize, Requires<[In64BitMode]>;
|
|
|
|
def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
|
|
|
|
[(store (add (loadi32 addr:$dst), 1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2010-10-06 04:35:37 +08:00
|
|
|
Requires<[In64BitMode]>;
|
|
|
|
def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
|
|
|
|
[(store (add (loadi16 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2010-10-06 04:35:37 +08:00
|
|
|
OpSize, Requires<[In64BitMode]>;
|
|
|
|
def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
|
|
|
|
[(store (add (loadi32 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2010-10-06 04:35:37 +08:00
|
|
|
Requires<[In64BitMode]>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // CodeSize = 2, SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let Constraints = "$src1 = $dst", SchedRW = [WriteALU] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
let CodeSize = 2 in
|
|
|
|
def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
|
|
|
|
"dec{b}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))],
|
|
|
|
IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
|
2012-12-27 06:19:23 +08:00
|
|
|
def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
|
2010-10-06 00:39:12 +08:00
|
|
|
"dec{w}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
|
2010-10-06 00:39:12 +08:00
|
|
|
"dec{l}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))],
|
|
|
|
IIC_UNARY_REG>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src1), "dec{q}\t$dst",
|
2012-02-02 07:20:51 +08:00
|
|
|
[(set GR64:$dst, EFLAGS, (X86dec_flag GR64:$src1))],
|
|
|
|
IIC_UNARY_REG>;
|
2010-10-06 00:39:12 +08:00
|
|
|
} // CodeSize = 2
|
2013-03-19 05:32:39 +08:00
|
|
|
} // Constraints = "$src1 = $dst", SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2010-10-06 00:52:25 +08:00
|
|
|
|
2013-03-19 05:32:39 +08:00
|
|
|
let CodeSize = 2, SchedRW = [WriteALULd, WriteRMW] in {
|
2010-10-06 00:39:12 +08:00
|
|
|
def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
|
|
|
|
[(store (add (loadi8 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
|
|
|
|
[(store (add (loadi16 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2013-12-20 10:04:49 +08:00
|
|
|
OpSize, Requires<[Not64BitMode]>;
|
2010-10-06 00:39:12 +08:00
|
|
|
def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
|
|
|
|
[(store (add (loadi32 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>,
|
2013-12-20 10:04:49 +08:00
|
|
|
Requires<[Not64BitMode]>;
|
2010-10-06 04:23:31 +08:00
|
|
|
def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst",
|
|
|
|
[(store (add (loadi64 addr:$dst), -1), addr:$dst),
|
2012-02-02 07:20:51 +08:00
|
|
|
(implicit EFLAGS)], IIC_UNARY_MEM>;
|
2013-03-19 05:32:39 +08:00
|
|
|
} // CodeSize = 2, SchedRW
|
2010-10-06 00:39:12 +08:00
|
|
|
} // Defs = [EFLAGS]
|
|
|
|
|
2010-10-06 08:45:24 +08:00
|
|
|
/// X86TypeInfo - This is a bunch of information that describes relevant X86
|
|
|
|
/// information about value types. For example, it can tell you what the
|
|
|
|
/// register class and preferred load to use.
|
|
|
|
class X86TypeInfo<ValueType vt, string instrsuffix, RegisterClass regclass,
|
2010-10-07 08:12:45 +08:00
|
|
|
PatFrag loadnode, X86MemOperand memoperand, ImmType immkind,
|
|
|
|
Operand immoperand, SDPatternOperator immoperator,
|
|
|
|
Operand imm8operand, SDPatternOperator imm8operator,
|
2010-10-06 13:28:38 +08:00
|
|
|
bit hasOddOpcode, bit hasOpSizePrefix, bit hasREX_WPrefix> {
|
2010-10-06 08:45:24 +08:00
|
|
|
/// VT - This is the value type itself.
|
|
|
|
ValueType VT = vt;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 08:45:24 +08:00
|
|
|
/// InstrSuffix - This is the suffix used on instructions with this type. For
|
|
|
|
/// example, i8 -> "b", i16 -> "w", i32 -> "l", i64 -> "q".
|
|
|
|
string InstrSuffix = instrsuffix;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 08:45:24 +08:00
|
|
|
/// RegClass - This is the register class associated with this type. For
|
|
|
|
/// example, i8 -> GR8, i16 -> GR16, i32 -> GR32, i64 -> GR64.
|
|
|
|
RegisterClass RegClass = regclass;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 08:45:24 +08:00
|
|
|
/// LoadNode - This is the load node associated with this type. For
|
|
|
|
/// example, i8 -> loadi8, i16 -> loadi16, i32 -> loadi32, i64 -> loadi64.
|
|
|
|
PatFrag LoadNode = loadnode;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 08:45:24 +08:00
|
|
|
/// MemOperand - This is the memory operand associated with this type. For
|
|
|
|
/// example, i8 -> i8mem, i16 -> i16mem, i32 -> i32mem, i64 -> i64mem.
|
|
|
|
X86MemOperand MemOperand = memoperand;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 13:55:42 +08:00
|
|
|
/// ImmEncoding - This is the encoding of an immediate of this type. For
|
|
|
|
/// example, i8 -> Imm8, i16 -> Imm16, i32 -> Imm32. Note that i64 -> Imm32
|
|
|
|
/// since the immediate fields of i64 instructions is a 32-bit sign extended
|
|
|
|
/// value.
|
|
|
|
ImmType ImmEncoding = immkind;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 13:55:42 +08:00
|
|
|
/// ImmOperand - This is the operand kind of an immediate of this type. For
|
|
|
|
/// example, i8 -> i8imm, i16 -> i16imm, i32 -> i32imm. Note that i64 ->
|
|
|
|
/// i64i32imm since the immediate fields of i64 instructions is a 32-bit sign
|
|
|
|
/// extended value.
|
|
|
|
Operand ImmOperand = immoperand;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-07 08:01:39 +08:00
|
|
|
/// ImmOperator - This is the operator that should be used to match an
|
|
|
|
/// immediate of this kind in a pattern (e.g. imm, or i64immSExt32).
|
|
|
|
SDPatternOperator ImmOperator = immoperator;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-07 08:12:45 +08:00
|
|
|
/// Imm8Operand - This is the operand kind to use for an imm8 of this type.
|
|
|
|
/// For example, i8 -> <invalid>, i16 -> i16i8imm, i32 -> i32i8imm. This is
|
|
|
|
/// only used for instructions that have a sign-extended imm8 field form.
|
|
|
|
Operand Imm8Operand = imm8operand;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-07 08:12:45 +08:00
|
|
|
/// Imm8Operator - This is the operator that should be used to match an 8-bit
|
|
|
|
/// sign extended immediate of this kind in a pattern (e.g. imm16immSExt8).
|
|
|
|
SDPatternOperator Imm8Operator = imm8operator;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 13:28:38 +08:00
|
|
|
/// HasOddOpcode - This bit is true if the instruction should have an odd (as
|
|
|
|
/// opposed to even) opcode. Operations on i8 are usually even, operations on
|
|
|
|
/// other datatypes are odd.
|
|
|
|
bit HasOddOpcode = hasOddOpcode;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 13:20:57 +08:00
|
|
|
/// HasOpSizePrefix - This bit is set to true if the instruction should have
|
|
|
|
/// the 0x66 operand size prefix. This is set for i16 types.
|
|
|
|
bit HasOpSizePrefix = hasOpSizePrefix;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-06 13:20:57 +08:00
|
|
|
/// HasREX_WPrefix - This bit is set to true if the instruction should have
|
|
|
|
/// the 0x40 REX prefix. This is set for i64 types.
|
|
|
|
bit HasREX_WPrefix = hasREX_WPrefix;
|
2010-10-06 08:45:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-07 08:12:45 +08:00
|
|
|
def invalid_node : SDNode<"<<invalid_node>>", SDTIntLeaf,[],"<<invalid_node>>">;
|
|
|
|
|
|
|
|
|
|
|
|
def Xi8 : X86TypeInfo<i8 , "b", GR8 , loadi8 , i8mem ,
|
|
|
|
Imm8 , i8imm , imm, i8imm , invalid_node,
|
|
|
|
0, 0, 0>;
|
|
|
|
def Xi16 : X86TypeInfo<i16, "w", GR16, loadi16, i16mem,
|
|
|
|
Imm16, i16imm, imm, i16i8imm, i16immSExt8,
|
|
|
|
1, 1, 0>;
|
|
|
|
def Xi32 : X86TypeInfo<i32, "l", GR32, loadi32, i32mem,
|
|
|
|
Imm32, i32imm, imm, i32i8imm, i32immSExt8,
|
|
|
|
1, 0, 0>;
|
|
|
|
def Xi64 : X86TypeInfo<i64, "q", GR64, loadi64, i64mem,
|
|
|
|
Imm32, i64i32imm, i64immSExt32, i64i8imm, i64immSExt8,
|
|
|
|
1, 0, 1>;
|
2010-10-06 13:20:57 +08:00
|
|
|
|
|
|
|
/// ITy - This instruction base class takes the type info for the instruction.
|
|
|
|
/// Using this, it:
|
|
|
|
/// 1. Concatenates together the instruction mnemonic with the appropriate
|
|
|
|
/// suffix letter, a tab, and the arguments.
|
|
|
|
/// 2. Infers whether the instruction should have a 0x66 prefix byte.
|
|
|
|
/// 3. Infers whether the instruction should have a 0x40 REX_W prefix.
|
2010-10-06 13:28:38 +08:00
|
|
|
/// 4. Infers whether the low bit of the opcode should be 0 (for i8 operations)
|
|
|
|
/// or 1 (for i16,i32,i64 operations).
|
2012-12-27 06:19:23 +08:00
|
|
|
class ITy<bits<8> opcode, Format f, X86TypeInfo typeinfo, dag outs, dag ins,
|
2012-02-02 07:20:51 +08:00
|
|
|
string mnemonic, string args, list<dag> pattern,
|
|
|
|
InstrItinClass itin = IIC_BIN_NONMEM>
|
2010-10-06 13:28:38 +08:00
|
|
|
: I<{opcode{7}, opcode{6}, opcode{5}, opcode{4},
|
|
|
|
opcode{3}, opcode{2}, opcode{1}, typeinfo.HasOddOpcode },
|
2012-12-27 06:19:23 +08:00
|
|
|
f, outs, ins,
|
2012-02-02 07:20:51 +08:00
|
|
|
!strconcat(mnemonic, "{", typeinfo.InstrSuffix, "}\t", args), pattern,
|
|
|
|
itin> {
|
2010-10-06 13:20:57 +08:00
|
|
|
|
|
|
|
// Infer instruction prefixes from type info.
|
|
|
|
let hasOpSizePrefix = typeinfo.HasOpSizePrefix;
|
|
|
|
let hasREX_WPrefix = typeinfo.HasREX_WPrefix;
|
|
|
|
}
|
2010-10-06 08:45:24 +08:00
|
|
|
|
2010-10-08 04:14:23 +08:00
|
|
|
// BinOpRR - Instructions like "add reg, reg, reg".
|
|
|
|
class BinOpRR<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2012-04-09 23:32:22 +08:00
|
|
|
dag outlist, list<dag> pattern, InstrItinClass itin,
|
|
|
|
Format f = MRMDestReg>
|
2010-10-08 05:31:03 +08:00
|
|
|
: ITy<opcode, f, typeinfo, outlist,
|
2010-10-08 04:14:23 +08:00
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.RegClass:$src2),
|
2013-03-19 05:32:39 +08:00
|
|
|
mnemonic, "{$src2, $src1|$src1, $src2}", pattern, itin>,
|
|
|
|
Sched<[WriteALU]>;
|
2010-10-08 04:14:23 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRR_R - Instructions like "add reg, reg, reg", where the pattern has
|
|
|
|
// just a regclass (no eflags) as a result.
|
|
|
|
class BinOpRR_R<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRR<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst,
|
2012-04-09 23:32:22 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.RegClass:$src2))],
|
|
|
|
IIC_BIN_NONMEM>;
|
2010-10-08 04:01:55 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpRR_F - Instructions like "cmp reg, Reg", where the pattern has
|
|
|
|
// just a EFLAGS as a result.
|
|
|
|
class BinOpRR_F<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2010-10-08 05:31:03 +08:00
|
|
|
SDPatternOperator opnode, Format f = MRMDestReg>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRR<opcode, mnemonic, typeinfo, (outs),
|
|
|
|
[(set EFLAGS,
|
2010-10-08 05:31:03 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.RegClass:$src2))],
|
2012-04-09 23:32:22 +08:00
|
|
|
IIC_BIN_NONMEM, f>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRR_RF - Instructions like "add reg, reg, reg", where the pattern has
|
|
|
|
// both a regclass and EFLAGS as a result.
|
|
|
|
class BinOpRR_RF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRR<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
2012-04-09 23:32:22 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.RegClass:$src2))],
|
|
|
|
IIC_BIN_NONMEM>;
|
2010-10-06 07:32:05 +08:00
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpRR_RFF - Instructions like "adc reg, reg, reg", where the pattern has
|
|
|
|
// both a regclass and EFLAGS as a result, and has EFLAGS as input.
|
|
|
|
class BinOpRR_RFF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
|
|
|
: BinOpRR<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.RegClass:$src2,
|
2013-09-14 03:23:28 +08:00
|
|
|
EFLAGS))], IIC_BIN_CARRY_NONMEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-07 08:35:28 +08:00
|
|
|
// BinOpRR_Rev - Instructions like "add reg, reg, reg" (reversed encoding).
|
2013-09-14 03:23:28 +08:00
|
|
|
class BinOpRR_Rev<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
InstrItinClass itin = IIC_BIN_NONMEM>
|
2010-10-06 13:35:22 +08:00
|
|
|
: ITy<opcode, MRMSrcReg, typeinfo,
|
|
|
|
(outs typeinfo.RegClass:$dst),
|
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.RegClass:$src2),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src2, $dst|$dst, $src2}", [], itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALU]> {
|
2010-10-06 13:35:22 +08:00
|
|
|
// The disassembler should know about this, but not the asmparser.
|
|
|
|
let isCodeGenOnly = 1;
|
2014-01-05 12:17:28 +08:00
|
|
|
let ForceDisassemble = 1;
|
2012-12-27 05:30:22 +08:00
|
|
|
let hasSideEffects = 0;
|
2010-10-06 13:35:22 +08:00
|
|
|
}
|
2010-10-06 08:30:49 +08:00
|
|
|
|
2013-09-14 03:23:28 +08:00
|
|
|
// BinOpRR_RDD_Rev - Instructions like "adc reg, reg, reg" (reversed encoding).
|
|
|
|
class BinOpRR_RFF_Rev<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo>
|
|
|
|
: BinOpRR_Rev<opcode, mnemonic, typeinfo, IIC_BIN_CARRY_NONMEM>;
|
|
|
|
|
2011-09-12 05:41:45 +08:00
|
|
|
// BinOpRR_F_Rev - Instructions like "cmp reg, reg" (reversed encoding).
|
|
|
|
class BinOpRR_F_Rev<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo>
|
|
|
|
: ITy<opcode, MRMSrcReg, typeinfo, (outs),
|
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.RegClass:$src2),
|
2013-03-19 05:32:39 +08:00
|
|
|
mnemonic, "{$src2, $src1|$src1, $src2}", [], IIC_BIN_NONMEM>,
|
|
|
|
Sched<[WriteALU]> {
|
2011-09-12 05:41:45 +08:00
|
|
|
// The disassembler should know about this, but not the asmparser.
|
|
|
|
let isCodeGenOnly = 1;
|
2014-01-05 12:17:28 +08:00
|
|
|
let ForceDisassemble = 1;
|
2012-12-27 10:08:46 +08:00
|
|
|
let hasSideEffects = 0;
|
2011-09-12 05:41:45 +08:00
|
|
|
}
|
|
|
|
|
2010-10-08 04:14:23 +08:00
|
|
|
// BinOpRM - Instructions like "add reg, reg, [mem]".
|
|
|
|
class BinOpRM<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
dag outlist, list<dag> pattern,
|
|
|
|
InstrItinClass itin = IIC_BIN_MEM>
|
2010-10-08 04:56:25 +08:00
|
|
|
: ITy<opcode, MRMSrcMem, typeinfo, outlist,
|
2010-10-08 04:01:55 +08:00
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.MemOperand:$src2),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src2, $src1|$src1, $src2}", pattern, itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALULd, ReadAfterLd]>;
|
2010-10-08 04:14:23 +08:00
|
|
|
|
|
|
|
// BinOpRM_R - Instructions like "add reg, reg, [mem]".
|
|
|
|
class BinOpRM_R<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRM<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst,
|
2010-10-08 04:01:55 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, (typeinfo.LoadNode addr:$src2)))]>;
|
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpRM_F - Instructions like "cmp reg, [mem]".
|
|
|
|
class BinOpRM_F<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2010-10-08 05:31:03 +08:00
|
|
|
SDPatternOperator opnode>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRM<opcode, mnemonic, typeinfo, (outs),
|
|
|
|
[(set EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, (typeinfo.LoadNode addr:$src2)))]>;
|
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRM_RF - Instructions like "add reg, reg, [mem]".
|
|
|
|
class BinOpRM_RF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2010-10-08 04:06:24 +08:00
|
|
|
SDNode opnode>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRM<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
2010-10-06 12:58:43 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, (typeinfo.LoadNode addr:$src2)))]>;
|
2010-10-06 08:30:49 +08:00
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpRM_RFF - Instructions like "adc reg, reg, [mem]".
|
|
|
|
class BinOpRM_RFF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
|
|
|
: BinOpRM<opcode, mnemonic, typeinfo, (outs typeinfo.RegClass:$dst),
|
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, (typeinfo.LoadNode addr:$src2),
|
2013-09-14 03:23:28 +08:00
|
|
|
EFLAGS))], IIC_BIN_CARRY_MEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-08 04:14:23 +08:00
|
|
|
// BinOpRI - Instructions like "add reg, reg, imm".
|
|
|
|
class BinOpRI<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
Format f, dag outlist, list<dag> pattern,
|
|
|
|
InstrItinClass itin = IIC_BIN_NONMEM>
|
2010-10-08 04:56:25 +08:00
|
|
|
: ITy<opcode, f, typeinfo, outlist,
|
2010-10-08 04:01:55 +08:00
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.ImmOperand:$src2),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src2, $src1|$src1, $src2}", pattern, itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALU]> {
|
2010-10-08 04:01:55 +08:00
|
|
|
let ImmT = typeinfo.ImmEncoding;
|
|
|
|
}
|
|
|
|
|
2010-10-08 04:14:23 +08:00
|
|
|
// BinOpRI_R - Instructions like "add reg, reg, imm".
|
|
|
|
class BinOpRI_R<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRI<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.ImmOperator:$src2))]>;
|
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpRI_F - Instructions like "cmp reg, imm".
|
|
|
|
class BinOpRI_F<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2010-10-08 05:31:03 +08:00
|
|
|
SDPatternOperator opnode, Format f>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRI<opcode, mnemonic, typeinfo, f, (outs),
|
|
|
|
[(set EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.ImmOperator:$src2))]>;
|
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRI_RF - Instructions like "add reg, reg, imm".
|
|
|
|
class BinOpRI_RF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRI<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
2012-12-27 06:19:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
2010-10-08 04:14:23 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.ImmOperator:$src2))]>;
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpRI_RFF - Instructions like "adc reg, reg, imm".
|
|
|
|
class BinOpRI_RFF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpRI<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
2012-12-27 06:19:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
2010-12-20 08:59:46 +08:00
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.ImmOperator:$src2,
|
2013-09-14 03:23:28 +08:00
|
|
|
EFLAGS))], IIC_BIN_CARRY_NONMEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-08 04:14:23 +08:00
|
|
|
// BinOpRI8 - Instructions like "add reg, reg, imm8".
|
|
|
|
class BinOpRI8<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
Format f, dag outlist, list<dag> pattern,
|
|
|
|
InstrItinClass itin = IIC_BIN_NONMEM>
|
2010-10-08 04:56:25 +08:00
|
|
|
: ITy<opcode, f, typeinfo, outlist,
|
2010-10-08 04:14:23 +08:00
|
|
|
(ins typeinfo.RegClass:$src1, typeinfo.Imm8Operand:$src2),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src2, $src1|$src1, $src2}", pattern, itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALU]> {
|
2010-10-08 04:14:23 +08:00
|
|
|
let ImmT = Imm8; // Always 8-bit immediate.
|
2010-10-06 13:55:42 +08:00
|
|
|
}
|
2010-10-06 08:30:49 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRI8_R - Instructions like "add reg, reg, imm8".
|
|
|
|
class BinOpRI8_R<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRI8<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.Imm8Operator:$src2))]>;
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpRI8_F - Instructions like "cmp reg, imm8".
|
|
|
|
class BinOpRI8_F<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpRI8<opcode, mnemonic, typeinfo, f, (outs),
|
|
|
|
[(set EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.Imm8Operator:$src2))]>;
|
2010-10-06 13:35:22 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// BinOpRI8_RF - Instructions like "add reg, reg, imm8".
|
|
|
|
class BinOpRI8_RF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2010-10-08 04:56:25 +08:00
|
|
|
: BinOpRI8<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
2010-10-08 04:14:23 +08:00
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.Imm8Operator:$src2))]>;
|
2010-10-07 08:12:45 +08:00
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpRI8_RFF - Instructions like "adc reg, reg, imm8".
|
|
|
|
class BinOpRI8_RFF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpRI8<opcode, mnemonic, typeinfo, f, (outs typeinfo.RegClass:$dst),
|
|
|
|
[(set typeinfo.RegClass:$dst, EFLAGS,
|
|
|
|
(opnode typeinfo.RegClass:$src1, typeinfo.Imm8Operator:$src2,
|
2013-09-14 03:23:28 +08:00
|
|
|
EFLAGS))], IIC_BIN_CARRY_NONMEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-07 08:35:28 +08:00
|
|
|
// BinOpMR - Instructions like "add [mem], reg".
|
|
|
|
class BinOpMR<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
list<dag> pattern, InstrItinClass itin = IIC_BIN_MEM>
|
2010-10-07 08:35:28 +08:00
|
|
|
: ITy<opcode, MRMDestMem, typeinfo,
|
|
|
|
(outs), (ins typeinfo.MemOperand:$dst, typeinfo.RegClass:$src),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src, $dst|$dst, $src}", pattern, itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALULd, WriteRMW]>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
|
|
|
// BinOpMR_RMW - Instructions like "add [mem], reg".
|
|
|
|
class BinOpMR_RMW<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
|
|
|
: BinOpMR<opcode, mnemonic, typeinfo,
|
|
|
|
[(store (opnode (load addr:$dst), typeinfo.RegClass:$src), addr:$dst),
|
|
|
|
(implicit EFLAGS)]>;
|
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpMR_RMW_FF - Instructions like "adc [mem], reg".
|
|
|
|
class BinOpMR_RMW_FF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
|
|
|
: BinOpMR<opcode, mnemonic, typeinfo,
|
|
|
|
[(store (opnode (load addr:$dst), typeinfo.RegClass:$src, EFLAGS),
|
|
|
|
addr:$dst),
|
2013-09-14 03:23:28 +08:00
|
|
|
(implicit EFLAGS)], IIC_BIN_CARRY_MEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpMR_F - Instructions like "cmp [mem], reg".
|
|
|
|
class BinOpMR_F<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode>
|
|
|
|
: BinOpMR<opcode, mnemonic, typeinfo,
|
|
|
|
[(set EFLAGS, (opnode (load addr:$dst), typeinfo.RegClass:$src))]>;
|
2010-10-07 08:35:28 +08:00
|
|
|
|
|
|
|
// BinOpMI - Instructions like "add [mem], imm".
|
2010-10-08 04:06:24 +08:00
|
|
|
class BinOpMI<string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
Format f, list<dag> pattern, bits<8> opcode = 0x80,
|
|
|
|
InstrItinClass itin = IIC_BIN_MEM>
|
2010-10-08 05:31:03 +08:00
|
|
|
: ITy<opcode, f, typeinfo,
|
2010-10-07 08:35:28 +08:00
|
|
|
(outs), (ins typeinfo.MemOperand:$dst, typeinfo.ImmOperand:$src),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src, $dst|$dst, $src}", pattern, itin>,
|
2013-03-19 05:32:39 +08:00
|
|
|
Sched<[WriteALULd, WriteRMW]> {
|
2010-10-07 08:35:28 +08:00
|
|
|
let ImmT = typeinfo.ImmEncoding;
|
|
|
|
}
|
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpMI_RMW - Instructions like "add [mem], imm".
|
|
|
|
class BinOpMI_RMW<string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2012-12-27 06:19:23 +08:00
|
|
|
: BinOpMI<mnemonic, typeinfo, f,
|
2010-10-08 04:56:25 +08:00
|
|
|
[(store (opnode (typeinfo.VT (load addr:$dst)),
|
|
|
|
typeinfo.ImmOperator:$src), addr:$dst),
|
|
|
|
(implicit EFLAGS)]>;
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpMI_RMW_FF - Instructions like "adc [mem], imm".
|
|
|
|
class BinOpMI_RMW_FF<string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
2012-12-27 06:19:23 +08:00
|
|
|
: BinOpMI<mnemonic, typeinfo, f,
|
2010-12-20 08:59:46 +08:00
|
|
|
[(store (opnode (typeinfo.VT (load addr:$dst)),
|
|
|
|
typeinfo.ImmOperator:$src, EFLAGS), addr:$dst),
|
2013-09-14 03:23:28 +08:00
|
|
|
(implicit EFLAGS)], 0x80, IIC_BIN_CARRY_MEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpMI_F - Instructions like "cmp [mem], imm".
|
|
|
|
class BinOpMI_F<string mnemonic, X86TypeInfo typeinfo,
|
2010-10-08 05:31:03 +08:00
|
|
|
SDPatternOperator opnode, Format f, bits<8> opcode = 0x80>
|
2012-12-27 06:19:23 +08:00
|
|
|
: BinOpMI<mnemonic, typeinfo, f,
|
2010-10-08 04:56:25 +08:00
|
|
|
[(set EFLAGS, (opnode (typeinfo.VT (load addr:$dst)),
|
2010-10-08 05:31:03 +08:00
|
|
|
typeinfo.ImmOperator:$src))],
|
|
|
|
opcode>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
2010-10-07 08:35:28 +08:00
|
|
|
// BinOpMI8 - Instructions like "add [mem], imm8".
|
2010-10-08 04:06:24 +08:00
|
|
|
class BinOpMI8<string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
Format f, list<dag> pattern,
|
|
|
|
InstrItinClass itin = IIC_BIN_MEM>
|
2010-10-08 04:06:24 +08:00
|
|
|
: ITy<0x82, f, typeinfo,
|
2010-10-07 08:35:28 +08:00
|
|
|
(outs), (ins typeinfo.MemOperand:$dst, typeinfo.Imm8Operand:$src),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, "{$src, $dst|$dst, $src}", pattern, itin>,
|
2013-03-21 00:56:36 +08:00
|
|
|
Sched<[WriteALULd, WriteRMW]> {
|
2010-10-07 08:35:28 +08:00
|
|
|
let ImmT = Imm8; // Always 8-bit immediate.
|
|
|
|
}
|
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpMI8_RMW - Instructions like "add [mem], imm8".
|
|
|
|
class BinOpMI8_RMW<string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpMI8<mnemonic, typeinfo, f,
|
|
|
|
[(store (opnode (load addr:$dst),
|
|
|
|
typeinfo.Imm8Operator:$src), addr:$dst),
|
|
|
|
(implicit EFLAGS)]>;
|
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
// BinOpMI8_RMW_FF - Instructions like "adc [mem], imm8".
|
|
|
|
class BinOpMI8_RMW_FF<string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpMI8<mnemonic, typeinfo, f,
|
|
|
|
[(store (opnode (load addr:$dst),
|
|
|
|
typeinfo.Imm8Operator:$src, EFLAGS), addr:$dst),
|
2013-09-14 03:23:28 +08:00
|
|
|
(implicit EFLAGS)], IIC_BIN_CARRY_MEM>;
|
2010-12-20 08:59:46 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
// BinOpMI8_F - Instructions like "cmp [mem], imm8".
|
|
|
|
class BinOpMI8_F<string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
SDNode opnode, Format f>
|
|
|
|
: BinOpMI8<mnemonic, typeinfo, f,
|
|
|
|
[(set EFLAGS, (opnode (load addr:$dst),
|
|
|
|
typeinfo.Imm8Operator:$src))]>;
|
|
|
|
|
2013-05-30 05:13:57 +08:00
|
|
|
// BinOpAI - Instructions like "add %eax, %eax, imm", that imp-def EFLAGS.
|
2010-10-07 08:43:39 +08:00
|
|
|
class BinOpAI<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
2013-09-14 03:23:28 +08:00
|
|
|
Register areg, string operands,
|
|
|
|
InstrItinClass itin = IIC_BIN_NONMEM>
|
2010-10-07 08:43:39 +08:00
|
|
|
: ITy<opcode, RawFrm, typeinfo,
|
|
|
|
(outs), (ins typeinfo.ImmOperand:$src),
|
2013-09-14 03:23:28 +08:00
|
|
|
mnemonic, operands, [], itin>, Sched<[WriteALU]> {
|
2010-10-07 08:43:39 +08:00
|
|
|
let ImmT = typeinfo.ImmEncoding;
|
|
|
|
let Uses = [areg];
|
2013-05-30 05:13:57 +08:00
|
|
|
let Defs = [areg, EFLAGS];
|
2012-12-27 06:19:23 +08:00
|
|
|
let hasSideEffects = 0;
|
2010-10-07 08:43:39 +08:00
|
|
|
}
|
2010-10-06 13:35:22 +08:00
|
|
|
|
2013-05-30 05:13:57 +08:00
|
|
|
// BinOpAI_FF - Instructions like "adc %eax, %eax, imm", that implicitly define
|
|
|
|
// and use EFLAGS.
|
|
|
|
class BinOpAI_FF<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
|
|
|
|
Register areg, string operands>
|
2013-09-14 03:23:28 +08:00
|
|
|
: BinOpAI<opcode, mnemonic, typeinfo, areg, operands,
|
|
|
|
IIC_BIN_CARRY_NONMEM> {
|
2013-05-30 05:13:57 +08:00
|
|
|
let Uses = [areg, EFLAGS];
|
|
|
|
}
|
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
/// ArithBinOp_RF - This is an arithmetic binary operator where the pattern is
|
|
|
|
/// defined with "(set GPR:$dst, EFLAGS, (...".
|
|
|
|
///
|
|
|
|
/// It would be nice to get rid of the second and third argument here, but
|
|
|
|
/// tblgen can't handle dependent type references aggressively enough: PR8330
|
|
|
|
multiclass ArithBinOp_RF<bits<8> BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4,
|
|
|
|
string mnemonic, Format RegMRM, Format MemMRM,
|
|
|
|
SDNode opnodeflag, SDNode opnode,
|
|
|
|
bit CommutableRR, bit ConvertibleToThreeAddress> {
|
2010-10-07 09:10:20 +08:00
|
|
|
let Defs = [EFLAGS] in {
|
|
|
|
let Constraints = "$src1 = $dst" in {
|
2010-10-07 09:37:01 +08:00
|
|
|
let isCommutable = CommutableRR,
|
|
|
|
isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rr : BinOpRR_RF<BaseOpc, mnemonic, Xi8 , opnodeflag>;
|
|
|
|
def NAME#16rr : BinOpRR_RF<BaseOpc, mnemonic, Xi16, opnodeflag>;
|
|
|
|
def NAME#32rr : BinOpRR_RF<BaseOpc, mnemonic, Xi32, opnodeflag>;
|
|
|
|
def NAME#64rr : BinOpRR_RF<BaseOpc, mnemonic, Xi64, opnodeflag>;
|
2010-10-07 09:10:20 +08:00
|
|
|
} // isCommutable
|
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rr_REV : BinOpRR_Rev<BaseOpc2, mnemonic, Xi8>;
|
|
|
|
def NAME#16rr_REV : BinOpRR_Rev<BaseOpc2, mnemonic, Xi16>;
|
|
|
|
def NAME#32rr_REV : BinOpRR_Rev<BaseOpc2, mnemonic, Xi32>;
|
|
|
|
def NAME#64rr_REV : BinOpRR_Rev<BaseOpc2, mnemonic, Xi64>;
|
2010-10-07 09:10:20 +08:00
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rm : BinOpRM_RF<BaseOpc2, mnemonic, Xi8 , opnodeflag>;
|
|
|
|
def NAME#16rm : BinOpRM_RF<BaseOpc2, mnemonic, Xi16, opnodeflag>;
|
|
|
|
def NAME#32rm : BinOpRM_RF<BaseOpc2, mnemonic, Xi32, opnodeflag>;
|
|
|
|
def NAME#64rm : BinOpRM_RF<BaseOpc2, mnemonic, Xi64, opnodeflag>;
|
2010-10-07 09:10:20 +08:00
|
|
|
|
2010-10-07 09:37:01 +08:00
|
|
|
let isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the ri8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the ri forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16ri8 : BinOpRI8_RF<0x82, mnemonic, Xi16, opnodeflag, RegMRM>;
|
|
|
|
def NAME#32ri8 : BinOpRI8_RF<0x82, mnemonic, Xi32, opnodeflag, RegMRM>;
|
|
|
|
def NAME#64ri8 : BinOpRI8_RF<0x82, mnemonic, Xi64, opnodeflag, RegMRM>;
|
|
|
|
|
|
|
|
def NAME#8ri : BinOpRI_RF<0x80, mnemonic, Xi8 , opnodeflag, RegMRM>;
|
|
|
|
def NAME#16ri : BinOpRI_RF<0x80, mnemonic, Xi16, opnodeflag, RegMRM>;
|
|
|
|
def NAME#32ri : BinOpRI_RF<0x80, mnemonic, Xi32, opnodeflag, RegMRM>;
|
|
|
|
def NAME#64ri32: BinOpRI_RF<0x80, mnemonic, Xi64, opnodeflag, RegMRM>;
|
2010-10-07 09:37:01 +08:00
|
|
|
}
|
2010-10-07 09:10:20 +08:00
|
|
|
} // Constraints = "$src1 = $dst"
|
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8mr : BinOpMR_RMW<BaseOpc, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16mr : BinOpMR_RMW<BaseOpc, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32mr : BinOpMR_RMW<BaseOpc, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64mr : BinOpMR_RMW<BaseOpc, mnemonic, Xi64, opnode>;
|
2010-10-07 09:10:20 +08:00
|
|
|
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the mi8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the mi forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16mi8 : BinOpMI8_RMW<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi8 : BinOpMI8_RMW<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi8 : BinOpMI8_RMW<mnemonic, Xi64, opnode, MemMRM>;
|
|
|
|
|
|
|
|
def NAME#8mi : BinOpMI_RMW<mnemonic, Xi8 , opnode, MemMRM>;
|
|
|
|
def NAME#16mi : BinOpMI_RMW<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi : BinOpMI_RMW<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi32 : BinOpMI_RMW<mnemonic, Xi64, opnode, MemMRM>;
|
2013-05-30 05:13:57 +08:00
|
|
|
} // Defs = [EFLAGS]
|
2013-01-07 13:26:58 +08:00
|
|
|
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#8i8 : BinOpAI<BaseOpc4, mnemonic, Xi8 , AL,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %al|al, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#16i16 : BinOpAI<BaseOpc4, mnemonic, Xi16, AX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %ax|ax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#32i32 : BinOpAI<BaseOpc4, mnemonic, Xi32, EAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %eax|eax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#64i32 : BinOpAI<BaseOpc4, mnemonic, Xi64, RAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %rax|rax, $src}">;
|
2010-10-07 09:10:20 +08:00
|
|
|
}
|
2010-10-06 04:35:37 +08:00
|
|
|
|
2010-12-20 08:59:46 +08:00
|
|
|
/// ArithBinOp_RFF - This is an arithmetic binary operator where the pattern is
|
|
|
|
/// defined with "(set GPR:$dst, EFLAGS, (node LHS, RHS, EFLAGS))" like ADC and
|
|
|
|
/// SBB.
|
2010-10-08 04:01:55 +08:00
|
|
|
///
|
2010-12-20 08:59:46 +08:00
|
|
|
/// It would be nice to get rid of the second and third argument here, but
|
|
|
|
/// tblgen can't handle dependent type references aggressively enough: PR8330
|
|
|
|
multiclass ArithBinOp_RFF<bits<8> BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4,
|
|
|
|
string mnemonic, Format RegMRM, Format MemMRM,
|
|
|
|
SDNode opnode, bit CommutableRR,
|
|
|
|
bit ConvertibleToThreeAddress> {
|
2013-05-30 05:13:57 +08:00
|
|
|
let Uses = [EFLAGS], Defs = [EFLAGS] in {
|
2010-10-08 04:01:55 +08:00
|
|
|
let Constraints = "$src1 = $dst" in {
|
|
|
|
let isCommutable = CommutableRR,
|
|
|
|
isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rr : BinOpRR_RFF<BaseOpc, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16rr : BinOpRR_RFF<BaseOpc, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32rr : BinOpRR_RFF<BaseOpc, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64rr : BinOpRR_RFF<BaseOpc, mnemonic, Xi64, opnode>;
|
2010-10-08 04:01:55 +08:00
|
|
|
} // isCommutable
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2013-09-14 03:23:28 +08:00
|
|
|
def NAME#8rr_REV : BinOpRR_RFF_Rev<BaseOpc2, mnemonic, Xi8>;
|
|
|
|
def NAME#16rr_REV : BinOpRR_RFF_Rev<BaseOpc2, mnemonic, Xi16>;
|
|
|
|
def NAME#32rr_REV : BinOpRR_RFF_Rev<BaseOpc2, mnemonic, Xi32>;
|
|
|
|
def NAME#64rr_REV : BinOpRR_RFF_Rev<BaseOpc2, mnemonic, Xi64>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rm : BinOpRM_RFF<BaseOpc2, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16rm : BinOpRM_RFF<BaseOpc2, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32rm : BinOpRM_RFF<BaseOpc2, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64rm : BinOpRM_RFF<BaseOpc2, mnemonic, Xi64, opnode>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
let isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the ri8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the ri forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16ri8 : BinOpRI8_RFF<0x82, mnemonic, Xi16, opnode, RegMRM>;
|
|
|
|
def NAME#32ri8 : BinOpRI8_RFF<0x82, mnemonic, Xi32, opnode, RegMRM>;
|
|
|
|
def NAME#64ri8 : BinOpRI8_RFF<0x82, mnemonic, Xi64, opnode, RegMRM>;
|
|
|
|
|
|
|
|
def NAME#8ri : BinOpRI_RFF<0x80, mnemonic, Xi8 , opnode, RegMRM>;
|
|
|
|
def NAME#16ri : BinOpRI_RFF<0x80, mnemonic, Xi16, opnode, RegMRM>;
|
|
|
|
def NAME#32ri : BinOpRI_RFF<0x80, mnemonic, Xi32, opnode, RegMRM>;
|
|
|
|
def NAME#64ri32: BinOpRI_RFF<0x80, mnemonic, Xi64, opnode, RegMRM>;
|
2010-10-08 04:01:55 +08:00
|
|
|
}
|
|
|
|
} // Constraints = "$src1 = $dst"
|
2010-10-06 04:23:31 +08:00
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8mr : BinOpMR_RMW_FF<BaseOpc, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16mr : BinOpMR_RMW_FF<BaseOpc, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32mr : BinOpMR_RMW_FF<BaseOpc, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64mr : BinOpMR_RMW_FF<BaseOpc, mnemonic, Xi64, opnode>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the mi8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the mi forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16mi8 : BinOpMI8_RMW_FF<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi8 : BinOpMI8_RMW_FF<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi8 : BinOpMI8_RMW_FF<mnemonic, Xi64, opnode, MemMRM>;
|
|
|
|
|
|
|
|
def NAME#8mi : BinOpMI_RMW_FF<mnemonic, Xi8 , opnode, MemMRM>;
|
|
|
|
def NAME#16mi : BinOpMI_RMW_FF<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi : BinOpMI_RMW_FF<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi32 : BinOpMI_RMW_FF<mnemonic, Xi64, opnode, MemMRM>;
|
2013-05-30 05:13:57 +08:00
|
|
|
} // Uses = [EFLAGS], Defs = [EFLAGS]
|
|
|
|
|
|
|
|
def NAME#8i8 : BinOpAI_FF<BaseOpc4, mnemonic, Xi8 , AL,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %al|al, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#16i16 : BinOpAI_FF<BaseOpc4, mnemonic, Xi16, AX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %ax|ax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#32i32 : BinOpAI_FF<BaseOpc4, mnemonic, Xi32, EAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %eax|eax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#64i32 : BinOpAI_FF<BaseOpc4, mnemonic, Xi64, RAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %rax|rax, $src}">;
|
2010-10-08 04:56:25 +08:00
|
|
|
}
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2010-10-08 04:56:25 +08:00
|
|
|
/// ArithBinOp_F - This is an arithmetic binary operator where the pattern is
|
|
|
|
/// defined with "(set EFLAGS, (...". It would be really nice to find a way
|
|
|
|
/// to factor this with the other ArithBinOp_*.
|
|
|
|
///
|
|
|
|
multiclass ArithBinOp_F<bits<8> BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4,
|
|
|
|
string mnemonic, Format RegMRM, Format MemMRM,
|
|
|
|
SDNode opnode,
|
|
|
|
bit CommutableRR, bit ConvertibleToThreeAddress> {
|
|
|
|
let Defs = [EFLAGS] in {
|
|
|
|
let isCommutable = CommutableRR,
|
|
|
|
isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rr : BinOpRR_F<BaseOpc, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16rr : BinOpRR_F<BaseOpc, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32rr : BinOpRR_F<BaseOpc, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64rr : BinOpRR_F<BaseOpc, mnemonic, Xi64, opnode>;
|
2010-10-08 04:56:25 +08:00
|
|
|
} // isCommutable
|
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rr_REV : BinOpRR_F_Rev<BaseOpc2, mnemonic, Xi8>;
|
|
|
|
def NAME#16rr_REV : BinOpRR_F_Rev<BaseOpc2, mnemonic, Xi16>;
|
|
|
|
def NAME#32rr_REV : BinOpRR_F_Rev<BaseOpc2, mnemonic, Xi32>;
|
|
|
|
def NAME#64rr_REV : BinOpRR_F_Rev<BaseOpc2, mnemonic, Xi64>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8rm : BinOpRM_F<BaseOpc2, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16rm : BinOpRM_F<BaseOpc2, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32rm : BinOpRM_F<BaseOpc2, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64rm : BinOpRM_F<BaseOpc2, mnemonic, Xi64, opnode>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
|
|
|
let isConvertibleToThreeAddress = ConvertibleToThreeAddress in {
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the ri8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the ri forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16ri8 : BinOpRI8_F<0x82, mnemonic, Xi16, opnode, RegMRM>;
|
|
|
|
def NAME#32ri8 : BinOpRI8_F<0x82, mnemonic, Xi32, opnode, RegMRM>;
|
|
|
|
def NAME#64ri8 : BinOpRI8_F<0x82, mnemonic, Xi64, opnode, RegMRM>;
|
|
|
|
|
|
|
|
def NAME#8ri : BinOpRI_F<0x80, mnemonic, Xi8 , opnode, RegMRM>;
|
|
|
|
def NAME#16ri : BinOpRI_F<0x80, mnemonic, Xi16, opnode, RegMRM>;
|
|
|
|
def NAME#32ri : BinOpRI_F<0x80, mnemonic, Xi32, opnode, RegMRM>;
|
|
|
|
def NAME#64ri32: BinOpRI_F<0x80, mnemonic, Xi64, opnode, RegMRM>;
|
2010-10-08 04:56:25 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#8mr : BinOpMR_F<BaseOpc, mnemonic, Xi8 , opnode>;
|
|
|
|
def NAME#16mr : BinOpMR_F<BaseOpc, mnemonic, Xi16, opnode>;
|
|
|
|
def NAME#32mr : BinOpMR_F<BaseOpc, mnemonic, Xi32, opnode>;
|
|
|
|
def NAME#64mr : BinOpMR_F<BaseOpc, mnemonic, Xi64, opnode>;
|
2010-10-08 04:56:25 +08:00
|
|
|
|
fix a subtle bug I introduced in my refactoring, where we stopped preferring
the i8 versions of instructions in some cases. In test6, we started
generating:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x81,0x7c,0x24,0xf8,0x00,0x00,0x00,0x00]
## <MCInst #478 CMP64mi32
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
instead of:
cmpq $0, -8(%rsp) ## encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
## <MCInst #479 CMP64mi8
## <MCOperand Reg:114>
## <MCOperand Imm:1>
## <MCOperand Reg:0>
## <MCOperand Imm:-8>
## <MCOperand Reg:0>
## <MCOperand Imm:0>>
Fix this and add some comments.
llvm-svn: 116053
2010-10-08 13:12:14 +08:00
|
|
|
// NOTE: These are order specific, we want the mi8 forms to be listed
|
|
|
|
// first so that they are slightly preferred to the mi forms.
|
2013-01-07 13:26:58 +08:00
|
|
|
def NAME#16mi8 : BinOpMI8_F<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi8 : BinOpMI8_F<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi8 : BinOpMI8_F<mnemonic, Xi64, opnode, MemMRM>;
|
|
|
|
|
|
|
|
def NAME#8mi : BinOpMI_F<mnemonic, Xi8 , opnode, MemMRM>;
|
|
|
|
def NAME#16mi : BinOpMI_F<mnemonic, Xi16, opnode, MemMRM>;
|
|
|
|
def NAME#32mi : BinOpMI_F<mnemonic, Xi32, opnode, MemMRM>;
|
|
|
|
def NAME#64mi32 : BinOpMI_F<mnemonic, Xi64, opnode, MemMRM>;
|
2013-05-30 05:13:57 +08:00
|
|
|
} // Defs = [EFLAGS]
|
2013-01-07 13:26:58 +08:00
|
|
|
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#8i8 : BinOpAI<BaseOpc4, mnemonic, Xi8 , AL,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %al|al, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#16i16 : BinOpAI<BaseOpc4, mnemonic, Xi16, AX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %ax|ax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#32i32 : BinOpAI<BaseOpc4, mnemonic, Xi32, EAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %eax|eax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
def NAME#64i32 : BinOpAI<BaseOpc4, mnemonic, Xi64, RAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %rax|rax, $src}">;
|
2010-10-08 04:01:55 +08:00
|
|
|
}
|
2010-10-06 00:52:25 +08:00
|
|
|
|
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
defm AND : ArithBinOp_RF<0x20, 0x22, 0x24, "and", MRM4r, MRM4m,
|
|
|
|
X86and_flag, and, 1, 0>;
|
|
|
|
defm OR : ArithBinOp_RF<0x08, 0x0A, 0x0C, "or", MRM1r, MRM1m,
|
|
|
|
X86or_flag, or, 1, 0>;
|
|
|
|
defm XOR : ArithBinOp_RF<0x30, 0x32, 0x34, "xor", MRM6r, MRM6m,
|
|
|
|
X86xor_flag, xor, 1, 0>;
|
|
|
|
defm ADD : ArithBinOp_RF<0x00, 0x02, 0x04, "add", MRM0r, MRM0m,
|
|
|
|
X86add_flag, add, 1, 1>;
|
2012-08-08 08:51:41 +08:00
|
|
|
let isCompare = 1 in {
|
2010-10-08 04:01:55 +08:00
|
|
|
defm SUB : ArithBinOp_RF<0x28, 0x2A, 0x2C, "sub", MRM5r, MRM5m,
|
|
|
|
X86sub_flag, sub, 0, 0>;
|
2012-08-08 08:51:41 +08:00
|
|
|
}
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2010-10-08 04:01:55 +08:00
|
|
|
// Arithmetic.
|
2013-05-30 05:13:57 +08:00
|
|
|
defm ADC : ArithBinOp_RFF<0x10, 0x12, 0x14, "adc", MRM2r, MRM2m, X86adc_flag,
|
|
|
|
1, 0>;
|
|
|
|
defm SBB : ArithBinOp_RFF<0x18, 0x1A, 0x1C, "sbb", MRM3r, MRM3m, X86sbb_flag,
|
|
|
|
0, 0>;
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2012-07-07 01:36:20 +08:00
|
|
|
let isCompare = 1 in {
|
2010-10-08 05:31:03 +08:00
|
|
|
defm CMP : ArithBinOp_F<0x38, 0x3A, 0x3C, "cmp", MRM7r, MRM7m, X86cmp, 0, 0>;
|
2012-07-07 01:36:20 +08:00
|
|
|
}
|
2010-10-06 00:39:12 +08:00
|
|
|
|
2010-10-06 04:49:15 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-10-08 05:31:03 +08:00
|
|
|
// Semantically, test instructions are similar like AND, except they don't
|
|
|
|
// generate a result. From an encoding perspective, they are very different:
|
|
|
|
// they don't have all the usual imm8 and REV forms, and are encoded into a
|
|
|
|
// different space.
|
|
|
|
def X86testpat : PatFrag<(ops node:$lhs, node:$rhs),
|
|
|
|
(X86cmp (and_su node:$lhs, node:$rhs), 0)>;
|
|
|
|
|
2013-05-30 05:13:57 +08:00
|
|
|
let isCompare = 1 in {
|
|
|
|
let Defs = [EFLAGS] in {
|
|
|
|
let isCommutable = 1 in {
|
|
|
|
def TEST8rr : BinOpRR_F<0x84, "test", Xi8 , X86testpat, MRMSrcReg>;
|
|
|
|
def TEST16rr : BinOpRR_F<0x84, "test", Xi16, X86testpat, MRMSrcReg>;
|
|
|
|
def TEST32rr : BinOpRR_F<0x84, "test", Xi32, X86testpat, MRMSrcReg>;
|
|
|
|
def TEST64rr : BinOpRR_F<0x84, "test", Xi64, X86testpat, MRMSrcReg>;
|
|
|
|
} // isCommutable
|
|
|
|
|
|
|
|
def TEST8rm : BinOpRM_F<0x84, "test", Xi8 , X86testpat>;
|
|
|
|
def TEST16rm : BinOpRM_F<0x84, "test", Xi16, X86testpat>;
|
|
|
|
def TEST32rm : BinOpRM_F<0x84, "test", Xi32, X86testpat>;
|
|
|
|
def TEST64rm : BinOpRM_F<0x84, "test", Xi64, X86testpat>;
|
|
|
|
|
|
|
|
def TEST8ri : BinOpRI_F<0xF6, "test", Xi8 , X86testpat, MRM0r>;
|
|
|
|
def TEST16ri : BinOpRI_F<0xF6, "test", Xi16, X86testpat, MRM0r>;
|
|
|
|
def TEST32ri : BinOpRI_F<0xF6, "test", Xi32, X86testpat, MRM0r>;
|
|
|
|
def TEST64ri32 : BinOpRI_F<0xF6, "test", Xi64, X86testpat, MRM0r>;
|
|
|
|
|
|
|
|
def TEST8mi : BinOpMI_F<"test", Xi8 , X86testpat, MRM0m, 0xF6>;
|
|
|
|
def TEST16mi : BinOpMI_F<"test", Xi16, X86testpat, MRM0m, 0xF6>;
|
|
|
|
def TEST32mi : BinOpMI_F<"test", Xi32, X86testpat, MRM0m, 0xF6>;
|
|
|
|
def TEST64mi32 : BinOpMI_F<"test", Xi64, X86testpat, MRM0m, 0xF6>;
|
|
|
|
|
|
|
|
// When testing the result of EXTRACT_SUBREG sub_8bit_hi, make sure the
|
|
|
|
// register class is constrained to GR8_NOREX.
|
|
|
|
let isPseudo = 1 in
|
|
|
|
def TEST8ri_NOREX : I<0, Pseudo, (outs), (ins GR8_NOREX:$src, i8imm:$mask),
|
|
|
|
"", [], IIC_BIN_NONMEM>, Sched<[WriteALU]>;
|
|
|
|
} // Defs = [EFLAGS]
|
2012-12-27 06:19:23 +08:00
|
|
|
|
2011-10-03 05:08:12 +08:00
|
|
|
def TEST8i8 : BinOpAI<0xA8, "test", Xi8 , AL,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %al|al, $src}">;
|
2011-10-03 05:08:12 +08:00
|
|
|
def TEST16i16 : BinOpAI<0xA8, "test", Xi16, AX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %ax|ax, $src}">;
|
2011-10-03 05:08:12 +08:00
|
|
|
def TEST32i32 : BinOpAI<0xA8, "test", Xi32, EAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %eax|eax, $src}">;
|
2011-10-03 05:08:12 +08:00
|
|
|
def TEST64i32 : BinOpAI<0xA8, "test", Xi64, RAX,
|
2013-07-31 10:47:52 +08:00
|
|
|
"{$src, %rax|rax, $src}">;
|
2013-05-30 05:13:57 +08:00
|
|
|
} // isCompare
|
2011-10-14 15:06:56 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ANDN Instruction
|
|
|
|
//
|
|
|
|
multiclass bmi_andn<string mnemonic, RegisterClass RC, X86MemOperand x86memop,
|
|
|
|
PatFrag ld_frag> {
|
|
|
|
def rr : I<0xF2, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
|
|
|
|
!strconcat(mnemonic, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
|
2012-12-17 13:12:30 +08:00
|
|
|
[(set RC:$dst, EFLAGS, (X86and_flag (not RC:$src1), RC:$src2))],
|
2013-03-19 05:32:39 +08:00
|
|
|
IIC_BIN_NONMEM>, Sched<[WriteALU]>;
|
2011-10-14 15:06:56 +08:00
|
|
|
def rm : I<0xF2, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2),
|
|
|
|
!strconcat(mnemonic, "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
|
|
|
|
[(set RC:$dst, EFLAGS,
|
2013-03-19 05:32:39 +08:00
|
|
|
(X86and_flag (not RC:$src1), (ld_frag addr:$src2)))], IIC_BIN_MEM>,
|
|
|
|
Sched<[WriteALULd, ReadAfterLd]>;
|
2011-10-14 15:06:56 +08:00
|
|
|
}
|
2010-10-06 04:49:15 +08:00
|
|
|
|
2011-10-14 15:06:56 +08:00
|
|
|
let Predicates = [HasBMI], Defs = [EFLAGS] in {
|
|
|
|
defm ANDN32 : bmi_andn<"andn{l}", GR32, i32mem, loadi32>, T8, VEX_4V;
|
|
|
|
defm ANDN64 : bmi_andn<"andn{q}", GR64, i64mem, loadi64>, T8, VEX_4V, VEX_W;
|
|
|
|
}
|
2011-10-23 08:33:32 +08:00
|
|
|
|
2012-12-17 13:12:30 +08:00
|
|
|
let Predicates = [HasBMI] in {
|
|
|
|
def : Pat<(and (not GR32:$src1), GR32:$src2),
|
|
|
|
(ANDN32rr GR32:$src1, GR32:$src2)>;
|
|
|
|
def : Pat<(and (not GR64:$src1), GR64:$src2),
|
|
|
|
(ANDN64rr GR64:$src1, GR64:$src2)>;
|
|
|
|
def : Pat<(and (not GR32:$src1), (loadi32 addr:$src2)),
|
|
|
|
(ANDN32rm GR32:$src1, addr:$src2)>;
|
|
|
|
def : Pat<(and (not GR64:$src1), (loadi64 addr:$src2)),
|
|
|
|
(ANDN64rm GR64:$src1, addr:$src2)>;
|
|
|
|
}
|
|
|
|
|
2011-10-23 08:33:32 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MULX Instruction
|
|
|
|
//
|
|
|
|
multiclass bmi_mulx<string mnemonic, RegisterClass RC, X86MemOperand x86memop> {
|
|
|
|
let neverHasSideEffects = 1 in {
|
|
|
|
let isCommutable = 1 in
|
|
|
|
def rr : I<0xF6, MRMSrcReg, (outs RC:$dst1, RC:$dst2), (ins RC:$src),
|
|
|
|
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
|
2013-06-22 02:33:04 +08:00
|
|
|
[], IIC_MUL8>, T8XD, VEX_4V, Sched<[WriteIMul, WriteIMulH]>;
|
2011-10-23 08:33:32 +08:00
|
|
|
|
|
|
|
let mayLoad = 1 in
|
|
|
|
def rm : I<0xF6, MRMSrcMem, (outs RC:$dst1, RC:$dst2), (ins x86memop:$src),
|
|
|
|
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
|
2013-06-22 02:33:04 +08:00
|
|
|
[], IIC_MUL8>, T8XD, VEX_4V, Sched<[WriteIMulLd, WriteIMulH]>;
|
2011-10-23 08:33:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let Predicates = [HasBMI2] in {
|
|
|
|
let Uses = [EDX] in
|
|
|
|
defm MULX32 : bmi_mulx<"mulx{l}", GR32, i32mem>;
|
|
|
|
let Uses = [RDX] in
|
|
|
|
defm MULX64 : bmi_mulx<"mulx{q}", GR64, i64mem>, VEX_W;
|
|
|
|
}
|
2013-02-15 03:08:21 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ADCX Instruction
|
|
|
|
//
|
|
|
|
let hasSideEffects = 0, Predicates = [HasADX], Defs = [EFLAGS] in {
|
2013-03-21 00:56:36 +08:00
|
|
|
let SchedRW = [WriteALU] in {
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADCX32rr : I<0xF6, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
|
|
|
|
"adcx{l}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_NONMEM>, T8, OpSize;
|
|
|
|
|
|
|
|
def ADCX64rr : I<0xF6, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
|
|
|
|
"adcx{q}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_NONMEM>, T8, OpSize, REX_W, Requires<[In64BitMode]>;
|
2013-03-21 00:56:36 +08:00
|
|
|
} // SchedRW
|
2013-02-15 03:08:21 +08:00
|
|
|
|
2013-03-21 00:56:36 +08:00
|
|
|
let mayLoad = 1, SchedRW = [WriteALULd] in {
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADCX32rm : I<0xF6, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
|
|
|
|
"adcx{l}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_MEM>, T8, OpSize;
|
2013-06-22 02:33:04 +08:00
|
|
|
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADCX64rm : I<0xF6, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
|
|
|
|
"adcx{q}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_MEM>, T8, OpSize, REX_W, Requires<[In64BitMode]>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ADOX Instruction
|
|
|
|
//
|
|
|
|
let hasSideEffects = 0, Predicates = [HasADX], Defs = [EFLAGS] in {
|
2013-03-21 00:56:36 +08:00
|
|
|
let SchedRW = [WriteALU] in {
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADOX32rr : I<0xF6, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
|
|
|
|
"adox{l}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_NONMEM>, T8XS;
|
|
|
|
|
|
|
|
def ADOX64rr : I<0xF6, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
|
|
|
|
"adox{q}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_NONMEM>, T8XS, REX_W, Requires<[In64BitMode]>;
|
2013-03-21 00:56:36 +08:00
|
|
|
} // SchedRW
|
2013-02-15 03:08:21 +08:00
|
|
|
|
2013-03-21 00:56:36 +08:00
|
|
|
let mayLoad = 1, SchedRW = [WriteALULd] in {
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADOX32rm : I<0xF6, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
|
|
|
|
"adox{l}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_MEM>, T8XS;
|
2013-06-22 02:33:04 +08:00
|
|
|
|
2013-02-15 03:08:21 +08:00
|
|
|
def ADOX64rm : I<0xF6, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
|
|
|
|
"adox{q}\t{$src, $dst|$dst, $src}",
|
|
|
|
[], IIC_BIN_MEM>, T8XS, REX_W, Requires<[In64BitMode]>;
|
|
|
|
}
|
|
|
|
}
|