-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[xllvm] Add support for multi-result intrinsics (#1470)
- Loading branch information
Showing
5 changed files
with
106 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===- XLLVMTypeConstraints.td - XLLVM type constraints. --*- tablegen -*-====// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// Defines type constraints for LLVM types used in XLLVM intrinsic op | ||
// definitions. | ||
//===----------------------------------------------------------------------===// | ||
|
||
|
||
#ifndef AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD | ||
#define AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD | ||
|
||
class EnumeratedType<Type ty, int idx> { | ||
Type type = ty; | ||
int index = idx; | ||
} | ||
|
||
class EnumerateTypeListFrom<list<Type> tlist, int from = 0> { | ||
list<EnumeratedType> sequence = | ||
!if(!empty(tlist), [], | ||
!listconcat( | ||
[EnumeratedType<!head(tlist), from>], | ||
EnumerateTypeListFrom<!tail(tlist), !add(from, 1)>.sequence | ||
)); | ||
} | ||
|
||
class LLVM_StructOf<list<Type> structTypes> : | ||
Type< | ||
And<[LLVM_AnyStruct.predicate, | ||
CPred<"cast<::mlir::LLVM::LLVMStructType>($_self).getBody().size() == " # !size(structTypes)>, | ||
And<!foreach(enumTy, EnumerateTypeListFrom<structTypes>.sequence, | ||
SubstLeaves<"$_self", | ||
"cast<::mlir::LLVM::LLVMStructType>($_self).getBody()[" # enumTy.index # "]", | ||
enumTy.type.predicate> | ||
) | ||
> | ||
]>, | ||
"an LLVM struct of {" # !interleave(!foreach(ty, structTypes, ty.summary), "; ") # "}" | ||
>; | ||
|
||
#endif // AIE_DIALECT_XLLVM_IR_XLLVMTYPECONSTRAINTS_TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: aie-opt %s -split-input-file -verify-diagnostics | ||
|
||
func.func @invalidStructType(%A : vector<32xbf16>, %B : vector<32xbf16>) | ||
-> vector<16xbf16> { | ||
// expected-error @+1 {{'res' is an LLVM struct of {vector of bfloat16 type values of length 32; 32-bit signless integer}} | ||
%rs = "xllvm.intr.aie2.vmax.ltbf16"(%A, %B) : | ||
(vector<32xbf16>, vector<32xbf16>) -> !llvm.struct<(vector<16xbf16>, i32)> | ||
%rv = llvm.extractvalue %rs[0] : !llvm.struct<(vector<16xbf16>, i32)> | ||
return %rv : vector<16xbf16> | ||
} |