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

Update LLVM to 17 #330

Merged
merged 8 commits into from
Sep 28, 2023
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
430 changes: 201 additions & 229 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ cargo add melior

### Dependencies

[LLVM/MLIR 16](https://llvm.org/) needs to be installed on your system. On Linux and macOS, you can install it via [Homebrew](https://brew.sh).
[LLVM/MLIR 17](https://llvm.org/) needs to be installed on your system. On Linux and macOS, you can install it via [Homebrew](https://brew.sh).

```sh
brew install llvm@16
brew install llvm@17
```

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ proc-macro2 = "1"
quote = "1"
regex = "1.9.5"
syn = { version = "2", features = ["full"] }
tblgen = { version = "0.3.0", features = ["llvm16-0"] }
tblgen = { version = "0.3.0", features = ["llvm17-0"], default-features = false }
unindent = "0.2.3"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion macro/src/dialect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use quote::quote;
use std::{env, fmt::Display, path::Path, process::Command, str};
use tblgen::{record::Record, record_keeper::RecordKeeper, TableGenParser};

const LLVM_MAJOR_VERSION: usize = 16;
const LLVM_MAJOR_VERSION: usize = 17;

pub fn generate_dialect(input: DialectInput) -> Result<TokenStream, Box<dyn std::error::Error>> {
let mut td_parser = TableGenParser::new();
Expand Down
3 changes: 2 additions & 1 deletion macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pub fn conversion_passes(stream: TokenStream) -> TokenStream {
convert_result(pass::generate(identifiers.identifiers(), |mut name| {
name = name.strip_prefix("Conversion").unwrap();
name = name.strip_prefix("Convert").unwrap_or(name);
name.strip_suffix("ConversionPass").unwrap_or(name).into()
name = name.strip_suffix("ConversionPass").unwrap_or(name);
name.strip_suffix("Pass").unwrap_or(name).into()
}))
}

Expand Down
4 changes: 2 additions & 2 deletions melior/src/dialect/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ mod tests {
.add_pass(pass::conversion::create_arith_to_llvm());
pass_manager
.nested_under("func.func")
.add_pass(pass::conversion::create_index_to_llvm_pass());
.add_pass(pass::conversion::create_index_to_llvm());
pass_manager.add_pass(pass::conversion::create_scf_to_control_flow());
pass_manager.add_pass(pass::conversion::create_control_flow_to_llvm());
pass_manager.add_pass(pass::conversion::create_mem_ref_to_llvm());
pass_manager.add_pass(pass::conversion::create_finalize_mem_ref_to_llvm());

assert_eq!(pass_manager.run(module), Ok(()));
assert!(module.as_operation().verify());
Expand Down
2 changes: 1 addition & 1 deletion melior/src/dialect/ods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ melior_macro::dialect! {
}
melior_macro::dialect! {
name: "amdgpu",
tablegen: r#"include "mlir/Dialect/AMDGPU/AMDGPU.td""#
tablegen: r#"include "mlir/Dialect/AMDGPU/IR/AMDGPU.td""#
}
melior_macro::dialect! {
name: "arith",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: module.as_operation()
---
module attributes {llvm.data_layout = ""} {
llvm.func @foo(%arg0: !llvm.struct<(i64)>) {
%0 = "llvm.mlir.poison"() : () -> !llvm.struct<(i64)>
%0 = llvm.mlir.poison : !llvm.struct<(i64)>
llvm.return
}
}
Expand Down
29 changes: 14 additions & 15 deletions melior/src/pass/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,47 @@ melior_macro::conversion_passes!(
mlirCreateConversionConvertAMDGPUToROCDL,
mlirCreateConversionConvertArithToSPIRV,
mlirCreateConversionConvertArmNeon2dToIntr,
mlirCreateConversionConvertAsyncToLLVM,
mlirCreateConversionConvertAsyncToLLVMPass,
mlirCreateConversionConvertBufferizationToMemRef,
mlirCreateConversionConvertComplexToLibm,
mlirCreateConversionConvertComplexToLLVM,
mlirCreateConversionConvertComplexToLLVMPass,
mlirCreateConversionConvertComplexToStandard,
mlirCreateConversionConvertControlFlowToLLVM,
mlirCreateConversionConvertControlFlowToLLVMPass,
mlirCreateConversionConvertControlFlowToSPIRV,
mlirCreateConversionConvertFuncToLLVM,
mlirCreateConversionConvertFuncToLLVMPass,
mlirCreateConversionConvertFuncToSPIRV,
mlirCreateConversionConvertGpuLaunchFuncToVulkanLaunchFunc,
mlirCreateConversionConvertGpuOpsToNVVMOps,
mlirCreateConversionConvertGpuOpsToROCDLOps,
mlirCreateConversionConvertGPUToSPIRV,
mlirCreateConversionConvertIndexToLLVMPass,
mlirCreateConversionConvertLinalgToLLVM,
mlirCreateConversionConvertLinalgToLLVMPass,
mlirCreateConversionConvertLinalgToStandard,
mlirCreateConversionConvertMathToFuncs,
mlirCreateConversionConvertMathToLibm,
mlirCreateConversionConvertMathToLLVM,
mlirCreateConversionConvertMathToLLVMPass,
mlirCreateConversionConvertMathToSPIRV,
mlirCreateConversionConvertMemRefToSPIRV,
mlirCreateConversionConvertNVGPUToNVVM,
mlirCreateConversionConvertOpenACCToLLVM,
mlirCreateConversionConvertNVGPUToNVVMPass,
mlirCreateConversionConvertOpenACCToSCF,
mlirCreateConversionConvertOpenMPToLLVM,
mlirCreateConversionConvertOpenMPToLLVMPass,
mlirCreateConversionConvertParallelLoopToGpu,
mlirCreateConversionConvertPDLToPDLInterp,
mlirCreateConversionConvertSCFToOpenMP,
mlirCreateConversionConvertSCFToOpenMPPass,
mlirCreateConversionConvertShapeConstraints,
mlirCreateConversionConvertShapeToStandard,
mlirCreateConversionConvertSPIRVToLLVM,
mlirCreateConversionConvertSPIRVToLLVMPass,
mlirCreateConversionConvertTensorToLinalg,
mlirCreateConversionConvertTensorToSPIRV,
mlirCreateConversionConvertVectorToGPU,
mlirCreateConversionConvertVectorToLLVM,
mlirCreateConversionConvertVectorToLLVMPass,
mlirCreateConversionConvertVectorToSCF,
mlirCreateConversionConvertVectorToSPIRV,
mlirCreateConversionConvertVulkanLaunchFuncToVulkanCalls,
mlirCreateConversionConvertVulkanLaunchFuncToVulkanCallsPass,
mlirCreateConversionGpuToLLVMConversionPass,
mlirCreateConversionLowerHostCodeToLLVM,
mlirCreateConversionLowerHostCodeToLLVMPass,
mlirCreateConversionMapMemRefStorageClass,
mlirCreateConversionMemRefToLLVMConversionPass,
mlirCreateConversionFinalizeMemRefToLLVMConversionPass,
mlirCreateConversionReconcileUnrealizedCasts,
mlirCreateConversionSCFToControlFlow,
mlirCreateConversionSCFToSPIRV,
Expand Down
1 change: 0 additions & 1 deletion melior/src/pass/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

melior_macro::gpu_passes!(
// spell-checker: disable-next-line
mlirCreateGPUGPULowerMemorySpaceAttributesPass,
mlirCreateGPUGpuAsyncRegionPass,
mlirCreateGPUGpuKernelOutlining,
mlirCreateGPUGpuLaunchSinkIndexComputations,
Expand Down
9 changes: 5 additions & 4 deletions melior/src/pass/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use mlir_sys::{
mlirPassManagerAddOwnedPass, mlirPassManagerCreate, mlirPassManagerDestroy,
mlirPassManagerEnableIRPrinting, mlirPassManagerEnableVerifier,
mlirPassManagerGetAsOpPassManager, mlirPassManagerGetNestedUnder, mlirPassManagerRun,
mlirPassManagerGetAsOpPassManager, mlirPassManagerGetNestedUnder, mlirPassManagerRunOnOp,
MlirPassManager,
};
use std::marker::PhantomData;
Expand Down Expand Up @@ -54,8 +54,9 @@ impl<'c> PassManager<'c> {

/// Runs passes added to a pass manager against a module.
pub fn run(&self, module: &mut Module) -> Result<(), Error> {
let result =
LogicalResult::from_raw(unsafe { mlirPassManagerRun(self.raw, module.to_raw()) });
let result = LogicalResult::from_raw(unsafe {
mlirPassManagerRunOnOp(self.raw, module.as_operation().to_raw())
});

if result.is_success() {
Ok(())
Expand Down Expand Up @@ -201,7 +202,7 @@ mod tests {

assert_eq!(
manager.as_operation_pass_manager().to_string(),
"builtin.module(func.func(print-op-stats{json=false}))"
"any(func.func(print-op-stats{json=false}))"
);
assert_eq!(
function_manager.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion tools/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

llvm_version=16
llvm_version=17

if [ -n "$CI" ]; then
brew install --overwrite [email protected]
Expand Down