Changes between Version 1 and Version 2 of Commentary/Compiler/Backends/LLVM/GHC_LLVMPorting


Ignore:
Timestamp:
Jun 20, 2011 11:02:16 PM (3 years ago)
Author:
dterei
Comment:

--

Legend:

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

    v1 v2  
    33The list of steps needed for new GHC/LLVM port is: 
    44 
    5 '''(1)''' Make sure GHC unregisterised build is working on your target platform. 
     5'''(1)''' Make sure GHC unregisterised build is working on your target platform (using the C backend). This guide isn't intended for porting GHC to a completely unsupported platform. If the platform in question doesn't have a GHC unregisterised build then follow the [wiki:Building/Porting GHC Porting Guide] first. 
    66 
    7 '''(2)''' Now try to compile some very simple programs such as 'hello world' 
    8 or simpler using the GHC you just built, both with the C backend and 
    9 the LLVM backend. If the llvm backend built programs are failing find 
    10 out why. This is done using a combination of things such as the error 
    11 message you get when the program fails, tracing the execution with GDB 
    12 and also just comparing the assembly code produced by the C backend to 
    13 what LLVM produces. This last method is often the easiest. 
     7'''(2)''' Now try to compile some very simple programs such as 'hello world' or simpler using the GHC you just built. Try with the C backend First to make sure everything is working. Then try with the LLVM backend. If the llvm backend built programs are failing find out why. This is done using a combination of things such as the error message you get when the program fails, [wiki:Debugging/CompiledCode tracing the execution with GDB] and also just comparing the assembly code produced by the C backend to what LLVM produces. This last method is often the easiest and you can occasionally use techniques like doing doing a 'binary search' for the bug by merging the assembly produced by the C backend and LLVM backend. 
    148 
    15 '''(3)''' When the programs you throw at the LLVM backend are running, try 
    16 running the GHC testsuite. First run it against the C backend to get a 
    17 baseline, then run it against the LLVM backend. Fix any failures that 
    18 are LLVM backend specific. 
     9'''(3)''' When the programs you throw at the LLVM backend are running, try running the GHC testsuite. First run it against the C backend to get a baseline, then run it against the LLVM backend. Fix any failures that are LLVM backend specific. 
    1910 
    20 '''(4)''' If the testsuite is passing, now try to build GHC itself using the 
    21 LLVM backend. This is a very tough test. When working though its a 
    22 good proof that the LLVM backend is working well on your platform. 
     11'''(4)''' If the testsuite is passing, now try to build GHC itself using the LLVM backend. This is a very tough test. When working though its a good proof that the LLVM backend is working well on your platform. 
    2312 
    24 '''(5)''' Now you have LLVM working in unregistered mode, so the next thing 
    25 is to implement custom GHC calling convention and get the llvm backend 
    26 working in registered mode but with (TABLES_NEXT_TO_CODE = NO in your 
    27 build.mk). Majority of this step involves hacking inside the LLVM code. Usually lib/Target/<your target platform name> is the best way to start. Also you might study what David Terei did for x86 support: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-March/030031.html and his patch itself: http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20100307/714e5c37/attachment-0001.obj to get an idea what's really needed. 
     13'''(5)''' Now you have LLVM working in unregistered mode, so the next thing is to implement the GHC calling convention in LLVM that is used by GHC's LLVM backend. This should then allow you to get the LLVM backend working in registered mode but with (TABLES_NEXT_TO_CODE = NO in your build.mk). Majority of this step involves hacking inside the LLVM code. Usually lib/Target/<your target platform name> is the best way to start. Also you might study what David Terei did for [http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-March/030031.html x86 support] and his [http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20100307/714e5c37/attachment-0001.obj patch itself] to get an idea what's really needed. 
    2814 
    29 '''(6)''' Once '''(5)''' is working you have it all running except 
    30 TABLES_NEXT_TO_CODE. So change that to Yes in your build.mk and get 
    31 that working. 
     15'''(6)''' Once '''(5)''' is working you have it all running except TABLES_NEXT_TO_CODE. So change that to Yes in your build.mk and get that working. This will probably involve changing the mangler used by LLVM to work on the platform you are targeting.