6 ms·
What are the proper abstractions necessary?
by univerio 7y ago
What are the proper abstractions necessary?
- chrisseaton 7y agoMost simple cases of instructions seem straightforward to just go ahead and emit the bytes for. Then when you start to use more addressing modes you realise it gets to be a lot of code and it turns out there's a common pattern for everything. Here's a concrete example from an industrial assembler. Almost every simple instruction boils down this helper method which is parameterised by a bunch of flags and can then deal with all of them. https://github.com/oracle/graal/blob/f3a3576493f87abdea1045d6156a633e332550dd/compiler/src/org.graalvm.compiler.asm.amd64/src/org/graalvm/compiler/asm/amd64/AMD64BaseAssembler.java#L549 https://github.com/oracle/graal/blob/f3a3576493f87abdea1045d... Even that looks complicated! But writing this per instruction (the simple case) would be insanely complicated.
- userbinator 7y agoIdeally, the common fields and patterns noted by the manufacturer in the ISA description would be implemented, and then the remainder of the logic can be (relatively) simple table-lookup.