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

Changed LLVM Dialect to ClairV2 #228

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.mill
Original file line number Diff line number Diff line change
@@ -107,7 +107,6 @@ object `package` extends RootModule with ScairModule {
"scair.dialects.arithgen.ArithGen",
"scair.dialects.cmathgen.CMathGen",
"scair.dialects.funcgen.FuncGen",
"scair.dialects.llvmgen.LLVMGen",
"scair.dialects.memrefgen.MemrefGen"
) )(oneDialect)()
PathRef(Task.dest)
36 changes: 23 additions & 13 deletions dialects/src/main/scala-3/llvm/LLVM.scala
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
package scair.dialects.llvmgen
package scair.dialects.llvm

import scair.clair.mirrored.*
import scair.dialects.builtin.DenseArrayAttr
import scair.dialects.builtin.IntegerType
import scair.ir.Attribute
import scair.scairdl.constraints.*
import scair.scairdl.irdef.*
import scair.ir.*
import scair.clairV2.codegen.*
import scair.clairV2.mirrored.*
import scair.dialects.builtin.*
import scair.ir.*
import scair.clairV2.macros._

object Ptr extends AttributeObject {
override def name: String = "llvm.ptr"
override def factory = Ptr.apply
}

case class Ptr(
) extends AttributeFE
with TypeAttributeFE
val typ: Seq[Attribute]
) extends ParametrizedAttribute(
name = "llvm.ptr",
parameters = Seq(typ)
)
with TypeAttribute

case class Load(
ptr: Operand[Ptr],
result: Result[Attribute]
) extends OperationFE
) extends MLIRName["llvm.load"]
derives MLIRTrait

case class GetElementPtr(
base: Operand[Ptr],
dynamicIndices: Variadic[Operand[IntegerType]],
res: Result[Ptr],
rawConstantIndices: Property[DenseArrayAttr],
elem_type: Property[Attribute]
) extends OperationFE
) extends MLIRName["llvm.getelementptr"]
derives MLIRTrait

object LLVMGen
extends ScaIRDLDialect(
summonDialect[(GetElementPtr, Ptr, Load)]("LLVM")
)
val LLVMDialect = summonDialect[(Load, GetElementPtr)](Seq(Ptr))
8 changes: 4 additions & 4 deletions tests/filecheck/dialects/llvm/llvm.mlir
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
%3 = "llvm.getelementptr"(%0, %1) <{"elem_type" = i32, "rawConstantIndices" = array<i32: -2147483648>}> : (!llvm.ptr, i32) -> !llvm.ptr

// CHECK: builtin.module {
// CHECK-NEXT: %0, %1 = "test.op"() : () -> (!llvm.ptr, i32)
// CHECK-NEXT: %2 = "llvm.load"(%0) : (!llvm.ptr) -> (i32)
// CHECK-NEXT: %3 = "llvm.load"(%0) : (!llvm.ptr) -> (index)
// CHECK-NEXT: %4 = "llvm.getelementptr"(%0, %2) <{elem_type = i32, rawConstantIndices = array<i32: -2147483648>}> : (!llvm.ptr, i32) -> (!llvm.ptr)
// CHECK-NEXT: %0, %1 = "test.op"() : () -> (!llvm.ptr<[]>, i32)
// CHECK-NEXT: %2 = "llvm.load"(%0) : (!llvm.ptr<[]>) -> (i32)
// CHECK-NEXT: %3 = "llvm.load"(%0) : (!llvm.ptr<[]>) -> (index)
// CHECK-NEXT: %4 = "llvm.getelementptr"(%0, %2) <{elem_type = i32, rawConstantIndices = array<i32: -2147483648>}> : (!llvm.ptr<[]>, i32) -> (!llvm.ptr<[]>)
// CHECK-NEXT: }
13 changes: 0 additions & 13 deletions tests/filecheck/mlir/dialects/llvm/llvm.mlir

This file was deleted.

2 changes: 1 addition & 1 deletion tools/src/main/scala-3/scair/utils/Utils.scala
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ val allDialects: Seq[Dialect] =
BuiltinDialect,
CMathDialect,
FuncDialect,
LLVMDialect,
MathDialect,
MemrefDialect,
TupleStreamDialect,
@@ -40,6 +39,7 @@ val allDialects: Seq[Dialect] =

val allClairV2Dialects: Seq[DialectV2] =
Seq(
LLVMDialect,
CMathV2Dialect
)