mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
X86: Better diagnostics for 32-bit vs. 64-bit mode mismatches.
When an instruction as written requires 32-bit mode and we're assembling in 64-bit mode, or vice-versa, issue a more specific diagnostic about what's wrong. rdar://12700702 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167937 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7af4b9b33a
commit
3ca6382120
@ -1748,6 +1748,7 @@ processInstruction(MCInst &Inst,
|
||||
}
|
||||
}
|
||||
|
||||
static const char *getSubtargetFeatureName(unsigned Val);
|
||||
bool X86AsmParser::
|
||||
MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||
@ -1809,10 +1810,21 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
Out.EmitInstruction(Inst);
|
||||
Opcode = Inst.getOpcode();
|
||||
return false;
|
||||
case Match_MissingFeature:
|
||||
Error(IDLoc, "instruction requires a CPU feature not currently enabled",
|
||||
EmptyRanges, MatchingInlineAsm);
|
||||
return true;
|
||||
case Match_MissingFeature: {
|
||||
assert(ErrorInfo && "Unknown missing feature!");
|
||||
// Special case the error message for the very common case where only
|
||||
// a single subtarget feature is missing.
|
||||
std::string Msg = "instruction requires:";
|
||||
unsigned Mask = 1;
|
||||
for (unsigned i = 0; i < (sizeof(ErrorInfo)*8-1); ++i) {
|
||||
if (ErrorInfo & Mask) {
|
||||
Msg += " ";
|
||||
Msg += getSubtargetFeatureName(ErrorInfo & Mask);
|
||||
}
|
||||
Mask <<= 1;
|
||||
}
|
||||
return Error(IDLoc, Msg, EmptyRanges, MatchingInlineAsm);
|
||||
}
|
||||
case Match_InvalidOperand:
|
||||
WasOriginallyInvalidOperand = true;
|
||||
break;
|
||||
@ -1843,19 +1855,32 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
// Check for the various suffix matches.
|
||||
Tmp[Base.size()] = Suffixes[0];
|
||||
unsigned ErrorInfoIgnore;
|
||||
unsigned ErrorInfoMissingFeature;
|
||||
unsigned Match1, Match2, Match3, Match4;
|
||||
|
||||
Match1 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore,
|
||||
isParsingIntelSyntax());
|
||||
// If this returned as a missing feature failure, remember that.
|
||||
if (Match1 == Match_MissingFeature)
|
||||
ErrorInfoMissingFeature = ErrorInfoIgnore;
|
||||
Tmp[Base.size()] = Suffixes[1];
|
||||
Match2 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore,
|
||||
isParsingIntelSyntax());
|
||||
// If this returned as a missing feature failure, remember that.
|
||||
if (Match2 == Match_MissingFeature)
|
||||
ErrorInfoMissingFeature = ErrorInfoIgnore;
|
||||
Tmp[Base.size()] = Suffixes[2];
|
||||
Match3 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore,
|
||||
isParsingIntelSyntax());
|
||||
// If this returned as a missing feature failure, remember that.
|
||||
if (Match3 == Match_MissingFeature)
|
||||
ErrorInfoMissingFeature = ErrorInfoIgnore;
|
||||
Tmp[Base.size()] = Suffixes[3];
|
||||
Match4 = MatchInstructionImpl(Operands, Inst, ErrorInfoIgnore,
|
||||
isParsingIntelSyntax());
|
||||
// If this returned as a missing feature failure, remember that.
|
||||
if (Match4 == Match_MissingFeature)
|
||||
ErrorInfoMissingFeature = ErrorInfoIgnore;
|
||||
|
||||
// Restore the old token.
|
||||
Op->setTokenValue(Base);
|
||||
@ -1936,9 +1961,16 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
// missing feature.
|
||||
if ((Match1 == Match_MissingFeature) + (Match2 == Match_MissingFeature) +
|
||||
(Match3 == Match_MissingFeature) + (Match4 == Match_MissingFeature) == 1){
|
||||
Error(IDLoc, "instruction requires a CPU feature not currently enabled",
|
||||
EmptyRanges, MatchingInlineAsm);
|
||||
return true;
|
||||
std::string Msg = "instruction requires:";
|
||||
unsigned Mask = 1;
|
||||
for (unsigned i = 0; i < (sizeof(ErrorInfoMissingFeature)*8-1); ++i) {
|
||||
if (ErrorInfoMissingFeature & Mask) {
|
||||
Msg += " ";
|
||||
Msg += getSubtargetFeatureName(ErrorInfoMissingFeature & Mask);
|
||||
}
|
||||
Mask <<= 1;
|
||||
}
|
||||
return Error(IDLoc, Msg, EmptyRanges, MatchingInlineAsm);
|
||||
}
|
||||
|
||||
// If one instruction matched with an invalid operand, report this as an
|
||||
@ -2039,4 +2071,5 @@ extern "C" void LLVMInitializeX86AsmParser() {
|
||||
|
||||
#define GET_REGISTER_MATCHER
|
||||
#define GET_MATCHER_IMPLEMENTATION
|
||||
#define GET_SUBTARGET_FEATURE_NAME
|
||||
#include "X86GenAsmMatcher.inc"
|
||||
|
@ -594,9 +594,9 @@ def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
|
||||
def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
|
||||
def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">;
|
||||
def In32BitMode : Predicate<"!Subtarget->is64Bit()">,
|
||||
AssemblerPredicate<"!Mode64Bit">;
|
||||
AssemblerPredicate<"!Mode64Bit", "32-bit mode">;
|
||||
def In64BitMode : Predicate<"Subtarget->is64Bit()">,
|
||||
AssemblerPredicate<"Mode64Bit">;
|
||||
AssemblerPredicate<"Mode64Bit", "64-bit mode">;
|
||||
def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
|
||||
def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
|
||||
def NotNaCl : Predicate<"!Subtarget->isTargetNaCl()">;
|
||||
|
@ -18,7 +18,7 @@ addl $0, 0(%rax)
|
||||
|
||||
movl 0(%rax), 0(%edx) // error: invalid operand for instruction
|
||||
|
||||
// 32: error: instruction requires a CPU feature not currently enabled
|
||||
// 32: error: instruction requires: 64-bit mode
|
||||
sysexitq
|
||||
|
||||
// rdar://10710167
|
||||
|
Loading…
Reference in New Issue
Block a user