[LLVMdev] Replacing Platform Specific IR Codes with Generic Implementation and Introducing Macro Facilities

Tim Northover t.p.northover at gmail.com
Sat May 10 05:53:08 PDT 2014


On 10 May 2014 12:57, Suminda Dharmasena <sirinath at sakrio.com> wrote:
> This might sound a bit controversial at this stage of maturity for LLVM. Can
> the community consider deprecating architecture specific features which has
> come into the IR and replacing them with more generic IR codes.

On a case-by-case basis, certainly. I'm very much in favour of general
mechanisms so that work doesn't have to be duplicated on all targets.

It doesn't make sense for everything though, particularly if you want
target-specific IR to simply not exist. What would you map ARM's
"ldrex" to on x86? Or an inline assembly block?

> Also some form of powerful macro facility which supports platform specific
> macros which can be used to expand generic IRs to a set of IRs which might
> have equivalent results and / or the platform specific implementation of it.

LLVM IR isn't really for humans to write, so macros would likely not
be a popular idea. Reusable APIs to emit the correct target-specific
IR for features would probably be the LLVM equivalent.

We keep meaning to write one to handle the details of emitting
functions compliant with C ABIs, for example.

> The aim would be that any code in LLVM IR can execute in any architecture
> and will get the best possible optimisation and full set of functionality
> being available in each architecture.

Have you looked at what the PNaCl people are doing? As I recall they
have something close to a generic subset of LLVM IR which they then
compile to the various native object formats (they don't care about
matching any particular ABI except their own).

There's inevitably some kind of speed penalty, but I really like the idea.

Cheers.

Tim.



More information about the llvm-dev mailing list