forked from OSchip/llvm-project
[WebAssembly][AsmParser] Name missing features in error message
Rather than just saying that some feature is missing, report the exact features to make the error message more useful and actionable. Differential Revision: https://reviews.llvm.org/D85795
This commit is contained in:
parent
b9af72bffe
commit
2985c02f79
|
@ -35,6 +35,8 @@ using namespace llvm;
|
|||
|
||||
#define DEBUG_TYPE "wasm-asm-parser"
|
||||
|
||||
static const char *getSubtargetFeatureName(uint64_t Val);
|
||||
|
||||
namespace {
|
||||
|
||||
/// WebAssemblyOperand - Instances of this class represent the operands in a
|
||||
|
@ -836,8 +838,9 @@ public:
|
|||
bool MatchingInlineAsm) override {
|
||||
MCInst Inst;
|
||||
Inst.setLoc(IDLoc);
|
||||
unsigned MatchResult =
|
||||
MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm);
|
||||
FeatureBitset MissingFeatures;
|
||||
unsigned MatchResult = MatchInstructionImpl(
|
||||
Operands, Inst, ErrorInfo, MissingFeatures, MatchingInlineAsm);
|
||||
switch (MatchResult) {
|
||||
case Match_Success: {
|
||||
ensureLocals(Out);
|
||||
|
@ -866,9 +869,17 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
case Match_MissingFeature:
|
||||
return Parser.Error(
|
||||
IDLoc, "instruction requires a Wasm feature not currently enabled");
|
||||
case Match_MissingFeature: {
|
||||
auto NumMissing = MissingFeatures.count();
|
||||
assert(NumMissing > 0 && "Expected missing features");
|
||||
SmallString<128> Message;
|
||||
raw_svector_ostream OS(Message);
|
||||
OS << "instruction requires:";
|
||||
for (unsigned i = 0, e = MissingFeatures.size(); i != e; ++i)
|
||||
if (MissingFeatures.test(i))
|
||||
OS << ' ' << getSubtargetFeatureName(i);
|
||||
return Parser.Error(IDLoc, Message);
|
||||
}
|
||||
case Match_MnemonicFail:
|
||||
return Parser.Error(IDLoc, "invalid instruction");
|
||||
case Match_NearMisses:
|
||||
|
@ -932,5 +943,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser() {
|
|||
}
|
||||
|
||||
#define GET_REGISTER_MATCHER
|
||||
#define GET_SUBTARGET_FEATURE_NAME
|
||||
#define GET_MATCHER_IMPLEMENTATION
|
||||
#include "WebAssemblyGenAsmMatcher.inc"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# RUN: not llvm-mc -triple=wasm32-unknown-unknown < %s 2>&1 | FileCheck %s
|
||||
|
||||
# Check that missing features are named in the error message
|
||||
|
||||
# CHECK: error: instruction requires: simd128
|
||||
needs_simd:
|
||||
.functype needs_simd () -> (v128)
|
||||
i32.const 42
|
||||
i32x4.splat
|
||||
drop
|
||||
end_function
|
Loading…
Reference in New Issue