[LLVMdev] Help with subtarget features and context-dependent asm parsers
rsandifo at linux.vnet.ibm.com
Wed Jul 17 09:52:16 PDT 2013
I'm trying to add some instructions that are only available on certain
processors. These instructions use context-dependent parsers. Everything
works fine for the valid cases, but if you try to use an instruction on
processors that don't support it, the asm parser says:
/tmp/foo.s:1:2: error: invalid operands for instruction
/tmp/foo.s:1:2: error: instruction requires: distinct-ops
This is because MatchOperandParserImpl() skips custom parsers if the
subtarget feature isn't enabled, so the instruction is parsed using
the default operand parser instead. Then MatchInstructionImpl() only
returns Match_MissingFeature if an otherwise good match is found,
which in my case requires the custom parser to be used.
ARM seems to rely on the current MatchOperandParserImpl() behaviour,
so I'm not going to suggest changing it unconditionally. But on SystemZ
there aren't any cases where the choice of parse routine depends on the
enabled features. It'd be better just to parse in the same way
regardless and check for errors at the end.
The patch below does that by adding an optional argument to
MatchOperandParserImpl(). It seems really ugly though. Does anyone have
any better suggestions?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1704 bytes
Desc: not available
More information about the llvm-dev