-
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] Create dialect for external LLVM IR intrinsics (#1085)
- Loading branch information
Showing
34 changed files
with
364 additions
and
156 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
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
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,8 @@ | ||
# | ||
# 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. | ||
|
||
add_subdirectory(IR) |
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,17 @@ | ||
# | ||
# 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. | ||
|
||
add_mlir_dialect(XLLVM xllvm) | ||
add_mlir_doc(XLLVMOps XLLVMOps ./ -gen-dialect-doc -dialect=xllvm) | ||
|
||
# Add XLLVM operations | ||
set(LLVM_TARGET_DEFINITIONS XLLVMOps.td) | ||
mlir_tablegen(XLLVMOps.h.inc -gen-op-decls) | ||
mlir_tablegen(XLLVMOps.cpp.inc -gen-op-defs) | ||
add_public_tablegen_target(MLIRXLLVMOpsIncGen) | ||
mlir_tablegen(XLLVMConversions.inc -gen-llvmir-conversions) | ||
add_public_tablegen_target(MLIRXLLVMConversionsIncGen) |
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,42 @@ | ||
//===- XLLVM.td - XLLVM Dialect definition ----------------*- 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 External LLVM (XLLVM) dialect. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef AIE_DIALECT_XLLVM_IR_XLLVM_TD | ||
#define AIE_DIALECT_XLLVM_IR_XLLVM_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
include "mlir/Dialect/LLVMIR/LLVMOpBase.td" | ||
|
||
def XLLVM_Dialect : Dialect { | ||
let name = "xllvm"; | ||
let summary = "Types and operations for external LLVM dialect"; | ||
let cppNamespace = "::xilinx::xllvm"; | ||
} | ||
|
||
// Base clase for external LLVM intrinsic operations | ||
class ExtIntrOpBase<string opName, | ||
string enumName, | ||
list<Trait> traits, | ||
int numResults | ||
> : LLVM_OpBase<XLLVM_Dialect, opName, traits>, | ||
Results<!if(!gt(numResults, 0), (outs LLVM_Type:$res), (outs))> { | ||
string llvmBuilder = [{ | ||
auto *inst = ::xilinx::xllvm::createExternalLLVMIntrinsicCall(builder, | ||
moduleTranslation, &opInst, "llvm.}] # enumName # [{"); | ||
(void) inst; | ||
$res = inst; | ||
}]; | ||
string mlirBuilder = ""; | ||
list<int> llvmArgIndices = []; | ||
} | ||
|
||
#endif // AIE_DIALECT_XLLVM_IR_XLLVMDIALECT_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===- XLLVMOps.td - XLLVM dialect op definitions ---------*- 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 external LLVM (XLLVM) dialect operations. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef AIE_DIALECT_XLLVM_IR_XLLVMOPS_TD | ||
#define AIE_DIALECT_XLLVM_IR_XLLVMOPS_TD | ||
|
||
include "aie/Dialect/XLLVM/IR/XLLVM.td" | ||
|
||
// Include AIE2 intrinsics. | ||
include "aie/Dialect/XLLVM/IR/XLLVMAIE2IntrOps.td" | ||
|
||
#endif |
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,72 @@ | ||
//===- XLLVMDialect.h - External LLVM (xllvm) dialect --------------C++ -*-===// | ||
// | ||
// Part of the LLVM Project, 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the XLLVM dialect, containing LLVM intrinsic operations | ||
// for an external LLVM compiler. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef AIE_DIALECT_XLLVM_XLLVMDIALECT_H | ||
#define AIE_DIALECT_XLLVM_XLLVMDIALECT_H | ||
|
||
#include "mlir/Bytecode/BytecodeOpInterface.h" | ||
#include "mlir/Dialect/LLVMIR/LLVMAttrs.h" | ||
#include "mlir/Dialect/LLVMIR/LLVMInterfaces.h" | ||
#include "mlir/Dialect/LLVMIR/LLVMTypes.h" | ||
#include "mlir/IR/BuiltinOps.h" | ||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
#include "mlir/IR/TypeSupport.h" | ||
#include "mlir/IR/Types.h" | ||
#include "mlir/Interfaces/CallInterfaces.h" | ||
#include "mlir/Interfaces/ControlFlowInterfaces.h" | ||
#include "mlir/Interfaces/FunctionInterfaces.h" | ||
#include "mlir/Interfaces/InferTypeOpInterface.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
#include "mlir/Support/ThreadLocalCache.h" | ||
#include "mlir/Transforms/Mem2Reg.h" | ||
#include "llvm/ADT/PointerEmbeddedInt.h" | ||
#include "llvm/IR/DerivedTypes.h" | ||
#include "llvm/IR/LLVMContext.h" | ||
#include "llvm/IR/Module.h" | ||
#include "llvm/IR/Type.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "aie/Dialect/XLLVM/IR/XLLVMOps.h.inc" | ||
|
||
#include "aie/Dialect/XLLVM/IR/XLLVMDialect.h.inc" | ||
|
||
namespace llvm { | ||
|
||
class CallInst; | ||
class IRBuilderBase; | ||
class StringRef; | ||
|
||
} // namespace llvm | ||
|
||
namespace mlir { | ||
|
||
class Operation; | ||
|
||
namespace LLVM { | ||
class ModuleTranslation; | ||
} // namespace LLVM | ||
|
||
} // namespace mlir | ||
|
||
namespace xilinx::xllvm { | ||
|
||
llvm::CallInst *createExternalLLVMIntrinsicCall( | ||
llvm::IRBuilderBase &builder, | ||
mlir::LLVM::ModuleTranslation &moduleTranslation, mlir::Operation *intrOp, | ||
llvm::StringRef intrinsicName); | ||
|
||
} // namespace xilinx::xllvm | ||
|
||
#endif // AIE_DIALECT_XLLVM_XLLVMDIALECT_H |
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
Oops, something went wrong.