Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Integrate LLVM at llvm/llvm-project@e371ada4 #414

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The `emitc-opt` tool supports the following options:
| `--convert-scf-to-emitc` | Convert SCF dialect to EmitC dialect, maintaining structured control flow|
| `--convert-stablehlo-region-ops-to-emitc ` | Convert StableHLO operations containing regions to EmitC dialect. |
| `--convert-stablehlo-to-emitc ` | Convert from StableHLO dialect to EmitC dialect. |
| `--convert-arith-to-emitc ` | Convert arith dialect to EmitC dialect, replacing IndexCastOp. |
| `--convert-arith-to-emitc-ext ` | Convert arith dialect to EmitC dialect (extended). |
| `--convert-tensor-to-emitc ` | Convert tensor dialect to EmitC dialect. |
| `--convert-tosa-to-emitc ` | Convert TOSA dialect to EmitC dialect. |
| `--insert-emitc-stablehlo-include` | Insert an EmitC include for the StableHLO dialect. |
Expand Down
2 changes: 1 addition & 1 deletion build_tools/llvm_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d592c8ec8f7138dcbde6f0890d048e59cba95041
e371ada409b225ea990b5ac0d5cafea26a6046e1
8 changes: 4 additions & 4 deletions docs/arith-op-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

The table below shows the supported Arithmetic ops.

| op | supported | comment |
| :-------------------- |:------------------:| :-------------------- |
| constant | :white_check_mark: | via `emitc-translate` |
| index_cast | :heavy_check_mark: | |
| op | supported | comment |
| :-------------------- |:------------------:| :----------------------------------- |
| constant | :heavy_check_mark: | |
| index_cast | :heavy_check_mark: | local extension compared to upstream |
4 changes: 2 additions & 2 deletions include/emitc/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def ConvertStablehloToEmitC : Pass<"convert-stablehlo-to-emitc", "func::FuncOp">
let dependentDialects = ["EmitCDialect"];
}

def ConvertArithToEmitC : Pass<"convert-arith-to-emitc", "func::FuncOp"> {
let summary = "Convert arith dialect to EmitC dialect, replacing IndexCastOp.";
def ConvertArithToEmitC : Pass<"convert-arith-to-emitc-ext", "func::FuncOp"> {
let summary = "Convert arith dialect to EmitC dialect (extended).";
let constructor = "createConvertArithToEmitCPass()";
let dependentDialects = ["EmitCDialect"];
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/IR/BuiltinOps.h"
Expand Down Expand Up @@ -71,7 +72,12 @@ struct ConvertArithToEmitCPass
target.addIllegalOp<arith::IndexCastOp>();

RewritePatternSet patterns(&getContext());

TypeConverter typeConverter;
typeConverter.addConversion([](Type type) { return type; });

populateArithToEmitcPatterns(&getContext(), patterns);
populateArithToEmitCPatterns(typeConverter, patterns);

if (failed(applyPartialConversion(getOperation(), target,
std::move(patterns))))
Expand Down
2 changes: 1 addition & 1 deletion lib/Conversion/ArithToEmitC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_library(MLIRArithToEmitC
add_mlir_library(MLIRArithToEmitCExt
ArithToEmitC.cpp

DEPENDS
Expand Down
6 changes: 3 additions & 3 deletions test/Conversion/arith-to-emitc.mlir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: emitc-opt -convert-arith-to-emitc %s | FileCheck %s
// RUN: emitc-opt -convert-arith-to-emitc %s | emitc-translate --mlir-to-cpp | FileCheck %s -check-prefix=CPP
// RUN: emitc-opt -insert-emitc-arith-include -convert-arith-to-emitc %s | FileCheck %s --check-prefixes=CHECK,CHECK-INCLUDE
// RUN: emitc-opt -convert-arith-to-emitc-ext %s | FileCheck %s
// RUN: emitc-opt -convert-arith-to-emitc-ext %s | emitc-translate --mlir-to-cpp | FileCheck %s -check-prefix=CPP
// RUN: emitc-opt -insert-emitc-arith-include -convert-arith-to-emitc-ext %s | FileCheck %s --check-prefixes=CHECK,CHECK-INCLUDE
// RUN: emitc-opt -arith-to-emitc-pipeline %s | FileCheck %s --check-prefixes=CHECK,CHECK-INCLUDE

// CHECK-INCLUDE: emitc.include "emitc/arith.h"
Expand Down
12 changes: 6 additions & 6 deletions test/Conversion/tensor-to-emitc.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
// CHECK-INCLUDE: emitc.include "emitc/tensor.h"

func.func @std_extract_element(%arg0: tensor<i32>, %arg1: tensor<2xi32> ) -> () {
%0 = arith.constant 0 : index
%1 = arith.constant 1 : index
%0 = "emitc.constant"() {value = 0 : index} : () -> index
%1 = "emitc.constant"() {value = 1 : index} : () -> index
%2 = tensor.extract %arg0[] : tensor<i32>
%3 = tensor.extract %arg1[%0] : tensor<2xi32>
%4 = tensor.extract %arg1[%1] : tensor<2xi32>
return
}
// CHECK-LABEL: func @std_extract_element
// CHECK-NEXT: constant 0 : index
// CHECK-NEXT: constant 1 : index
// CHECK-NEXT: "emitc.constant"() <{value = 0 : index}> : () -> index
// CHECK-NEXT: "emitc.constant"() <{value = 1 : index}> : () -> index
// CHECK-NEXT: emitc.call_opaque "emitc::tensor::extract"(%arg0) : (tensor<i32>) -> i32
// CHECK-NEXT: emitc.call_opaque "emitc::tensor::extract"(%arg1, %c0) : (tensor<2xi32>, index) -> i32
// CHECK-NEXT: emitc.call_opaque "emitc::tensor::extract"(%arg1, %c1) : (tensor<2xi32>, index) -> i32
// CHECK-NEXT: emitc.call_opaque "emitc::tensor::extract"(%arg1, %0) : (tensor<2xi32>, index) -> i32
// CHECK-NEXT: emitc.call_opaque "emitc::tensor::extract"(%arg1, %1) : (tensor<2xi32>, index) -> i32

// CPP-LABEL: void std_extract_element(Tensor<int32_t> v1, Tensor<int32_t, 2> v2)
// CPP-NEXT: size_t v3 = 0;
Expand Down
2 changes: 1 addition & 1 deletion third_party/stablehlo
Submodule stablehlo updated 118 files
2 changes: 1 addition & 1 deletion tools/emitc-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(LIBS
MLIRSupport
MLIRIR
MLIREmitCDialect
MLIRArithToEmitC
MLIRArithToEmitCExt
MLIRTensorToEmitC
MLIRTosaToEmitC
MLIREmitCTransformsLocal
Expand Down