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

jl-generators.cpp changes #447

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
512 changes: 290 additions & 222 deletions deps/ReactantExtra/tblgen/jl-generators.cc

Large diffs are not rendered by default.

119 changes: 72 additions & 47 deletions src/mlir/Dialects/Affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ import ...IR:
IndexType
import ..Dialects: namedattribute, operandsegmentsizes
import ...API
using EnumX

@enumx CmpFPredicate false_ = 0 oeq = 1 ogt = 2 oge = 3 olt = 4 ole = 5 one = 6 ord = 7 ueq =
8 ugt = 9 uge = 10 ult = 11 ule = 12 une = 13 uno = 14 true_ = 15

@enumx CmpIPredicate eq = 0 ne = 1 slt = 2 sle = 3 sgt = 4 sge = 5 ult = 6 ule = 7 ugt = 8 uge =
9

@enumx IntegerOverflowFlags none nsw nuw

@enumx RoundingMode to_nearest_even = 0 downward = 1 upward = 2 toward_zero = 3 to_nearest_away =
4

@enumx AtomicRMWKind addf = 0 addi = 1 assign = 2 maximumf = 3 maxs = 4 maxu = 5 minimumf =
6 mins = 7 minu = 8 mulf = 9 muli = 10 ori = 11 andi = 12 maxnumf = 13 minnumf = 14

@enumx FastMathFlags none reassoc nnan ninf nsz arcp contract afn fast

