Simplify *(x+y) to x[y]. NFC.

They are equivalent in C (and in C++ in this case).

llvm-svn: 272942
This commit is contained in:
Rui Ueyama 2016-06-16 19:48:07 +00:00
parent b0bd07aff7
commit 595bc5db4b
1 changed files with 11 additions and 11 deletions

View File

@ -824,11 +824,11 @@ void X86_64TargetInfo::relaxGotNoPic(uint8_t *Loc, uint64_t Val, uint8_t Op,
// 0x38 == 00 111 000 binary.
// We transfer reg2 to reg1 here as operand.
// See "2.1.3 ModR/M and SIB Bytes" (Vol. 2A 2-3).
*(Loc - 1) = 0xc0 | (ModRm & 0x38) >> 3; // ModR/M byte.
Loc[-1] = 0xc0 | (ModRm & 0x38) >> 3; // ModR/M byte.
// Change opcode from TEST r/m64, r64 to TEST r/m64, imm32
// See "TEST-Logical Compare" (4-428 Vol. 2B).
*(Loc - 2) = 0xf7;
Loc[-2] = 0xf7;
// Move R bit to the B bit in REX byte.
// REX byte is encoded as 0100WRXB, where
@ -841,7 +841,7 @@ void X86_64TargetInfo::relaxGotNoPic(uint8_t *Loc, uint64_t Val, uint8_t Op,
// REX.B This 1-bit value is an extension to the MODRM.rm field or the
// SIB.base field.
// See "2.2.1.2 More on REX Prefix Fields " (2-8 Vol. 2A).
*(Loc - 3) = (Rex & ~0x4) | (Rex & 0x4) >> 2;
Loc[-3] = (Rex & ~0x4) | (Rex & 0x4) >> 2;
relocateOne(Loc, R_X86_64_PC32, Val);
return;
}
@ -852,7 +852,7 @@ void X86_64TargetInfo::relaxGotNoPic(uint8_t *Loc, uint64_t Val, uint8_t Op,
// Convert "binop foo@GOTPCREL(%rip), %reg" to "binop $foo, %reg".
// Logic is close to one for test instruction above, but we also
// write opcode extension here, see below for details.
*(Loc - 1) = 0xc0 | (ModRm & 0x38) >> 3 | (Op & 0x3c); // ModR/M byte.
Loc[-1] = 0xc0 | (ModRm & 0x38) >> 3 | (Op & 0x3c); // ModR/M byte.
// Primary opcode is 0x81, opcode extension is one of:
// 000b = ADD, 001b is OR, 010b is ADC, 011b is SBB,
@ -861,8 +861,8 @@ void X86_64TargetInfo::relaxGotNoPic(uint8_t *Loc, uint64_t Val, uint8_t Op,
// See "3.2 INSTRUCTIONS (A-M)" (Vol. 2A 3-15),
// "INSTRUCTION SET REFERENCE, N-Z" (Vol. 2B 4-1) for
// descriptions about each operation.
*(Loc - 2) = 0x81;
*(Loc - 3) = (Rex & ~0x4) | (Rex & 0x4) >> 2;
Loc[-2] = 0x81;
Loc[-3] = (Rex & ~0x4) | (Rex & 0x4) >> 2;
relocateOne(Loc, R_X86_64_PC32, Val);
}
@ -872,7 +872,7 @@ void X86_64TargetInfo::relaxGot(uint8_t *Loc, uint64_t Val) const {
// Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %reg.
if (Op == 0x8b) {
*(Loc - 2) = 0x8d;
Loc[-2] = 0x8d;
relocateOne(Loc, R_X86_64_PC32, Val);
return;
}
@ -883,14 +883,14 @@ void X86_64TargetInfo::relaxGot(uint8_t *Loc, uint64_t Val) const {
// ABI says we can convert call *foo@GOTPCREL(%rip) to nop call foo.
// Instead we convert to addr32 call foo, where addr32 is instruction
// prefix. That makes result expression to be a single instruction.
*(Loc - 2) = 0x67; // addr32 prefix
*(Loc - 1) = 0xe8; // call
Loc[-2] = 0x67; // addr32 prefix
Loc[-1] = 0xe8; // call
} else {
assert(ModRm == 0x25);
// Convert jmp *foo@GOTPCREL(%rip) to jmp foo nop.
// jmp doesn't return, so it is fine to use nop here, it is just a stub.
*(Loc - 2) = 0xe9; // jmp
*(Loc + 3) = 0x90; // nop
Loc[-2] = 0xe9; // jmp
Loc[3] = 0x90; // nop
Loc -= 1;
Val += 1;
}