Commit fe04f91
committed
[MLIR][LLVM][Intrinsics] Add new MLIR and LLVM APIs to automatically resolve overload types
Currently, the `getOrInsertDeclaration` API requires callers to explicitly
provide overload types for overloaded intrinsics, placing a significant burden
on callers who must determine whether overload types are needed. This typically
results in conditional logic at each call site to check if the intrinsic is
overloaded and manually match the intrinsic signature.
This patch introduces a new `getOrInsertDeclaration` overload that automatically
deduces overload types from the provided return type and argument types. The new
API uses `Intrinsic::matchIntrinsicSignature` internally to resolve overloaded
types, eliminating the need for callers to perform manual overload detection.
This patch introduces two levels of convenience APIs to eliminate manual
overload detection:
1. A new `getOrInsertDeclaration` overload that automatically deduces overload
types from return and argument types
2. A new `createIntrinsicCall` overload at MLIR level that leverages the above to provide a
simple, type-based intrinsic call interface
Key changes:
- Added `Intrinsic::getOrInsertDeclaration(Module*, ID, Type *RetTy,
ArrayRef<Type*> ArgTys)` overload that automatically resolves overloaded
intrinsics by internally using `matchIntrinsicSignature`. For non-overloaded
intrinsics, it delegates to the existing API.
- Refactored `Intrinsics.cpp` to extract a common helper function
`getOrInsertIntrinsicDeclarationImpl` to reduce code duplication between
the two `getOrInsertDeclaration` overloads.
- Added `createIntrinsicCall(IRBuilderBase&, Intrinsic::ID, Type *retTy,
ArrayRef<Value*> args)` overload in ModuleTranslation that provides a
simple interface by delegating overload resolution to the new LLVM API.
- Simplified NVVM_PrefetchOp implementation by removing all conditional logic
for handling overloaded intrinsics.1 parent 29e3c2e commit fe04f91
File tree
5 files changed
+81
-15
lines changed- llvm
- include/llvm/IR
- lib/IR
- mlir
- include/mlir
- Dialect/LLVMIR
- Target/LLVMIR
- lib/Target/LLVMIR
5 files changed
+81
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
728 | 727 | | |
729 | | - | |
730 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | | - | |
743 | | - | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
747 | 779 | | |
748 | 780 | | |
749 | 781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3176 | 3176 | | |
3177 | 3177 | | |
3178 | 3178 | | |
3179 | | - | |
3180 | | - | |
3181 | | - | |
3182 | | - | |
3183 | | - | |
3184 | | - | |
| 3179 | + | |
3185 | 3180 | | |
3186 | 3181 | | |
3187 | 3182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
515 | 524 | | |
516 | 525 | | |
517 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
901 | 916 | | |
902 | 917 | | |
903 | 918 | | |
| |||
0 commit comments