Windows/Android/Mac/RaspberryPi/Linux/ARM/FPGA/ASIC/DSP/uC

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 24 13:11:37 PDT 2017


On Saturday, 24 June 2017 at 19:18:24 UTC, FoxyBrown wrote:
> On Saturday, 24 June 2017 at 18:51:44 UTC, Johan Engelen wrote:
>> On Saturday, 24 June 2017 at 18:16:46 UTC, FoxyBrown wrote:
>>> [...]
>>
>> Yes indeed. LDC will output the IR when you use the 
>> `-output-ll` (human readable) or `-output-bc` (binary 
>> representation) compile switches.
>>
>>> [...]
>>
>> In theory, yes indeed. What may be important is that the LLVM 
>> versions match (the LLVM version used to build LDC, and the 
>> LLVM version of that 8051 fork). With every new LLVM version, 
>> the IR may change in subtle ways...
>>
>>> [...]
>>
>> As far as I know, GCC also uses an IR (it's used for LTO).
>>
>> -Johan
>
> Why, then, doesn't anything that targets llvm simply target 
> everything else? D is not just for the ones listed but also for 
> many other platforms? is it simply because no one has 
> implemented the transformations to prove it works?

In theory, once you can produce llvm IR, you get every CPU that 
llvm targets, which grows by the day.  However, being able to 
target CPUs is not the only aspect of porting, you also have to 
integrate with the OS.  D's runtime and phobos rely on the C 
runtime for some basic functions, though there has been some talk 
of re-implementing them in pure D.

So if you're running on an OS, you also need to wrap several C 
APIs from that OS, see my pulls for bionic/Android, mostly the 
bottom five:

https://github.com/dlang/druntime/pulls?q=is%3Apr+author%3Ajoakim-noah+is%3Aclosed

If you're running on bare metal, that's obviously not an issue, 
but conversely those who've tried it say D doesn't really support 
stripping out the druntime for those targets.  There has been a 
renewed focus on this recently, with work on the -betterC flag, 
about which you can see another forum thread.


More information about the Digitalmars-d mailing list