Skip to content

[CIR] Implement AnyScalarType constraint #141033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

xlauko
Copy link
Contributor

@xlauko xlauko commented May 22, 2025

This mirrors incubator changes from llvm/clangir#1625

@xlauko
Copy link
Contributor Author

xlauko commented May 22, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@xlauko xlauko marked this pull request as ready for review May 22, 2025 10:27
@xlauko xlauko requested a review from andykaylor May 22, 2025 10:27
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels May 22, 2025
@xlauko xlauko requested a review from erichkeane May 22, 2025 10:27
@llvmbot
Copy link
Member

llvmbot commented May 22, 2025

@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Henrich Lauko (xlauko)

Changes

This mirrors incubator changes from llvm/clangir#1625


Full diff: https://github.com/llvm/llvm-project/pull/141033.diff

1 Files Affected:

  • (modified) clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td (+18)
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td
index 902d6535ff717..ec461cab961c7 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td
@@ -31,6 +31,12 @@ class CIR_ConfinedType<Type type, list<Pred> preds, string summary = "">
     : Type<And<[type.predicate, CIR_CastedSelfsToType<type.cppType, preds>]>,
          summary, type.cppType>;
 
+//===----------------------------------------------------------------------===//
+// Bool Type predicates
+//===----------------------------------------------------------------------===//
+
+def CIR_AnyBoolType : CIR_TypeBase<"::cir::BoolType", "boolean type">;
+
 //===----------------------------------------------------------------------===//
 // IntType predicates
 //===----------------------------------------------------------------------===//
@@ -193,4 +199,16 @@ def IntegerVector : Type<
 // Any Integer or Vector of Integer Constraints
 def CIR_AnyIntOrVecOfInt: AnyTypeOf<[CIR_AnyIntType, IntegerVector]>;
 
+//===----------------------------------------------------------------------===//
+// Scalar Type predicates
+//===----------------------------------------------------------------------===//
+
+defvar CIR_ScalarTypes = [
+    CIR_AnyBoolType, CIR_AnyIntType, CIR_AnyFloatType, CIR_AnyPtrType
+];
+
+def CIR_AnyScalarType : AnyTypeOf<CIR_ScalarTypes, "cir scalar type"> {
+  let cppFunctionName = "isScalarType";
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIRTYPECONSTRAINTS_TD

Copy link
Contributor

@andykaylor andykaylor left a comment

Choose a reason for hiding this comment

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

lgtm

@xlauko
Copy link
Contributor Author

xlauko commented May 22, 2025

Merge activity

  • May 22, 4:46 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 22, 4:48 PM UTC: @xlauko merged this pull request with Graphite.

@xlauko xlauko merged commit 586e1df into main May 22, 2025
16 checks passed
@xlauko xlauko deleted the users/xlauko/cir-scalar-constraint branch May 22, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants