Skip to content

Commit

Permalink
Merge pull request #131 from Xilinx/matthias.backport_emitc
Browse files Browse the repository at this point in the history
Backport all EmitC commits
  • Loading branch information
mgehre-amd authored Mar 12, 2024
2 parents eb28bbc + 86a976b commit 15893ae
Show file tree
Hide file tree
Showing 72 changed files with 2,927 additions and 424 deletions.
3 changes: 0 additions & 3 deletions mlir/docs/Dialects/emitc.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ translating the following operations:
* `cf.cond_br`
* 'func' Dialect
* `func.call`
* `func.constant`
* `func.func`
* `func.return`
* 'arith' Dialect
* `arith.constant`
12 changes: 5 additions & 7 deletions mlir/include/mlir/Conversion/ArithToEmitC/ArithToEmitC.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
//===- ArithToEmitC.h - Convert Arith to EmitC ----------------------------===//
//===- ArithToEmitC.h - Arith to EmitC Patterns -----------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITC_H
#define MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITC_H

#include "mlir/Pass/Pass.h"

namespace mlir {
class RewritePatternSet;
class TypeConverter;

#define GEN_PASS_DECL_ARITHTOEMITCCONVERSIONPASS
#include "mlir/Conversion/Passes.h.inc"

void populateArithToEmitCConversionPatterns(RewritePatternSet &patterns);
void populateArithToEmitCPatterns(TypeConverter &typeConverter,
RewritePatternSet &patterns);
} // namespace mlir

#endif // MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITC_H
21 changes: 21 additions & 0 deletions mlir/include/mlir/Conversion/ArithToEmitC/ArithToEmitCPass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===- ArithToEmitCPass.h - Arith to EmitC Pass -----------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITCPASS_H
#define MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITCPASS_H

#include <memory>

namespace mlir {
class Pass;

#define GEN_PASS_DECL_CONVERTARITHTOEMITC
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir

#endif // MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITCPASS_H
18 changes: 18 additions & 0 deletions mlir/include/mlir/Conversion/FuncToEmitC/FuncToEmitC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===- FuncToEmitC.h - Func to EmitC Patterns -------------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITC_H
#define MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITC_H

namespace mlir {
class RewritePatternSet;

void populateFuncToEmitCPatterns(RewritePatternSet &patterns);
} // namespace mlir

#endif // MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITC_H
21 changes: 21 additions & 0 deletions mlir/include/mlir/Conversion/FuncToEmitC/FuncToEmitCPass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===- FuncToEmitCPass.h - Func to EmitC Pass -------------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITCPASS_H
#define MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITCPASS_H

#include <memory>

namespace mlir {
class Pass;

#define GEN_PASS_DECL_CONVERTFUNCTOEMITC
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir

#endif // MLIR_CONVERSION_FUNCTOEMITC_FUNCTOEMITCPASS_H
3 changes: 2 additions & 1 deletion mlir/include/mlir/Conversion/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h"
#include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
#include "mlir/Conversion/ArithToAMDGPU/ArithToAMDGPU.h"
#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
#include "mlir/Conversion/ArithToEmitC/ArithToEmitCPass.h"
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
#include "mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h"
#include "mlir/Conversion/ArmNeon2dToIntr/ArmNeon2dToIntr.h"
Expand All @@ -29,6 +29,7 @@
#include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h"
#include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRVPass.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMPass.h"
#include "mlir/Conversion/FuncToEmitC/FuncToEmitCPass.h"
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
#include "mlir/Conversion/FuncToSPIRV/FuncToSPIRVPass.h"
#include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
Expand Down
22 changes: 17 additions & 5 deletions mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,20 @@ def ArithToAMDGPUConversionPass : Pass<"convert-arith-to-amdgpu"> {
}];

let dependentDialects = ["amdgpu::AMDGPUDialect", "vector::VectorDialect"];

let options = [
Option<"saturateFP8Truncf", "saturate-fp8-truncf", "bool",
/*default=*/"false",
"Use saturating truncation for 8-bit float types">,
];
}

//===----------------------------------------------------------------------===//
// ArithToEmitC
//===----------------------------------------------------------------------===//

def ArithToEmitCConversionPass : Pass<"convert-arith-to-emitc"> {
let summary = "Convert Arith ops to EmitC ops";
let description = [{
Convert `arith` operations to operations in the `emitc` dialect.
}];
def ConvertArithToEmitC : Pass<"convert-arith-to-emitc"> {
let summary = "Convert Arith dialect to EmitC dialect";
let dependentDialects = ["emitc::EmitCDialect"];
}

Expand Down Expand Up @@ -356,6 +359,15 @@ def ConvertControlFlowToSPIRV : Pass<"convert-cf-to-spirv"> {
];
}

//===----------------------------------------------------------------------===//
// FuncToEmitC
//===----------------------------------------------------------------------===//

def ConvertFuncToEmitC : Pass<"convert-func-to-emitc", "ModuleOp"> {
let summary = "Convert Func dialect to EmitC dialect";
let dependentDialects = ["emitc::EmitCDialect"];
}

//===----------------------------------------------------------------------===//
// FuncToLLVM
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/EmitC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(IR)
add_subdirectory(Transforms)
2 changes: 2 additions & 0 deletions mlir/include/mlir/Dialect/EmitC/IR/EmitC.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
#define MLIR_DIALECT_EMITC_IR_EMITC_H

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/Dialect/EmitC/IR/EmitCTraits.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/Interfaces/CastInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"

#include "mlir/Dialect/EmitC/IR/EmitCDialect.h.inc"
Expand Down
Loading

0 comments on commit 15893ae

Please sign in to comment.