llvm.org GIT mirror llvm / 15b64d0
In the X86 back end, getMemoryOperandNo() returns the offset into the operand array of the start of the memory reference descriptor. Additional code in EncodeInstruction provides an additional adjustment. This patch places that additional code in a separate function, called getOperandBias, so that any caller of getMemoryOperandNo can also call getOperandBias. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179211 91177308-0d34-0410-b5e6-96231b3b80d8 Preston Gurd 7 years ago
2 changed file(s) with 22 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
1919 #include "X86MCTargetDesc.h"
2020 #include "llvm/Support/DataTypes.h"
2121 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/MC/MCInstrInfo.h"
2223
2324 namespace llvm {
2425
4041 AddrNumOperands = 5
4142 };
4243 } // end namespace X86;
43
4444
4545 /// X86II - This namespace holds all of the target specific flags that
4646 /// instruction info tracks.
518518 case X86II::Imm64:
519519 return false;
520520 }
521 }
522
523 /// getOperandBias - compute any additional adjustment needed to
524 /// the offset to the start of the memory operand
525 /// in this instruction.
526 /// If this is a two-address instruction,skip one of the register operands.
527 /// FIXME: This should be handled during MCInst lowering.
528 inline int getOperandBias(const MCInstrDesc& Desc)
529 {
530 unsigned NumOps = Desc.getNumOperands();
531 unsigned CurOp = 0;
532 if (NumOps > 1 && Desc.getOperandConstraint(1, MCOI::TIED_TO) == 0)
533 ++CurOp;
534 else if (NumOps > 3 && Desc.getOperandConstraint(2, MCOI::TIED_TO) == 0) {
535 assert(Desc.getOperandConstraint(NumOps - 1, MCOI::TIED_TO) == 1);
536 // Special case for GATHER with 2 TIED_TO operands
537 // Skip the first 2 operands: dst, mask_wb
538 CurOp += 2;
539 }
540 return CurOp;
521541 }
522542
523543 /// getMemoryOperandNo - The function returns the MCInst operand # for the
978978 if ((TSFlags & X86II::FormMask) == X86II::Pseudo)
979979 return;
980980
981 // If this is a two-address instruction, skip one of the register operands.
982 // FIXME: This should be handled during MCInst lowering.
983981 unsigned NumOps = Desc.getNumOperands();
984 unsigned CurOp = 0;
985 if (NumOps > 1 && Desc.getOperandConstraint(1, MCOI::TIED_TO) == 0)
986 ++CurOp;
987 else if (NumOps > 3 && Desc.getOperandConstraint(2, MCOI::TIED_TO) == 0) {
988 assert(Desc.getOperandConstraint(NumOps - 1, MCOI::TIED_TO) == 1);
989 // Special case for GATHER with 2 TIED_TO operands
990 // Skip the first 2 operands: dst, mask_wb
991 CurOp += 2;
992 }
982 unsigned CurOp = X86II::getOperandBias(Desc);
993983
994984 // Keep track of the current byte being emitted.
995985 unsigned CurByte = 0;