Changes between Version 6 and Version 7 of Commentary/Compiler/Backends/LLVM/GHC_LLVMPorting


Ignore:
Timestamp:
Jun 28, 2011 1:15:05 AM (3 years ago)
Author:
dterei
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/Backends/LLVM/GHC_LLVMPorting

    v6 v7  
    1919Here is an expanded version of what needs to be done in step 5 and 6 to get a registerised port of LLVM working: 
    2020 
    21 1. GHC in registerised mode stores some of its virtual registers in 
    22  real hardware registers for performance. You will need to decide on a 
    23  mapping of GHC's virtual registers to hardware registers. So how 
    24  many registers you want to map and which virtual registers to store 
    25  and where. GHC's design for this on X86 is basically to use as many 
    26  hardware registers as it can and to store the more frequently accessed 
    27  virtual registers like the stack pointer in callee saved registers 
    28  rather than caller saved registers. You can find the mappings that GHC 
    29  currently uses for supported architectures in 
    30  'includes/stg/MachRegs.h'. 
     211. GHC in registerised mode stores some of its virtual registers in real hardware registers for performance. You will need to decide on a mapping of GHC's virtual registers to hardware registers. So how many registers you want to map and which virtual registers to store and where. GHC's design for this on X86 is basically to use as many hardware registers as it can and to store the more frequently cessed virtual registers like the stack pointer in callee saved registers rather than caller saved registers. You can find the mappings that GHC currently uses for supported architectures in 'includes/stg/MachRegs.h'. 
    3122 
    32 2. You will need to implement a custom calling convention for LLVM for your platform 
    33  that supports passing arguments using the register map you 
    34  decided on. You can see the calling convention I have created for X86 
    35  in the llvm source file 'lib/Target/X86/X86CallingConvention.td'. 
     232. You will need to implement a custom calling convention for LLVM for your platform that supports passing arguments using the register map you decided on. You can see the calling convention I have created for X86 in the llvm source file 'lib/Target/X86/X86CallingConvention.td'. 
    3624 
    37253. Get GHC's build system running on your platform in registerised mode. 
    3826 
    39 4. Add new inline assembly code for your platform to ghc's RTS. See files like 
    40  'rts/StgCRun.c' that include assembly code for the architectures GHC 
    41  supports. This is the main place as its where the boundary between the 
    42  RTS and haskell code is but I'm sure there are defiantly other places 
    43  that will need to be changed. Just grep the source code to find 
    44  existing assembly and add code for your platform appropriately. 
     274. Add new inline assembly code for your platform to ghc's RTS. See files like 'rts/StgCRun.c' that include assembly code for the architectures GHC supports. This is the main place as its where the boundary between the RTS and haskell code is but I'm sure there are defiantly other places that will need to be changed. Just grep the source code to find existing assembly and add code for your platform appropriately. 
    4528 
    46295. Will need to change a few things in LLVM code gen. 
    4730 
    48 5.1 'compiler/llvmGen/LlvmCodeGen/Ppr.hs' defines a platform specific 
    49  string that is included in all generated llvm code. Add one for your platform. 
    50  This string specifies the datalayout parameters for the platform (e.g 
    51  pointer size, word size..). If you don't include one llvm should still 
    52  work but wont optimise as aggressively. 
    53 5.2 'compiler/llvmGen/LlvmCodeGen/CodeGen.hs' has some platform 
    54  specific code on how write barriers should be handled. 
     315.1 'compiler/llvmGen/LlvmCodeGen/Ppr.hs' defines a platform specific string that is included in all generated llvm code. Add one for your platform. This string specifies the datalayout parameters for the platform (e.g pointer size, word size..). If you don't include one llvm should still work but wont optimise as aggressively. 
    5532 
    56 6. Probably some stuff elsewhere in ghc that needs to be changed (most 
    57  likely in the main/ subfolder which is where most the compiler driver 
    58  lives or in codegen/ which is the Cmm code generator). 
     335.2 'compiler/llvmGen/LlvmCodeGen/CodeGen.hs' has some platform specific code on how write barriers should be handled. 
    5934 
    60 7. This is just what I know needs to be done, I'm sure there is many 
    61  small pieces missing although they should all fall into one of the 
    62  above categories. In the end just trial and error your way to success. 
     356. Probably some stuff elsewhere in ghc that needs to be changed (most likely in the main/ subfolder which is where most the compiler driver lives or in codegen/ which is the Cmm code generator). 
     36 
     377. This is just what I know needs to be done, I'm sure there is many small pieces missing although they should all fall into one of the above categories. In the end just trial and error your way to success.