llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
308 stars 84 forks source link

[CIR][ABI] Create target lowering library skeleton #643

Closed sitio-couto closed 1 month ago

sitio-couto commented 1 month ago

This patch adds a new TargetLowering library that intends to add supoort for lowering CIR code to target specific CIR code. It is largely based on the original codegen library used to lower AST nodes to ABI/Target -specific LLVM IR instructions. Because of this, each file has a comment specifying the original codegen file that inspired the new file. The idea is that anyone who wishes to expand this library can look at the original codegen file to understand how to implement the new feature.

In some cases, CIRGen defers the handling of ABI/target-specific details for a later stage in the pipeline. One reason for this is to keep the intermediate representation on a higher-level, which makes it easier to reason about and to perform optimizations. However, we still need to lower such representation to a target-specific format at some point. Some examples are ctor/dtors and calling conventions, which are not fully handled by CIRGen. The new library will be responsible for these lowerings.

Some files are empty but will eventually be used and a few getters and methods where added to avoid unused warnings. Missing features in this library are tracked in a dedicated MissingFeature.h header.

bcardosolopes commented 1 month ago

The idea is that anyone who wishes to expand this library can look at the original codegen file to understand how to implement the new feature.

Nice :)

sitio-couto commented 1 month ago

@bcardosolopes applied.

sitio-couto commented 1 month ago

@bcardosolopes applied.

This PR doesn't Implement ABI lowering, only the library structure. The following PRs will.