Replies: 4 comments 2 replies
|
I believe I do not understand the problem completely. Why do we need an encoding function in the assembly printer? The assembly printer never has an encoding, it only has a decoding function. |
No, it's exactly the opposite. The SelectionDag already operates on decoded values. So, not on fields but on field access functions (as immediates). So at the moment, if you want to print an operand in assembly, you have two choices: Below, you don't apply any function to the value. So, the output is something like that Below, you declared that you want to print the raw field value. However, when printing assembly, we have to apply the encoding function, so The problem is that (1) it is not clear that we are mixing assembly and binary. I propose to disallow the usage of fields which are not operands of the instruction. (2) Your answer actually emphasis my point that it is not visible that the encoding function is applied. Lastly, if you have an encoding function which references multiple field access functions (ergo multiple operands), it's getting really complicated. |
|
The assembly should have nothing to do with the Selection DAG, it has to be separated completely from the compiler (instruction selector). The compiler has work solely on the binary representation. Therefore, there exist the encoding and predicate functions for the compiler. The compiler has to work for different assembler printers with different syntaxes like reordering of destination and source registers or different representations of immediate values (e.g. unchanged or shifted). The compiler and the assembly printers have to be strictly separated and not intermingled. |
|
I try to summarize my understanding of the issue, without
(Note: These names are my ad hoc suggestion.) All representations can be converted into each other. In LLVM, the central representation is 1). Note there is no step In VADL the central representation is 3). So there is a mismatch between LLVM and VADL. This is a proposal worth contemplating. It could be more natural to specify As far as I can tell, a possible solution in the LLVM assembly printer with the current However, the objection is valid, that this is a convoluted Both representations have pros and cons. Personally I would suggest as a first try to keep the current assembly descrption, i.e., |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It is possible to define machine instructions with an assembly directive. This assembly directive is used by the compiler for printing an assembly representation of an instruction.
An example would like that
Note that in the case of
LUIthe behavior isX(rd) := immUp. This means that theLUIinstruction has two operands:rdandimmUp. The assembly directive uses the both therdwhich is ok since it is an operand andimmbecauseimmUpencodesimm. However,hex(imm)usesimmwhich is not an operand and instead refers to the binary representation of the instruction. This makes it necessary to encodeimmUptoimm. In this particular case, this is quite easy since field access functions and fields have a direct 1:1 relationship. But, if the encoding function requires multiple field access functions, the implementation becomes quite complicated and weird. (1) It's not clear why the assembly view and binary encoding are mixed. (2) It's not clear for the user that an encoding function is applied.I propose to disallow the use of fields which are not operands. In this case
immwould throw an error, whilerdis ok.A correct specification would be:
The difference is that
some_encoding_functionis a function which might be equal to a binary encoding function, but no necessarily. This separates both worlds assembly and binary nicely.@AndreasKrall @benjaminkasper99
All reactions