Commit 08fa0e55 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding initial mlir work

parent bd8b3029
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -3,6 +3,28 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12)
    cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()


if(POLICY CMP0068)
  cmake_policy(SET CMP0068 NEW)
  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
endif()

if(POLICY CMP0075)
  cmake_policy(SET CMP0075 NEW)
endif()

if(POLICY CMP0077)
  cmake_policy(SET CMP0077 NEW)
endif()

if(POLICY CMP0057)
  cmake_policy(SET CMP0057 NEW)
endif()

if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

if (NOT XACC_DIR)
  set(XACC_DIR "$ENV{HOME}/.xacc")
endif()
@@ -15,7 +37,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)

project(qcor LANGUAGES CXX)
project(qcor LANGUAGES CXX C)

option(QCOR_BUILD_TESTS "Build qcor tests" OFF)

@@ -27,8 +49,8 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
  message( STATUS "QCOR GIT hash: ${QCOR_BUILD_VERSION}")
endif()

find_package(Clang 10.0.0 REQUIRED)
find_package(XACC REQUIRED)
find_package(Clang 10.0.0 REQUIRED)

configure_file("${CMAKE_SOURCE_DIR}/cmake/qcor_config.hpp.in"
               "${CMAKE_BINARY_DIR}/qcor_config.hpp")
@@ -38,6 +60,7 @@ add_subdirectory(handlers)
add_subdirectory(runtime)
add_subdirectory(tools)
add_subdirectory(lib)
add_subdirectory(mlir)

if (QCOR_BUILD_TESTS)
  add_subdirectory(examples)

mlir/CMakeLists.txt

0 → 100644
+29 −0
Original line number Diff line number Diff line
# Need to make sure to use the separate MLIR install
set(LLVM_ROOT ${MLIR_DIR})
find_package(MLIR REQUIRED CONFIG)

message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})

list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
message(STATUS "MLIR HELLO ${LLVM_INCLUDE_DIRS}")
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
link_directories(${LLVM_BUILD_LIBRARY_DIR})

add_subdirectory(dialect)
add_subdirectory(parsers)
#add_subdirectory(transforms)

add_subdirectory(tests)

mlir/README.md

0 → 100644
+19 −0
Original line number Diff line number Diff line
# EXPERIMENTAL!!! Prototype Quantum MLIR Dialect

## Building
As of now, we need a separate MLIR install
```bash
git clone https://github.com/llvm/llvm-project.git llvm_mlir
mkdir llvm_mlir/build
cd llvm_mlir/build
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_INSTALL_PREFIX=$HOME/.mlir

cmake --build . --target install
```
Just add `-DMLIR_DIR=$HOME/.mlir/lib/cmake/mlir` to CMake call for building qcor.
+5 −0
Original line number Diff line number Diff line
add_mlir_dialect_library(quantum-dialect
        quantum_dialect.cpp
	LINK_LIBS PUBLIC
	MLIRIR
	)
+571 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading