Shop OBEX P1 Docs P2 Docs Learn Events
P2, LLVM, and many extra languages — Parallax Forums

P2, LLVM, and many extra languages

While I understand the sentiment a lot of older users have around the P2 and preferring Spin2, FORTH, BASIC, Assembly, etc (I personally love writing assembly projects in my free time, and FORTH is fun.), I have to acknowledge that support for a larger language set that LLVM provides is important, as that opens the doors for C, C++, Rust, TinyGo, and many, many other languages that use LLVM as a backend. I've looked at the P2LLVM project a bit, and I think the biggest issue is just that it doesn't have much support.
I'm likely going to try working on P2LLVM myself, but I'm pretty much brand new to the P2, it having only arrived 2 days ago, also brand new to LLVM, and rusty with C++, as most of my projects these days are in Rust.
Not having official C support is a bit detrimental to the P2, at that, as people i've talked to have expressed that one of the reasons they didn't really use the Propeller was the lack of C, C++, or other much more common languages.
I'm hoping that, eventually, C will be an officially supported language for the processor. LLVM exists and can provide the backbone for such an effort, as it already has a grade A optimizer and established infrastructure.

Comments

  • Many, many people have been asking for "official" C support for the P2 for ages. Frankly, it isn't going to happen, at least not until the P2 is a big success.

    For now, you'll have to use one of the existing community compilers. It sounds like you're planning to help out with p2llvm, and that's great! There are also some other C compilers you could look at:

    Catalina C
    FlexProp
    p2gcc
    riscvp2

    These are all in various states of development and with varying degrees of support.
  • moonymoony Posts: 27
    edited 2021-01-17 21:03
    @ersmith I'm already aware of those compilers, thank you though. I feel, though, that the P2 will have trouble really taking off in this day and age without at least good C support, as the vast majority of embedded developers know C, and being able to use the huge library of existing code is important. I personally am not really impeded by the lower-quality C support, but I know others are.
  • Cluso99Cluso99 Posts: 18,069
    I thought someone else was working on P2 LLVM. Perhaps a search of the P2 threads might be worthwhile. IIRC it was only months ago.
  • @Cluso99 Someone else indeed is. I'm picking up where they left off, they haven't touched it in ~5 months now.
  • moony wrote: »
    I have to acknowledge that support for a larger language set that LLVM provides is important, as that opens the doors for C, C++, Rust, TinyGo, and many, many other languages that use LLVM as a backend.
    Agreed. That would also make Free Pascal a potential option, which I'd really love to see.

  • RobertF wrote: »
    moony wrote: »
    I have to acknowledge that support for a larger language set that LLVM provides is important, as that opens the doors for C, C++, Rust, TinyGo, and many, many other languages that use LLVM as a backend.
    Agreed. That would also make Free Pascal a potential option, which I'd really love to see.

    I approve this message! :-)
  • So far, I've got some number of the P2's instructions specified within LLVM. I've got a lot of work ahead, and I don't usually code on weekdays, but hopefully I'll have some usable progress soon enough.
    The P2's flag registers ended up needing specialized handling to use them efficiently, which is somewhat annoying but I'll work with it, could get some cool opts out of it.
    LLVM's Tablegen DSL has been a bit of a blessing, specifying the P2's instructions would be much more tedious without it!

    498 x 735 - 98K
  • I'd love to help with this, although I don't have experience in LLVM (only ever used gcc). My current focus is on documentation improvements (see my other thread) but I have enough C/C++ experience that I could help write a new P2 backend.

  • @sjgallagher2 I'd appreciate the help. When I get home, I'll push my current progress to a fork on github so you can see what's been done so far.

    My own progress has been a bit slow, as not only am I learning LLVM's codebase, I'm also relearning C/C++, as I haven't actively used either in a long time. I recommend configuring LLVM to only build the P2 backend to save on build times.

  • Forgive me if I'm pestering, but can you give us an update? The benefits of having LLVM working for P2 cannot be overstated. Thank you again for taking it on!

  • @RobertF I'm afraid I don't have much to say, life happened.
    Alongside all that, at the moment Texas happens to be especially warm and comfortable (ha!)
    I'll resume working on LLVM when I find the motivation to, but atm I don't have that, sorry.

  • No problem, completely understandable. That's a lot for one person to take on in his/her spare time.

  • n_ermoshn_ermosh Posts: 294
    edited 2021-03-09 02:58

    @moony et al, I'd love it if you kept me in the loop on what you are working on with the LLVM backend, if you are extending what I wrote over the summer (https://github.com/ne75/p2llvm). I would hope you aren't starting from scratch, I wrote a lot so far. I haven't many updates recently as it does what I need it to do, and have't seen too many others actually use it and report problems. I do intend to continue to support this as I can.

Sign In or Register to comment.