mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 04:33:40 +00:00
add some long-overdue enums to refer to the parts of the 5-operand
X86 memory operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0afbf23453
commit
ac0ed5dc08
@ -730,9 +730,9 @@ void Emitter<CodeEmitter>::emitInstruction(const MachineInstr &MI,
|
||||
case X86II::MRMDestMem: {
|
||||
MCE.emitByte(BaseOpcode);
|
||||
emitMemModRMByte(MI, CurOp,
|
||||
getX86RegNum(MI.getOperand(CurOp + X86AddrNumOperands)
|
||||
getX86RegNum(MI.getOperand(CurOp + X86::AddrNumOperands)
|
||||
.getReg()));
|
||||
CurOp += X86AddrNumOperands + 1;
|
||||
CurOp += X86::AddrNumOperands + 1;
|
||||
if (CurOp != NumOps)
|
||||
emitConstant(MI.getOperand(CurOp++).getImm(),
|
||||
X86II::getSizeOfImm(Desc->TSFlags));
|
||||
@ -754,9 +754,9 @@ void Emitter<CodeEmitter>::emitInstruction(const MachineInstr &MI,
|
||||
int AddrOperands;
|
||||
if (Opcode == X86::LEA64r || Opcode == X86::LEA64_32r ||
|
||||
Opcode == X86::LEA16r || Opcode == X86::LEA32r)
|
||||
AddrOperands = X86AddrNumOperands - 1; // No segment register
|
||||
AddrOperands = X86::AddrNumOperands - 1; // No segment register
|
||||
else
|
||||
AddrOperands = X86AddrNumOperands;
|
||||
AddrOperands = X86::AddrNumOperands;
|
||||
|
||||
intptr_t PCAdj = (CurOp + AddrOperands + 1 != NumOps) ?
|
||||
X86II::getSizeOfImm(Desc->TSFlags) : 0;
|
||||
@ -810,14 +810,14 @@ void Emitter<CodeEmitter>::emitInstruction(const MachineInstr &MI,
|
||||
case X86II::MRM2m: case X86II::MRM3m:
|
||||
case X86II::MRM4m: case X86II::MRM5m:
|
||||
case X86II::MRM6m: case X86II::MRM7m: {
|
||||
intptr_t PCAdj = (CurOp + X86AddrNumOperands != NumOps) ?
|
||||
(MI.getOperand(CurOp+X86AddrNumOperands).isImm() ?
|
||||
intptr_t PCAdj = (CurOp + X86::AddrNumOperands != NumOps) ?
|
||||
(MI.getOperand(CurOp+X86::AddrNumOperands).isImm() ?
|
||||
X86II::getSizeOfImm(Desc->TSFlags) : 4) : 0;
|
||||
|
||||
MCE.emitByte(BaseOpcode);
|
||||
emitMemModRMByte(MI, CurOp, (Desc->TSFlags & X86II::FormMask)-X86II::MRM0m,
|
||||
PCAdj);
|
||||
CurOp += X86AddrNumOperands;
|
||||
CurOp += X86::AddrNumOperands;
|
||||
|
||||
if (CurOp == NumOps)
|
||||
break;
|
||||
|
@ -633,7 +633,7 @@ void FPS::handleZeroArgFP(MachineBasicBlock::iterator &I) {
|
||||
void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) {
|
||||
MachineInstr *MI = I;
|
||||
unsigned NumOps = MI->getDesc().getNumOperands();
|
||||
assert((NumOps == X86AddrNumOperands + 1 || NumOps == 1) &&
|
||||
assert((NumOps == X86::AddrNumOperands + 1 || NumOps == 1) &&
|
||||
"Can only handle fst* & ftst instructions!");
|
||||
|
||||
// Is this the last use of the source register?
|
||||
|
@ -8027,17 +8027,17 @@ X86TargetLowering::EmitAtomicBitwiseWithCustomInserter(MachineInstr *bInstr,
|
||||
newMBB->addSuccessor(newMBB);
|
||||
|
||||
// Insert instructions into newMBB based on incoming instruction
|
||||
assert(bInstr->getNumOperands() < X86AddrNumOperands + 4 &&
|
||||
assert(bInstr->getNumOperands() < X86::AddrNumOperands + 4 &&
|
||||
"unexpected number of operands");
|
||||
DebugLoc dl = bInstr->getDebugLoc();
|
||||
MachineOperand& destOper = bInstr->getOperand(0);
|
||||
MachineOperand* argOpers[2 + X86AddrNumOperands];
|
||||
MachineOperand* argOpers[2 + X86::AddrNumOperands];
|
||||
int numArgs = bInstr->getNumOperands() - 1;
|
||||
for (int i=0; i < numArgs; ++i)
|
||||
argOpers[i] = &bInstr->getOperand(i+1);
|
||||
|
||||
// x86 address has 4 operands: base, index, scale, and displacement
|
||||
int lastAddrIndx = X86AddrNumOperands - 1; // [0,3]
|
||||
int lastAddrIndx = X86::AddrNumOperands - 1; // [0,3]
|
||||
int valArgIndx = lastAddrIndx + 1;
|
||||
|
||||
unsigned t1 = F->getRegInfo().createVirtualRegister(RC);
|
||||
@ -8141,12 +8141,12 @@ X86TargetLowering::EmitAtomicBit6432WithCustomInserter(MachineInstr *bInstr,
|
||||
DebugLoc dl = bInstr->getDebugLoc();
|
||||
// Insert instructions into newMBB based on incoming instruction
|
||||
// There are 8 "real" operands plus 9 implicit def/uses, ignored here.
|
||||
assert(bInstr->getNumOperands() < X86AddrNumOperands + 14 &&
|
||||
assert(bInstr->getNumOperands() < X86::AddrNumOperands + 14 &&
|
||||
"unexpected number of operands");
|
||||
MachineOperand& dest1Oper = bInstr->getOperand(0);
|
||||
MachineOperand& dest2Oper = bInstr->getOperand(1);
|
||||
MachineOperand* argOpers[2 + X86AddrNumOperands];
|
||||
for (int i=0; i < 2 + X86AddrNumOperands; ++i) {
|
||||
MachineOperand* argOpers[2 + X86::AddrNumOperands];
|
||||
for (int i=0; i < 2 + X86::AddrNumOperands; ++i) {
|
||||
argOpers[i] = &bInstr->getOperand(i+2);
|
||||
|
||||
// We use some of the operands multiple times, so conservatively just
|
||||
@ -8156,7 +8156,7 @@ X86TargetLowering::EmitAtomicBit6432WithCustomInserter(MachineInstr *bInstr,
|
||||
}
|
||||
|
||||
// x86 address has 5 operands: base, index, scale, displacement, and segment.
|
||||
int lastAddrIndx = X86AddrNumOperands - 1; // [0,3]
|
||||
int lastAddrIndx = X86::AddrNumOperands - 1; // [0,3]
|
||||
|
||||
unsigned t1 = F->getRegInfo().createVirtualRegister(RC);
|
||||
MachineInstrBuilder MIB = BuildMI(thisMBB, dl, TII->get(LoadOpc), t1);
|
||||
@ -8295,16 +8295,16 @@ X86TargetLowering::EmitAtomicMinMaxWithCustomInserter(MachineInstr *mInstr,
|
||||
|
||||
DebugLoc dl = mInstr->getDebugLoc();
|
||||
// Insert instructions into newMBB based on incoming instruction
|
||||
assert(mInstr->getNumOperands() < X86AddrNumOperands + 4 &&
|
||||
assert(mInstr->getNumOperands() < X86::AddrNumOperands + 4 &&
|
||||
"unexpected number of operands");
|
||||
MachineOperand& destOper = mInstr->getOperand(0);
|
||||
MachineOperand* argOpers[2 + X86AddrNumOperands];
|
||||
MachineOperand* argOpers[2 + X86::AddrNumOperands];
|
||||
int numArgs = mInstr->getNumOperands() - 1;
|
||||
for (int i=0; i < numArgs; ++i)
|
||||
argOpers[i] = &mInstr->getOperand(i+1);
|
||||
|
||||
// x86 address has 4 operands: base, index, scale, and displacement
|
||||
int lastAddrIndx = X86AddrNumOperands - 1; // [0,3]
|
||||
int lastAddrIndx = X86::AddrNumOperands - 1; // [0,3]
|
||||
int valArgIndx = lastAddrIndx + 1;
|
||||
|
||||
unsigned t1 = F->getRegInfo().createVirtualRegister(X86::GR32RegisterClass);
|
||||
@ -8705,7 +8705,7 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
|
||||
AM.Disp = Op.getImm();
|
||||
}
|
||||
addFullAddress(BuildMI(*BB, MI, DL, TII->get(Opc)), AM)
|
||||
.addReg(MI->getOperand(X86AddrNumOperands).getReg());
|
||||
.addReg(MI->getOperand(X86::AddrNumOperands).getReg());
|
||||
|
||||
// Reload the original control word now.
|
||||
addFrameReference(BuildMI(*BB, MI, DL,
|
||||
|
@ -863,7 +863,7 @@ unsigned X86InstrInfo::isStoreToStackSlot(const MachineInstr *MI,
|
||||
int &FrameIndex) const {
|
||||
if (isFrameStoreOpcode(MI->getOpcode()))
|
||||
if (isFrameOperand(MI, 0, FrameIndex))
|
||||
return MI->getOperand(X86AddrNumOperands).getReg();
|
||||
return MI->getOperand(X86::AddrNumOperands).getReg();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2616,7 +2616,7 @@ MachineInstr* X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
|
||||
} else if (Ops.size() != 1)
|
||||
return NULL;
|
||||
|
||||
SmallVector<MachineOperand,X86AddrNumOperands> MOs;
|
||||
SmallVector<MachineOperand,X86::AddrNumOperands> MOs;
|
||||
switch (LoadMI->getOpcode()) {
|
||||
case X86::V_SET0PS:
|
||||
case X86::V_SET0PD:
|
||||
@ -2670,7 +2670,7 @@ MachineInstr* X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
|
||||
default: {
|
||||
// Folding a normal load. Just copy the load's address operands.
|
||||
unsigned NumOps = LoadMI->getDesc().getNumOperands();
|
||||
for (unsigned i = NumOps - X86AddrNumOperands; i != NumOps; ++i)
|
||||
for (unsigned i = NumOps - X86::AddrNumOperands; i != NumOps; ++i)
|
||||
MOs.push_back(LoadMI->getOperand(i));
|
||||
break;
|
||||
}
|
||||
@ -2764,13 +2764,13 @@ bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
||||
// conservatively assume the address is unaligned. That's bad for
|
||||
// performance.
|
||||
return false;
|
||||
SmallVector<MachineOperand, X86AddrNumOperands> AddrOps;
|
||||
SmallVector<MachineOperand, X86::AddrNumOperands> AddrOps;
|
||||
SmallVector<MachineOperand,2> BeforeOps;
|
||||
SmallVector<MachineOperand,2> AfterOps;
|
||||
SmallVector<MachineOperand,4> ImpOps;
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &Op = MI->getOperand(i);
|
||||
if (i >= Index && i < Index + X86AddrNumOperands)
|
||||
if (i >= Index && i < Index + X86::AddrNumOperands)
|
||||
AddrOps.push_back(Op);
|
||||
else if (Op.isReg() && Op.isImplicit())
|
||||
ImpOps.push_back(Op);
|
||||
@ -2789,7 +2789,7 @@ bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
||||
loadRegFromAddr(MF, Reg, AddrOps, RC, MMOs.first, MMOs.second, NewMIs);
|
||||
if (UnfoldStore) {
|
||||
// Address operands cannot be marked isKill.
|
||||
for (unsigned i = 1; i != 1 + X86AddrNumOperands; ++i) {
|
||||
for (unsigned i = 1; i != 1 + X86::AddrNumOperands; ++i) {
|
||||
MachineOperand &MO = NewMIs[0]->getOperand(i);
|
||||
if (MO.isReg())
|
||||
MO.setIsKill(false);
|
||||
@ -2886,7 +2886,7 @@ X86InstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
|
||||
unsigned NumOps = N->getNumOperands();
|
||||
for (unsigned i = 0; i != NumOps-1; ++i) {
|
||||
SDValue Op = N->getOperand(i);
|
||||
if (i >= Index-NumDefs && i < Index-NumDefs + X86AddrNumOperands)
|
||||
if (i >= Index-NumDefs && i < Index-NumDefs + X86::AddrNumOperands)
|
||||
AddrOps.push_back(Op);
|
||||
else if (i < Index-NumDefs)
|
||||
BeforeOps.push_back(Op);
|
||||
@ -3218,7 +3218,7 @@ unsigned X86InstrInfo::determineREX(const MachineInstr &MI) {
|
||||
case X86II::MRM4m: case X86II::MRM5m:
|
||||
case X86II::MRM6m: case X86II::MRM7m:
|
||||
case X86II::MRMDestMem: {
|
||||
unsigned e = (isTwoAddr ? X86AddrNumOperands+1 : X86AddrNumOperands);
|
||||
unsigned e = (isTwoAddr ? X86::AddrNumOperands+1 : X86::AddrNumOperands);
|
||||
i = isTwoAddr ? 1 : 0;
|
||||
if (NumOps > e && isX86_64ExtendedReg(MI.getOperand(e)))
|
||||
REX |= 1 << 2;
|
||||
@ -3570,7 +3570,7 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
|
||||
case X86II::MRMDestMem: {
|
||||
++FinalSize;
|
||||
FinalSize += getMemModRMByteSize(MI, CurOp, IsPIC, Is64BitMode);
|
||||
CurOp += X86AddrNumOperands + 1;
|
||||
CurOp += X86::AddrNumOperands + 1;
|
||||
if (CurOp != NumOps) {
|
||||
++CurOp;
|
||||
FinalSize += sizeConstant(X86II::getSizeOfImm(Desc->TSFlags));
|
||||
@ -3592,9 +3592,9 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
|
||||
int AddrOperands;
|
||||
if (Opcode == X86::LEA64r || Opcode == X86::LEA64_32r ||
|
||||
Opcode == X86::LEA16r || Opcode == X86::LEA32r)
|
||||
AddrOperands = X86AddrNumOperands - 1; // No segment register
|
||||
AddrOperands = X86::AddrNumOperands - 1; // No segment register
|
||||
else
|
||||
AddrOperands = X86AddrNumOperands;
|
||||
AddrOperands = X86::AddrNumOperands;
|
||||
|
||||
++FinalSize;
|
||||
FinalSize += getMemModRMByteSize(MI, CurOp+1, IsPIC, Is64BitMode);
|
||||
@ -3652,7 +3652,7 @@ static unsigned GetInstSizeWithDesc(const MachineInstr &MI,
|
||||
|
||||
++FinalSize;
|
||||
FinalSize += getMemModRMByteSize(MI, CurOp, IsPIC, Is64BitMode);
|
||||
CurOp += X86AddrNumOperands;
|
||||
CurOp += X86::AddrNumOperands;
|
||||
|
||||
if (CurOp != NumOps) {
|
||||
const MachineOperand &MO = MI.getOperand(CurOp++);
|
||||
|
@ -24,6 +24,24 @@ namespace llvm {
|
||||
class X86TargetMachine;
|
||||
|
||||
namespace X86 {
|
||||
// Enums for memory operand decoding. Each memory operand is represented with
|
||||
// a 5 operand sequence in the form:
|
||||
// [BaseReg, ScaleAmt, IndexReg, Disp, Segment]
|
||||
// These enums help decode this.
|
||||
enum {
|
||||
AddrBaseReg = 0,
|
||||
AddrScaleAmt = 1,
|
||||
AddrIndexReg = 2,
|
||||
AddrDisp = 3,
|
||||
|
||||
/// AddrSegmentReg - The operand # of the segment in the memory operand.
|
||||
AddrSegmentReg = 4,
|
||||
|
||||
/// AddrNumOperands - Total number of operands in a memory reference.
|
||||
AddrNumOperands = 5
|
||||
};
|
||||
|
||||
|
||||
// X86 specific condition code. These correspond to X86_*_COND in
|
||||
// X86InstrInfo.td. They must be kept in synch.
|
||||
enum CondCode {
|
||||
@ -542,12 +560,6 @@ namespace X86II {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Move into X86II namespace.
|
||||
enum {
|
||||
X86AddrSegment = 4,
|
||||
X86AddrNumOperands = 5
|
||||
};
|
||||
|
||||
inline static bool isScale(const MachineOperand &MO) {
|
||||
return MO.isImm() &&
|
||||
(MO.getImm() == 1 || MO.getImm() == 2 ||
|
||||
|
@ -464,7 +464,7 @@ void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
|
||||
case X86II::MRM4m: case X86II::MRM5m:
|
||||
case X86II::MRM6m: case X86II::MRM7m:
|
||||
case X86II::MRMDestMem:
|
||||
NumOps = CurOp = X86AddrNumOperands;
|
||||
NumOps = CurOp = X86::AddrNumOperands;
|
||||
case X86II::MRMSrcMem:
|
||||
case X86II::MRMSrcReg:
|
||||
if (MI.getNumOperands() > CurOp && MI.getOperand(CurOp).isReg() &&
|
||||
@ -606,7 +606,7 @@ static unsigned DetermineREXPrefix(const MCInst &MI, uint64_t TSFlags,
|
||||
case X86II::MRM4m: case X86II::MRM5m:
|
||||
case X86II::MRM6m: case X86II::MRM7m:
|
||||
case X86II::MRMDestMem: {
|
||||
unsigned e = (isTwoAddr ? X86AddrNumOperands+1 : X86AddrNumOperands);
|
||||
unsigned e = (isTwoAddr ? X86::AddrNumOperands+1 : X86::AddrNumOperands);
|
||||
i = isTwoAddr ? 1 : 0;
|
||||
if (NumOps > e && MI.getOperand(e).isReg() &&
|
||||
X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(e).getReg()))
|
||||
@ -659,7 +659,7 @@ void X86MCCodeEmitter::EmitOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
|
||||
// FIXME: This is disgusting.
|
||||
MI.getOpcode() != X86::LEA64r && MI.getOpcode() != X86::LEA64_32r &&
|
||||
MI.getOpcode() != X86::LEA16r && MI.getOpcode() != X86::LEA32r) {
|
||||
switch (MI.getOperand(MemOperand+X86AddrSegment).getReg()) {
|
||||
switch (MI.getOperand(MemOperand+X86::AddrSegmentReg).getReg()) {
|
||||
default: assert(0 && "Unknown segment register!");
|
||||
case 0: break;
|
||||
case X86::CS: EmitByte(0x2E, CurByte, OS); break;
|
||||
@ -814,9 +814,9 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
case X86II::MRMDestMem:
|
||||
EmitByte(BaseOpcode, CurByte, OS);
|
||||
EmitMemModRMByte(MI, CurOp,
|
||||
GetX86RegNum(MI.getOperand(CurOp + X86AddrNumOperands)),
|
||||
GetX86RegNum(MI.getOperand(CurOp + X86::AddrNumOperands)),
|
||||
TSFlags, CurByte, OS, Fixups);
|
||||
CurOp += X86AddrNumOperands + 1;
|
||||
CurOp += X86::AddrNumOperands + 1;
|
||||
break;
|
||||
|
||||
case X86II::MRMSrcReg:
|
||||
@ -832,7 +832,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
break;
|
||||
|
||||
case X86II::MRMSrcMem: {
|
||||
int AddrOperands = X86AddrNumOperands;
|
||||
int AddrOperands = X86::AddrNumOperands;
|
||||
unsigned FirstMemOp = CurOp+1;
|
||||
if (HasVEX_4V) {
|
||||
++AddrOperands;
|
||||
@ -870,7 +870,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
EmitByte(BaseOpcode, CurByte, OS);
|
||||
EmitMemModRMByte(MI, CurOp, (TSFlags & X86II::FormMask)-X86II::MRM0m,
|
||||
TSFlags, CurByte, OS, Fixups);
|
||||
CurOp += X86AddrNumOperands;
|
||||
CurOp += X86::AddrNumOperands;
|
||||
break;
|
||||
case X86II::MRM_C1:
|
||||
EmitByte(BaseOpcode, CurByte, OS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user