forked from OSchip/llvm-project
				
			[ms-inline asm] Do not report a Parser error when matching inline assembly.
llvm-svn: 162306
This commit is contained in:
		
							parent
							
								
									f737cb3b92
								
							
						
					
					
						commit
						3d4bc62a5c
					
				| 
						 | 
					@ -89,7 +89,8 @@ public:
 | 
				
			||||||
  MatchInstruction(SMLoc IDLoc,
 | 
					  MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
                   SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
					                   SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
				
			||||||
                   SmallVectorImpl<MCInst> &MCInsts,
 | 
					                   SmallVectorImpl<MCInst> &MCInsts,
 | 
				
			||||||
                   unsigned &OrigErrorInfo) {
 | 
					                   unsigned &OrigErrorInfo,
 | 
				
			||||||
 | 
					                   bool matchingInlineAsm = false) {
 | 
				
			||||||
    OrigErrorInfo = ~0x0;
 | 
					    OrigErrorInfo = ~0x0;
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,9 @@ private:
 | 
				
			||||||
  MCAsmLexer &getLexer() const { return Parser.getLexer(); }
 | 
					  MCAsmLexer &getLexer() const { return Parser.getLexer(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  bool Error(SMLoc L, const Twine &Msg,
 | 
					  bool Error(SMLoc L, const Twine &Msg,
 | 
				
			||||||
             ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) {
 | 
					             ArrayRef<SMRange> Ranges = ArrayRef<SMRange>(),
 | 
				
			||||||
 | 
					             bool matchingInlineAsm = false) {
 | 
				
			||||||
 | 
					    if (matchingInlineAsm) return true;
 | 
				
			||||||
    return Parser.Error(L, Msg, Ranges);
 | 
					    return Parser.Error(L, Msg, Ranges);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +70,8 @@ private:
 | 
				
			||||||
  bool MatchInstruction(SMLoc IDLoc,
 | 
					  bool MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
                        SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
					                        SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
				
			||||||
                        SmallVectorImpl<MCInst> &MCInsts,
 | 
					                        SmallVectorImpl<MCInst> &MCInsts,
 | 
				
			||||||
                        unsigned &OrigErrorInfo);
 | 
					                        unsigned &OrigErrorInfo,
 | 
				
			||||||
 | 
					                        bool matchingInlineAsm = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// isSrcOp - Returns true if operand is either (%rsi) or %ds:%(rsi)
 | 
					  /// isSrcOp - Returns true if operand is either (%rsi) or %ds:%(rsi)
 | 
				
			||||||
  /// in 64bit mode or (%esi) or %es:(%esi) in 32bit mode.
 | 
					  /// in 64bit mode or (%esi) or %es:(%esi) in 32bit mode.
 | 
				
			||||||
| 
						 | 
					@ -1525,11 +1528,12 @@ MatchAndEmitInstruction(SMLoc IDLoc,
 | 
				
			||||||
bool X86AsmParser::
 | 
					bool X86AsmParser::
 | 
				
			||||||
MatchInstruction(SMLoc IDLoc,
 | 
					MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
                 SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
					                 SmallVectorImpl<MCParsedAsmOperand*> &Operands,
 | 
				
			||||||
                 SmallVectorImpl<MCInst> &MCInsts,
 | 
					                 SmallVectorImpl<MCInst> &MCInsts, unsigned &OrigErrorInfo,
 | 
				
			||||||
                 unsigned &OrigErrorInfo) {
 | 
					                 bool matchingInlineAsm) {
 | 
				
			||||||
  assert(!Operands.empty() && "Unexpect empty operand list!");
 | 
					  assert(!Operands.empty() && "Unexpect empty operand list!");
 | 
				
			||||||
  X86Operand *Op = static_cast<X86Operand*>(Operands[0]);
 | 
					  X86Operand *Op = static_cast<X86Operand*>(Operands[0]);
 | 
				
			||||||
  assert(Op->isToken() && "Leading operand should always be a mnemonic!");
 | 
					  assert(Op->isToken() && "Leading operand should always be a mnemonic!");
 | 
				
			||||||
 | 
					  ArrayRef<SMRange> EmptyRanges = ArrayRef<SMRange>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // First, handle aliases that expand to multiple instructions.
 | 
					  // First, handle aliases that expand to multiple instructions.
 | 
				
			||||||
  // FIXME: This should be replaced with a real .td file alias mechanism.
 | 
					  // FIXME: This should be replaced with a real .td file alias mechanism.
 | 
				
			||||||
| 
						 | 
					@ -1578,10 +1582,12 @@ MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
    MCInsts.push_back(Inst);
 | 
					    MCInsts.push_back(Inst);
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  case Match_MissingFeature:
 | 
					  case Match_MissingFeature:
 | 
				
			||||||
    Error(IDLoc, "instruction requires a CPU feature not currently enabled");
 | 
					    Error(IDLoc, "instruction requires a CPU feature not currently enabled",
 | 
				
			||||||
 | 
					          EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  case Match_ConversionFail:
 | 
					  case Match_ConversionFail:
 | 
				
			||||||
    return Error(IDLoc, "unable to convert operands to instruction");
 | 
					    return Error(IDLoc, "unable to convert operands to instruction",
 | 
				
			||||||
 | 
					                 EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
  case Match_InvalidOperand:
 | 
					  case Match_InvalidOperand:
 | 
				
			||||||
    WasOriginallyInvalidOperand = true;
 | 
					    WasOriginallyInvalidOperand = true;
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
| 
						 | 
					@ -1660,7 +1666,7 @@ MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
      OS << "'" << Base << MatchChars[i] << "'";
 | 
					      OS << "'" << Base << MatchChars[i] << "'";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    OS << ")";
 | 
					    OS << ")";
 | 
				
			||||||
    Error(IDLoc, OS.str());
 | 
					    Error(IDLoc, OS.str(), EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1672,30 +1678,33 @@ MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
      (Match3 == Match_MnemonicFail) && (Match4 == Match_MnemonicFail)) {
 | 
					      (Match3 == Match_MnemonicFail) && (Match4 == Match_MnemonicFail)) {
 | 
				
			||||||
    if (!WasOriginallyInvalidOperand) {
 | 
					    if (!WasOriginallyInvalidOperand) {
 | 
				
			||||||
      return Error(IDLoc, "invalid instruction mnemonic '" + Base + "'",
 | 
					      return Error(IDLoc, "invalid instruction mnemonic '" + Base + "'",
 | 
				
			||||||
                   Op->getLocRange());
 | 
					                   Op->getLocRange(), matchingInlineAsm);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Recover location info for the operand if we know which was the problem.
 | 
					    // Recover location info for the operand if we know which was the problem.
 | 
				
			||||||
    if (OrigErrorInfo != ~0U) {
 | 
					    if (OrigErrorInfo != ~0U) {
 | 
				
			||||||
      if (OrigErrorInfo >= Operands.size())
 | 
					      if (OrigErrorInfo >= Operands.size())
 | 
				
			||||||
        return Error(IDLoc, "too few operands for instruction");
 | 
					        return Error(IDLoc, "too few operands for instruction",
 | 
				
			||||||
 | 
					                     EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      X86Operand *Operand = (X86Operand*)Operands[OrigErrorInfo];
 | 
					      X86Operand *Operand = (X86Operand*)Operands[OrigErrorInfo];
 | 
				
			||||||
      if (Operand->getStartLoc().isValid()) {
 | 
					      if (Operand->getStartLoc().isValid()) {
 | 
				
			||||||
        SMRange OperandRange = Operand->getLocRange();
 | 
					        SMRange OperandRange = Operand->getLocRange();
 | 
				
			||||||
        return Error(Operand->getStartLoc(), "invalid operand for instruction",
 | 
					        return Error(Operand->getStartLoc(), "invalid operand for instruction",
 | 
				
			||||||
                     OperandRange);
 | 
					                     OperandRange, matchingInlineAsm);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return Error(IDLoc, "invalid operand for instruction");
 | 
					    return Error(IDLoc, "invalid operand for instruction", EmptyRanges,
 | 
				
			||||||
 | 
					                 matchingInlineAsm);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If one instruction matched with a missing feature, report this as a
 | 
					  // If one instruction matched with a missing feature, report this as a
 | 
				
			||||||
  // missing feature.
 | 
					  // missing feature.
 | 
				
			||||||
  if ((Match1 == Match_MissingFeature) + (Match2 == Match_MissingFeature) +
 | 
					  if ((Match1 == Match_MissingFeature) + (Match2 == Match_MissingFeature) +
 | 
				
			||||||
      (Match3 == Match_MissingFeature) + (Match4 == Match_MissingFeature) == 1){
 | 
					      (Match3 == Match_MissingFeature) + (Match4 == Match_MissingFeature) == 1){
 | 
				
			||||||
    Error(IDLoc, "instruction requires a CPU feature not currently enabled");
 | 
					    Error(IDLoc, "instruction requires a CPU feature not currently enabled",
 | 
				
			||||||
 | 
					          EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1703,12 +1712,14 @@ MatchInstruction(SMLoc IDLoc,
 | 
				
			||||||
  // operand failure.
 | 
					  // operand failure.
 | 
				
			||||||
  if ((Match1 == Match_InvalidOperand) + (Match2 == Match_InvalidOperand) +
 | 
					  if ((Match1 == Match_InvalidOperand) + (Match2 == Match_InvalidOperand) +
 | 
				
			||||||
      (Match3 == Match_InvalidOperand) + (Match4 == Match_InvalidOperand) == 1){
 | 
					      (Match3 == Match_InvalidOperand) + (Match4 == Match_InvalidOperand) == 1){
 | 
				
			||||||
    Error(IDLoc, "invalid operand for instruction");
 | 
					    Error(IDLoc, "invalid operand for instruction", EmptyRanges,
 | 
				
			||||||
 | 
					          matchingInlineAsm);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If all of these were an outright failure, report it in a useless way.
 | 
					  // If all of these were an outright failure, report it in a useless way.
 | 
				
			||||||
  Error(IDLoc, "unknown use of instruction mnemonic without a size suffix");
 | 
					  Error(IDLoc, "unknown use of instruction mnemonic without a size suffix",
 | 
				
			||||||
 | 
					        EmptyRanges, matchingInlineAsm);
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue