Skip to content
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

Add a cir.const_vec, simlar to cir.const_array and cir.const_struct #498

Closed
bcardosolopes opened this issue Mar 5, 2024 · 1 comment
Closed
Assignees

Comments

@bcardosolopes
Copy link
Member

          Random comment: If this was a constant vector (which isn't the case), this reminds me of something we discussed in previous patches it would be good to have `#cir.const_vec` of sorts, and similarly to `ConstArrayAttr`, we could have a trailing zero indicator. Adding a comment here so I can populate an issue.

Originally posted by @bcardosolopes in #490 (comment)

@dkolsen-pgi dkolsen-pgi self-assigned this May 17, 2024
dkolsen-pgi added a commit to dkolsen-pgi/clangir that referenced this issue Jun 22, 2024
Implement vector constants in ClangIR.

Resolves issue llvm#498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`.  The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first.  If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
bcardosolopes pushed a commit that referenced this issue Jul 1, 2024
Implement vector constants in ClangIR.

Resolves issue #498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`. The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first. If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
@dkolsen-pgi
Copy link
Collaborator

Fixed by PR #700

Hugobros3 pushed a commit to shady-gang/clangir that referenced this issue Oct 2, 2024
Implement vector constants in ClangIR.

Resolves issue llvm#498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`. The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first. If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
smeenai pushed a commit to smeenai/clangir that referenced this issue Oct 9, 2024
Implement vector constants in ClangIR.

Resolves issue llvm#498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`. The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first. If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
smeenai pushed a commit to smeenai/clangir that referenced this issue Oct 9, 2024
Implement vector constants in ClangIR.

Resolves issue llvm#498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`. The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first. If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
keryell pushed a commit to keryell/clangir that referenced this issue Oct 19, 2024
Implement vector constants in ClangIR.

Resolves issue llvm#498 - Add a `cir.const_vec`, simlar to `cir.const_array`
and `cir.const_struct`

Create a new kind of attribute, `cir::ConstVectorAttr` in the code or
`#cir.const_vector` in the assembly, which represents a compile-time
value of a `cir::VectorType`. The values for the elements within the
vector are stored as attributes within an `mlir::ArrayAttr`.

When doing CodeGen for a prvalue of vector type, try to represent it as
`cir.const #cir.const_vector` first. If that fails, most likely because
some of the elements are not compile-time values, fall back to the
existing code that uses a `cir.vec.create` operation.

When lowering directly to LLVM IR, lower `cir.const #cir.const_vector`
as `llvm.mlir.constant(dense<[...]> : _type_) : _type_`.

When lowering through other MLIR dialects, lower
`cir.const #cir.const_vector` as `arith.constant dense<[...]> : _type_`.

No new tests were added, but the expected results of the existing tests
that use vector constants were updated.
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

No branches or pull requests

2 participants