"""
`apply`
Expand All @@ -37,16 +54,16 @@ have ‘index’ type.
"""
function apply(
mapOperands::Vector{Value};
result_0=nothing::Union{Nothing,IR.Type},
map,
result::Union{Nothing,IR.Type}=nothing,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[]
operands = Value[mapOperands...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("map", map),]
!isnothing(result_0) && push!(op_ty_results, result_0)
!isnothing(result) && push!(op_ty_results, result)

return create_operation(
"affine.apply",
Expand All @@ -55,8 +72,8 @@ function apply(
owned_regions,
successors,
attributes,
results=(length(op_ty_results) == 0 ? nothing : op_ty_results),
result_inference=(length(op_ty_results) == 0 ? true : false),
results=(isempty(op_ty_results) ? nothing : op_ty_results),
result_inference=isempty(op_ty_results),
)
end

Expand Down Expand Up @@ -105,15 +122,15 @@ undefined behavior.
function delinearize_index(
linear_index::Value,
dynamic_basis::Vector{Value};
multi_index::Vector{IR.Type},
static_basis,
multi_index::Tuple{Vararg{IR.Type}},
static_basis::Vector{Int64},
location=Location(),
)
op_ty_results = IR.Type[multi_index...,]
operands = Value[linear_index, dynamic_basis...]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("static_basis", static_basis),]
attributes = NamedAttribute[namedattribute("static_basis", Attribute(static_basis)),]

return create_operation(
"affine.delinearize_index",
Expand Down Expand Up @@ -238,10 +255,10 @@ function for_(
lowerBoundOperands::Vector{Value},
upperBoundOperands::Vector{Value},
inits::Vector{Value};
results::Vector{IR.Type},
lowerBoundMap,
upperBoundMap,
step,
results::Tuple{Vararg{IR.Type}},
lowerBoundMap::Attribute,
upperBoundMap::Attribute,
step::Attribute,
region::Region,
location=Location(),
)
Expand Down Expand Up @@ -345,8 +362,8 @@ func.func @pad_edges(%I : memref<10x10xf32>) -> (memref<12x12xf32) {
"""
function if_(
operand_0::Vector{Value};
results::Vector{IR.Type},
condition,
results::Tuple{Vararg{IR.Type}},
condition::Attribute,
thenRegion::Region,
elseRegion::Region,
location=Location(),
Expand Down Expand Up @@ -414,15 +431,15 @@ In the above example, `%linear_index` conceptually holds the following:
function linearize_index(
multi_index::Vector{Value},
dynamic_basis::Vector{Value};
linear_index=nothing::Union{Nothing,IR.Type},
static_basis,
linear_index::Union{Nothing,IR.Type}=nothing,
static_basis::Vector{Int64},
location=Location(),
)
op_ty_results = IR.Type[]
operands = Value[multi_index..., dynamic_basis...]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("static_basis", static_basis),]
attributes = NamedAttribute[namedattribute("static_basis", Attribute(static_basis)),]
push!(attributes, operandsegmentsizes([length(multi_index), length(dynamic_basis)]))
!isnothing(linear_index) && push!(op_ty_results, linear_index)

Expand All @@ -433,8 +450,8 @@ function linearize_index(
owned_regions,
successors,
attributes,
results=(length(op_ty_results) == 0 ? nothing : op_ty_results),
result_inference=(length(op_ty_results) == 0 ? true : false),
results=(isempty(op_ty_results) ? nothing : op_ty_results),
result_inference=isempty(op_ty_results),
)
end

Expand Down Expand Up @@ -467,7 +484,11 @@ Example 2: Uses `symbol` keyword for symbols `%n` and `%m`.
```
"""
function load(
memref::Value, indices::Vector{Value}; result::IR.Type, map, location=Location()
memref::Value,
indices::Vector{Value};
result::IR.Type,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[result,]
operands = Value[memref, indices...]
Expand Down Expand Up @@ -501,16 +522,16 @@ affine map.
"""
function max(
operands::Vector{Value};
result_0=nothing::Union{Nothing,IR.Type},
map,
result::Union{Nothing,IR.Type}=nothing,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[]
operands = Value[operands...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("map", map),]
!isnothing(result_0) && push!(op_ty_results, result_0)
!isnothing(result) && push!(op_ty_results, result)

return create_operation(
"affine.max",
Expand All @@ -519,8 +540,8 @@ function max(
owned_regions,
successors,
attributes,
results=(length(op_ty_results) == 0 ? nothing : op_ty_results),
result_inference=(length(op_ty_results) == 0 ? true : false),
results=(isempty(op_ty_results) ? nothing : op_ty_results),
result_inference=isempty(op_ty_results),
)
end

Expand Down Expand Up @@ -548,16 +569,16 @@ input operands and result must all have \'index\' type.
"""
function min(
operands::Vector{Value};
result_0=nothing::Union{Nothing,IR.Type},
map,
result::Union{Nothing,IR.Type}=nothing,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[]
operands = Value[operands...,]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[namedattribute("map", map),]
!isnothing(result_0) && push!(op_ty_results, result_0)
!isnothing(result) && push!(op_ty_results, result)

return create_operation(
"affine.min",
Expand All @@ -566,8 +587,8 @@ function min(
owned_regions,
successors,
attributes,
results=(length(op_ty_results) == 0 ? nothing : op_ty_results),
result_inference=(length(op_ty_results) == 0 ? true : false),
results=(isempty(op_ty_results) ? nothing : op_ty_results),
result_inference=isempty(op_ty_results),
)
end

Expand Down Expand Up @@ -638,13 +659,13 @@ affine.parallel (%ii, %jj) = (0, 0) to (%N, %M) step (32, 32) {
"""
function parallel(
mapOperands::Vector{Value};
results::Vector{IR.Type},
reductions,
lowerBoundsMap,
lowerBoundsGroups,
upperBoundsMap,
upperBoundsGroups,
steps,
results::Tuple{Vararg{IR.Type}},
reductions::Attribute,
lowerBoundsMap::Attribute,
lowerBoundsGroups::Attribute,
upperBoundsMap::Attribute,
upperBoundsGroups::Attribute,
steps::Attribute,
region::Region,
location=Location(),
)
Expand Down Expand Up @@ -694,20 +715,20 @@ instruction cache.
function prefetch(
memref::Value,
indices::Vector{Value};
isWrite,
localityHint,
isDataCache,
map,
isWrite::Bool,
localityHint::Int32,
isDataCache::Bool,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[]
operands = Value[memref, indices...]
owned_regions = Region[]
successors = Block[]
attributes = NamedAttribute[
namedattribute("isWrite", isWrite),
namedattribute("localityHint", localityHint),
namedattribute("isDataCache", isDataCache),
namedattribute("isWrite", Attribute(isWrite)),
namedattribute("localityHint", Attribute(localityHint)),
namedattribute("isDataCache", Attribute(isDataCache)),
namedattribute("map", map),
]

Expand Down Expand Up @@ -752,7 +773,7 @@ affine.store %v0, %0[%i0 + symbol(%n), %i1 + symbol(%m)] : memref<100x100xf32>
```
"""
function store(
value::Value, memref::Value, indices::Vector{Value}; map, location=Location()
value::Value, memref::Value, indices::Vector{Value}; map::Attribute, location=Location()
)
op_ty_results = IR.Type[]
operands = Value[value, memref, indices...]
Expand Down Expand Up @@ -812,7 +833,11 @@ TODOs:
(see [vector.transfer_read](../Vector/#vectortransfer_read-mlirvectortransferreadop)).
"""
function vector_load(
memref::Value, indices::Vector{Value}; result::IR.Type, map, location=Location()
memref::Value,
indices::Vector{Value};
result::IR.Type,
map::Attribute,
location=Location(),
)
op_ty_results = IR.Type[result,]
operands = Value[memref, indices...]
Expand Down Expand Up @@ -874,7 +899,7 @@ TODOs:
(see [vector.transfer_write](../Vector/#vectortransfer_write-mlirvectortransferwriteop)).
"""
function vector_store(
value::Value, memref::Value, indices::Vector{Value}; map, location=Location()
value::Value, memref::Value, indices::Vector{Value}; map::Attribute, location=Location()
)
op_ty_results = IR.Type[]
operands = Value[value, memref, indices...]
Expand Down
Loading
Loading