Converting intermediate code to x64 code
The intermediate code generator from Chapter 9, Intermediate Code Generation, placed the intermediate code for the whole program in the icode
attribute in the root of the syntax tree. A Boolean named isNative
says whether to generate bytecode as shown in the previous chapter, or native x64 code. To generate x64 code, the gencode()
method in the j0
class calls a new method in this class, named x64code()
, and passes it the intermediate code in root.icode
as its input. Output x64 code is placed in a j0
list variable named xcode
. The Unicon gencode()
method that invokes this functionality in j0.icn
looks like this:
method gencode(root) root.genfirst() root.genfollow() root.gentargets() root.gencode() xcode := [] ...