Skip to content

Commit af55b0d

Browse files
committed
[X86][NFC] Fix a bug after D150436 and update some comments
D150436 changed the order for INC*r, but unintentionally remove 'isConvertibleToThreeAddress = 1' for INC*r_alt. This patch also update wrong comment X86InstrArithmetic.td, and move class ITy to InstrInfo.td for it's a general class. Reviewed By: skan Differential Revision: https://reviews.llvm.org/D151527
1 parent 9f6250f commit af55b0d

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

llvm/lib/Target/X86/X86InstrArithmetic.td

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,6 @@ class SchedLoadReg<X86FoldableSchedWrite Sched> : Sched<[Sched.Folded,
5858
// Register reads (implicit or explicit).
5959
Sched.ReadAfterFold, Sched.ReadAfterFold]>;
6060

61-
/// ITy - This instruction base class takes the type info for the instruction.
62-
/// Using this, it:
63-
/// 1. Concatenates together the instruction mnemonic with the appropriate
64-
/// suffix letter, a tab, and the arguments.
65-
/// 2. Infers whether the instruction should have a 0x66 prefix byte.
66-
/// 3. Infers whether the instruction should have a 0x40 REX_W prefix.
67-
/// 4. Infers whether the low bit of the opcode should be 0 (for i8 operations)
68-
/// or 1 (for i16,i32,i64 operations).
69-
class ITy<bits<8> opcode, Format f, X86TypeInfo typeinfo, dag outs, dag ins,
70-
string mnemonic, string args, list<dag> pattern>
71-
: I<{opcode{7}, opcode{6}, opcode{5}, opcode{4},
72-
opcode{3}, opcode{2}, opcode{1}, typeinfo.HasOddOpcode },
73-
f, outs, ins,
74-
!strconcat(mnemonic, "{", typeinfo.InstrSuffix, "}\t", args), pattern> {
75-
76-
// Infer instruction prefixes from type info.
77-
let OpSize = typeinfo.OpSize;
78-
let hasREX_W = typeinfo.HasREX_W;
79-
}
80-
8161
// BinOpRR - Binary instructions with inputs "reg, reg".
8262
class BinOpRR<bits<8> opcode, string mnemonic, X86TypeInfo typeinfo,
8363
dag outlist, X86FoldableSchedWrite sched, list<dag> pattern>
@@ -539,13 +519,13 @@ def X86sub_flag_nocf : PatFrag<(ops node:$lhs, node:$rhs),
539519

540520
let Defs = [EFLAGS] in {
541521
let Constraints = "$src1 = $dst", SchedRW = [WriteALU] in {
542-
let isConvertibleToThreeAddress = 1, CodeSize = 2 in { // Can xform into LEA.
543522
// Short forms only valid in 32-bit mode. Selected during MCInst lowering.
544523
let CodeSize = 1, hasSideEffects = 0 in {
545524
def INC16r_alt : INCDECR_ALT<0x40, "inc", Xi16>;
546525
def INC32r_alt : INCDECR_ALT<0x40, "inc", Xi32>;
547526
} // CodeSize = 1, hasSideEffects = 0
548527

528+
let isConvertibleToThreeAddress = 1, CodeSize = 2 in { // Can xform into LEA.
549529
def INC8r : INCDECR<MRM0r, "inc", Xi8, X86add_flag_nocf>;
550530
def INC16r : INCDECR<MRM0r, "inc", Xi16, X86add_flag_nocf>;
551531
def INC32r : INCDECR<MRM0r, "inc", Xi32, X86add_flag_nocf>;
@@ -777,7 +757,7 @@ let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in // RDX:RAX/[mem64] = RAX,RDX
777757
def IDIV64m: MulOpM<0xF7, MRM7m, "idiv", Xi64, WriteIDiv64, []>,
778758
Requires<[In64BitMode]>;
779759
}
780-
} // hasSideEffects = 0
760+
} // hasSideEffects = 1
781761

782762
//===----------------------------------------------------------------------===//
783763
// Two address Instructions.

llvm/lib/Target/X86/X86InstrInfo.td

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,27 @@ def Xi32 : X86TypeInfo<i32, "l", GR32, loadi32, i32mem, Imm32, i32imm,
13841384
def Xi64 : X86TypeInfo<i64, "q", GR64, loadi64, i64mem, Imm32S, i64i32imm,
13851385
i64immSExt32_su, i64immSExt32, i64i8imm, i64immSExt8_su,
13861386
i64immSExt8, 1, OpSizeFixed, 1>;
1387+
1388+
/// ITy - This instruction base class takes the type info for the instruction.
1389+
/// Using this, it:
1390+
/// 1. Concatenates together the instruction mnemonic with the appropriate
1391+
/// suffix letter, a tab, and the arguments.
1392+
/// 2. Infers whether the instruction should have a 0x66 prefix byte.
1393+
/// 3. Infers whether the instruction should have a 0x40 REX_W prefix.
1394+
/// 4. Infers whether the low bit of the opcode should be 0 (for i8 operations)
1395+
/// or 1 (for i16,i32,i64 operations).
1396+
class ITy<bits<8> opcode, Format f, X86TypeInfo typeinfo, dag outs, dag ins,
1397+
string mnemonic, string args, list<dag> pattern>
1398+
: I<{opcode{7}, opcode{6}, opcode{5}, opcode{4},
1399+
opcode{3}, opcode{2}, opcode{1}, typeinfo.HasOddOpcode },
1400+
f, outs, ins,
1401+
!strconcat(mnemonic, "{", typeinfo.InstrSuffix, "}\t", args), pattern> {
1402+
1403+
// Infer instruction prefixes from type info.
1404+
let OpSize = typeinfo.OpSize;
1405+
let hasREX_W = typeinfo.HasREX_W;
1406+
}
1407+
13871408
//===----------------------------------------------------------------------===//
13881409
// Subsystems.
13891410
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)