Skip to content

Conversation

seven-mile
Copy link
Collaborator

The first patch to fix #803 . This PR adds the calling convention attribute to CallOp directly, which is similar to LLVM, rather than adding the information to function type, which mimics Clang AST function type.

The syntax of it in CIR assembly is between the function type and extra attributes, as follows:

%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)

The verification of direct calls is not included. It will be included in the next patch extending CIRGen & Lowering.


For every builder method of Call Op, an optional parameter callingConv is inserted right before the parameter of extra attribute. However, apart from the parser / printer, this PR does not introduce any functional changes.

@sitio-couto
Copy link
Collaborator

sitio-couto commented Sep 10, 2024

@seven-mile quick question about this: what led you to add calling convention to the CallOp instead of the FuncOp? Or, in other words, choosing the more LLVM-like approach than the AST-like one?

@seven-mile
Copy link
Collaborator Author

FuncOp already got one, do you mean FunctionType? If so, the description of #803 provides more information about the decision.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach makes sense to me, I don't think adding this to the func type is the right approach.

Verification might be a bit tricky because we might start getting legit failures in code where people are relying on bad behavior (ODR violations). I'd say we should do verification anyways (your next PRs) and if/when it becomes a problem, we introduce a pass to do the "ODR hand-waive".

LGTM with minor nit.

@bcardosolopes bcardosolopes merged commit d472146 into llvm:main Sep 11, 2024
6 checks passed
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
)

The first patch to fix llvm#803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
)

The first patch to fix llvm#803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
)

The first patch to fix llvm#803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
)

The first patch to fix llvm#803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
lanza pushed a commit that referenced this pull request Nov 5, 2024
The first patch to fix #803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
lanza pushed a commit that referenced this pull request Mar 18, 2025
The first patch to fix #803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
)

The first patch to fix llvm#803 . This PR adds the calling convention
attribute to CallOp directly, which is similar to LLVM, rather than
adding the information to function type, which mimics Clang AST function
type.

The syntax of it in CIR assembly is between the function type and extra
attributes, as follows:

```mlir
%1 = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i cc(spir_kernel) extra(#fn_attr)
```

The verification of direct calls is not included. It will be included in
the next patch extending CIRGen & Lowering.

---

For every builder method of Call Op, an optional parameter `callingConv`
is inserted right before the parameter of extra attribute. However,
apart from the parser / printer, this PR does not introduce any
functional changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make cir.call aware of calling conventions
3 participants