Recent

Author Topic: Can the FPC optimiser and back end be used with a new front end ?  (Read 2980 times)

simonc

  • Newbie
  • Posts: 2
Is it viable to implement a new language front end (implementing, say, Ada 95, Modula 2 or Oberon) that would use the existing FPC optimiser and back end code generators ?

The goal here is to see if these parts of FPC can be used as a generic infrastructure in the same way as the LLVM core libraries currently are. It would be a nice lightweight alternative to the LLVM libraries if such a thing were possible.

From reading the various online documents I have found, it is not yet clear to me how viable this is.

Unlike LLVM, FPC does not appear to use a human readable IR language, but instead uses a Pascal based data structure. This means any new front end would probably have to be in Pascal as well. This is absolutely not a problem for me.

However, I have not yet found any documentation comparable to the LLVM IR documentation which shows how a new front end would build up this data structure and pass it to the FPC optimiser and back end.

Is such an idea viable ?

Thanks,

Simon.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Can the FPC optimiser and back end be used with a new front end ?
« Reply #1 on: May 19, 2018, 09:23:34 am »
Is such an idea viable ?

In principle that might be viable, though the compiler's code is not structured for that: It's geared towards the (Object) Pascal language and its various dialects.
I also don't know how much support you'd receive for restructuring the compiler towards that goal of yours as most of us core developers are Pascal developers (e.g. I myself definitely would not be interested)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Can the FPC optimiser and back end be used with a new front end ?
« Reply #2 on: May 19, 2018, 09:24:28 am »
I wouldn't call it impossible, but any new frontend will either need to be adjusted to produce whatever the compiler recognizes or extend it for something FPC doesn't have. e.g. BY clause in FOR loop that Modula-2 and Oberon has. If you see compiler/nflw.pas, you will find that tfornode has no field for that clause. Either you have to extend tfornode or produces twhilerepeatnode instead (AFAIK FOR loop semantics is already different for those Pascal's little bros anyway). It's like transpiling everything to Pascal, only in memory and as data structure.

FPC was never intended to be used as generic infrastructure target or compiler library like LLVM, so everything is built specifically with Pascal in mind.

simonc

  • Newbie
  • Posts: 2
Re: Can the FPC optimiser and back end be used with a new front end ?
« Reply #3 on: May 20, 2018, 12:14:05 am »
FPC was never intended to be used as generic infrastructure target or compiler library like LLVM, so everything is built specifically with Pascal in mind.

The more I look at it, the more I am also beginning to realise that unfortunately.

Oh well, it was a nice idea, but not a practical one as it turns out. Thanks to both of you for your replies.

Simon.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Can the FPC optimiser and back end be used with a new front end ?
« Reply #4 on: May 20, 2018, 12:24:51 am »
One does have to take into account that FPC originally was not multi target (x86 only), and not for deep embedded (8-bit and 16-bit and their segmentation) either.

The question is more, who will be the first?

 

TinyPortal © 2005-2018