[llvm-dev] Default arguments in AsmMatcher
Семен Колтон via llvm-dev
llvm-dev at lists.llvm.org
Thu Mar 10 07:45:14 PST 2016
Hi,
In AMDGPU backend assembler, we have some instructions with optional
operands (IsOptional=1 in AsmOperandClass). For example, all of the
following instructions are valid:
v_add_f32 v1, v2, v3
v_add_f32 v1, v2, v3 clamp:0
v_add_f32 v1, v2, v3 mul:2
v_add_f32 v1, v2, v3 clamp:0 mul:2
If operand is not specified, it is not added to OperandVector during
parsing, but we want it to be added to final MCInst (usually with value 0).
Currently, we have to create custom converters for instructions and add
default values inside them. But having a lot of different instruction
formats in AMDGPU backend number of converters began to increase
immoderately. Most of these converters are similar and needed only to add
default values. We would like to find a way to solve this task without need
to add custom converters.
Perhaps AsmMatcher can handle this and add default values based on some
field (DefaultValue=”0”). Or there can be a callback that returns default
value (DefaultValueMethod=”getDefaultClampValue”). However, it is unclear
if it can really be done in AsmMatcher.
Do you have any suggestion/comments on how to better solve this? What do
other backends do?
Thanks,
Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160310/3ec38db4/attachment.html>
More information about the llvm-dev
mailing list