[SystemZ] Correctly diagnose missing features in AsmParser

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
This commit is contained in:
Ulrich Weigand 2016-10-31 14:25:05 +00:00
parent b12a0a51d5
commit 19e305e8e7
4 changed files with 489 additions and 483 deletions

View File

@ -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;

View File

@ -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
@ -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
@ -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

File diff suppressed because it is too large Load Diff

View File

@ -69,12 +69,12 @@
aghi %r0, 32768
aghi %r0, foo
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: aghik %r1, %r2, 3
aghik %r1, %r2, 3
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: agrk %r2,%r3,%r4
agrk %r2,%r3,%r4
@ -115,7 +115,7 @@
ahi %r0, 32768
ahi %r0, foo
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: ahik %r1, %r2, 3
ahik %r1, %r2, 3
@ -128,7 +128,7 @@
ahy %r0, -524289
ahy %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: aih %r0, 0
aih %r0, 0
@ -165,12 +165,12 @@
alfi %r0, -1
alfi %r0, (1 << 32)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: alghsik %r1, %r2, 3
alghsik %r1, %r2, 3
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: alhsik %r1, %r2, 3
alhsik %r1, %r2, 3
@ -199,12 +199,12 @@
algfi %r0, -1
algfi %r0, (1 << 32)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: algrk %r2,%r3,%r4
algrk %r2,%r3,%r4
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: alrk %r2,%r3,%r4
alrk %r2,%r3,%r4
@ -217,7 +217,7 @@
aly %r0, -524289
aly %r0, 524288
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: ark %r2,%r3,%r4
ark %r2,%r3,%r4
@ -414,12 +414,12 @@
cdb %f0, -1
cdb %f0, 4096
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: cdlfbr %f0, 0, %r0, 0
cdlfbr %f0, 0, %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: cdlgbr %f0, 0, %r0, 0
cdlgbr %f0, 0, %r0, 0
@ -432,12 +432,12 @@
ceb %f0, -1
ceb %f0, 4096
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: celfbr %f0, 0, %r0, 0
celfbr %f0, 0, %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: celgbr %f0, 0, %r0, 0
celgbr %f0, 0, %r0, 0
@ -690,7 +690,7 @@
ch %r0, -1
ch %r0, 4096
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: chf %r0, 0
chf %r0, 0
@ -762,7 +762,7 @@
chy %r0, -524289
chy %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: cih %r0, 0
cih %r0, 0
@ -863,17 +863,17 @@
clc 0(1,%r2), 0(%r1,%r2)
clc 0(-), 0
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: clhf %r0, 0
clhf %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clfdbr %r0, 0, %f0, 0
clfdbr %r0, 0, %f0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clfebr %r0, 0, %f0, 0
clfebr %r0, 0, %f0, 0
@ -917,7 +917,7 @@
clfito %r0, 0
clfitno %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clfxbr %r0, 0, %f0, 0
clfxbr %r0, 0, %f0, 0
@ -944,12 +944,12 @@
clgito %r0, 0
clgitno %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clgdbr %r0, 0, %f0, 0
clgdbr %r0, 0, %f0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clgebr %r0, 0, %f0, 0
clgebr %r0, 0, %f0, 0
@ -1081,7 +1081,7 @@
clgrto %r0, %r0
clgrtno %r0, %r0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: clgxbr %r0, 0, %f0, 0
clgxbr %r0, 0, %f0, 0
@ -1134,7 +1134,7 @@
cli 0, -1
cli 0, 256
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: clih %r0, 0
clih %r0, 0
@ -1333,12 +1333,12 @@
cxgbr %f2, %r0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: cxlfbr %f0, 0, %r0, 0
cxlfbr %f0, 0, %r0, 0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: cxlgbr %f0, 0, %r0, 0
cxlgbr %f0, 0, %r0, 0
@ -1472,7 +1472,7 @@
fidbr %f0, -1, %f0
fidbr %f0, 16, %f0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: fidbra %f0, 0, %f0, 0
fidbra %f0, 0, %f0, 0
@ -1485,7 +1485,7 @@
fiebr %f0, -1, %f0
fiebr %f0, 16, %f0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: fiebra %f0, 0, %f0, 0
fiebra %f0, 0, %f0, 0
@ -1504,7 +1504,7 @@
fixbr %f0, 0, %f2
fixbr %f2, 0, %f0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: fixbra %f0, 0, %f0, 0
fixbra %f0, 0, %f0, 0
@ -1636,43 +1636,43 @@
la %r0, -1
la %r0, 4096
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laa %r1, %r2, 100(%r3)
laa %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laag %r1, %r2, 100(%r3)
laag %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laal %r1, %r2, 100(%r3)
laal %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laalg %r1, %r2, 100(%r3)
laalg %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: lan %r1, %r2, 100(%r3)
lan %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: lang %r1, %r2, 100(%r3)
lang %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: lao %r1, %r2, 100(%r3)
lao %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laog %r1, %r2, 100(%r3)
laog %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: lax %r1, %r2, 100(%r3)
lax %r1, %r2, 100(%r3)
#CHECK: error: {{(instruction requires: interlocked-access1)?}}
#CHECK: error: instruction requires: interlocked-access1
#CHECK: laxg %r1, %r2, 100(%r3)
laxg %r1, %r2, 100(%r3)
@ -1706,7 +1706,7 @@
lb %r0, -524289
lb %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: lbh %r0, 0
lbh %r0, 0
@ -1743,7 +1743,7 @@
ldxbr %f0, %f2
ldxbr %f2, %f0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: ldxbra %f0, 0, %f0, 0
ldxbra %f0, 0, %f0, 0
@ -1764,7 +1764,7 @@
le %f0, -1
le %f0, 4096
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: ledbra %f0, 0, %f0, 0
ledbra %f0, 0, %f0, 0
@ -1777,7 +1777,7 @@
lexbr %f0, %f2
lexbr %f2, %f0
#CHECK: error: {{(instruction requires: fp-extension)?}}
#CHECK: error: instruction requires: fp-extension
#CHECK: lexbra %f0, 0, %f0, 0
lexbra %f0, 0, %f0, 0
@ -1790,7 +1790,7 @@
ley %f0, -524289
ley %f0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: lfh %r0, 0
lfh %r0, 0
@ -1896,7 +1896,7 @@
lh %r0, -1
lh %r0, 4096
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: lhh %r0, 0
lhh %r0, 0
@ -1942,7 +1942,7 @@
llc %r0, -524289
llc %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: llch %r0, 0
llch %r0, 0
@ -2007,7 +2007,7 @@
llh %r0, -524289
llh %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: llhh %r0, 0
llhh %r0, 0
@ -2614,7 +2614,7 @@
ng %r0, -524289
ng %r0, 524288
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: ngrk %r2,%r3,%r4
ngrk %r2,%r3,%r4
@ -2701,7 +2701,7 @@
niy 0, -1
niy 0, 256
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: nrk %r2,%r3,%r4
nrk %r2,%r3,%r4
@ -2774,7 +2774,7 @@
og %r0, -524289
og %r0, 524288
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: ogrk %r2,%r3,%r4
ogrk %r2,%r3,%r4
@ -2861,7 +2861,7 @@
oiy 0, -1
oiy 0, 256
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: ork %r2,%r3,%r4
ork %r2,%r3,%r4
@ -2908,7 +2908,7 @@
pfdrl 1, 1
pfdrl 1, 0x100000000
#CHECK: error: {{(instruction requires: population-count)?}}
#CHECK: error: instruction requires: population-count
#CHECK: popcnt %r0, %r0
popcnt %r0, %r0
@ -2937,12 +2937,12 @@
risbg %r0,%r0,-1,0,0
risbg %r0,%r0,256,0,0
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: risbhg %r1, %r2, 0, 0, 0
risbhg %r1, %r2, 0, 0, 0
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: risblg %r1, %r2, 0, 0, 0
risblg %r1, %r2, 0, 0, 0
@ -3075,7 +3075,7 @@
sgf %r0, -524289
sgf %r0, 524288
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: sgrk %r2,%r3,%r4
sgrk %r2,%r3,%r4
@ -3152,7 +3152,7 @@
slgfi %r0, -1
slgfi %r0, (1 << 32)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: slgrk %r2,%r3,%r4
slgrk %r2,%r3,%r4
@ -3171,7 +3171,7 @@
sla %r0,0(%r0)
sla %r0,0(%r1,%r2)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: slak %r2,%r3,4(%r5)
slak %r2,%r3,4(%r5)
@ -3204,12 +3204,12 @@
sllg %r0,%r0,0(%r0)
sllg %r0,%r0,0(%r1,%r2)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: sllk %r2,%r3,4(%r5)
sllk %r2,%r3,4(%r5)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: slrk %r2,%r3,%r4
slrk %r2,%r3,%r4
@ -3274,12 +3274,12 @@
srag %r0,%r0,0(%r0)
srag %r0,%r0,0(%r1,%r2)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: srak %r2,%r3,4(%r5)
srak %r2,%r3,4(%r5)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: srk %r2,%r3,%r4
srk %r2,%r3,%r4
@ -3312,7 +3312,7 @@
srlg %r0,%r0,0(%r0)
srlg %r0,%r0,0(%r1,%r2)
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: srlk %r2,%r3,4(%r5)
srlk %r2,%r3,4(%r5)
@ -3333,7 +3333,7 @@
stc %r0, -1
stc %r0, 4096
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: stch %r0, 0
stch %r0, 0
@ -3408,7 +3408,7 @@
sth %r0, -1
sth %r0, 4096
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: sthh %r0, 0
sthh %r0, 0
@ -3435,7 +3435,7 @@
sthy %r0, -524289
sthy %r0, 524288
#CHECK: error: {{(instruction requires: high-word)?}}
#CHECK: error: instruction requires: high-word
#CHECK: stfh %r0, 0
stfh %r0, 0
@ -3718,7 +3718,7 @@
xg %r0, -524289
xg %r0, 524288
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: xgrk %r2,%r3,%r4
xgrk %r2,%r3,%r4
@ -3773,7 +3773,7 @@
xiy 0, -1
xiy 0, 256
#CHECK: error: {{(instruction requires: distinct-ops)?}}
#CHECK: error: instruction requires: distinct-ops
#CHECK: xrk %r2,%r3,%r4
xrk %r2,%r3,%r4