Skip to content

Commit

Permalink
[SystemZ] Correctly diagnose missing features in AsmParser
Browse files Browse the repository at this point in the history
Currently, when using an instruction that is not supported on the
currently selected architecture, the LLVM assembler is likely to
diagnose an "invalid operand" instead of a "missing feature".

This is because many operands require a custom parser in order to
be processed correctly, and if an instruction is not available
according to the current feature set, the generated parser code
will also not detect the associated custom operand parsers.

Fixed by temporarily enabling all features while parsing operands.
The missing features will then be correctly detected when actually
parsing the instruction itself.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285575 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
uweigand committed Oct 31, 2016
1 parent b12a0a5 commit 19e305e
Show file tree
Hide file tree
Showing 4 changed files with 489 additions and 483 deletions.
8 changes: 7 additions & 1 deletion lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,14 @@ bool SystemZAsmParser::ParseInstruction(ParseInstructionInfo &Info,
bool SystemZAsmParser::parseOperand(OperandVector &Operands,
StringRef Mnemonic) {
// Check if the current operand has a custom associated parser, if so, try to
// custom parse the operand, or fallback to the general approach.
// custom parse the operand, or fallback to the general approach. Force all
// features to be available during the operand check, or else we will fail to
// find the custom parser, and then we will later get an InvalidOperand error
// instead of a MissingFeature errror.
uint64_t AvailableFeatures = getAvailableFeatures();
setAvailableFeatures(~(uint64_t)0);
OperandMatchResultTy ResTy = MatchOperandParserImpl(Operands, Mnemonic);
setAvailableFeatures(AvailableFeatures);
if (ResTy == MatchOperand_Success)
return false;

Expand Down
16 changes: 8 additions & 8 deletions test/MC/SystemZ/insn-bad-z196.s
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
cxlgbr %f0, 16, %r0, 0
cxlgbr %f2, 0, %r0, 0

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: etnd %r7

etnd %r7
Expand Down Expand Up @@ -551,17 +551,17 @@
locr %r0,%r0,-1
locr %r0,%r0,16

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: ntstg %r0, 524287(%r1,%r15)

ntstg %r0, 524287(%r1,%r15)

#CHECK: error: {{(instruction requires: processor-assist)?}}
#CHECK: error: instruction requires: processor-assist
#CHECK: ppa %r4, %r6, 7

ppa %r4, %r6, 7

#CHECK: error: {{(instruction requires: miscellaneous-extensions)?}}
#CHECK: error: instruction requires: miscellaneous-extensions
#CHECK: risbgn %r1, %r2, 0, 0, 0

risbgn %r1, %r2, 0, 0, 0
Expand Down Expand Up @@ -720,22 +720,22 @@
stocg %r0,524288,1
stocg %r0,0(%r1,%r2),1

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: tabort 4095(%r1)

tabort 4095(%r1)

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: tbegin 4095(%r1), 42

tbegin 4095(%r1), 42

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: tbeginc 4095(%r1), 42

tbeginc 4095(%r1), 42

#CHECK: error: {{(instruction requires: transactional-execution)?}}
#CHECK: error: instruction requires: transactional-execution
#CHECK: tend

tend
Expand Down
Loading

0 comments on commit 19e305e

Please sign in to comment.