Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
36 changes: 36 additions & 0 deletions include/mqt-core/qasm3/DebugInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
* Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

#pragma once

#include <cstddef>
#include <memory>
#include <string>
#include <utility>

namespace qasm3 {

struct DebugInfo {
size_t line;
size_t column;
std::string filename;
std::shared_ptr<DebugInfo> parent;

DebugInfo(const size_t l, const size_t c, std::string file,
std::shared_ptr<DebugInfo> parentDebugInfo = nullptr)
: line(l), column(c), filename(std::move(std::move(file))),
parent(std::move(parentDebugInfo)) {}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

[[nodiscard]] std::string toString() const {
return filename + ":" + std::to_string(line) + ":" + std::to_string(column);
}
};

} // namespace qasm3
Comment thread
coderabbitai[bot] marked this conversation as resolved.
2 changes: 1 addition & 1 deletion include/mqt-core/qasm3/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#pragma once

#include "Statement.hpp"
#include "DebugInfo.hpp"

#include <exception>
#include <memory>
Expand Down
17 changes: 1 addition & 16 deletions include/mqt-core/qasm3/Statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include "DebugInfo.hpp" // IWYU pragma: export
#include "Statement_fwd.hpp" // IWYU pragma: export
#include "Types_fwd.hpp"
#include "ir/Permutation.hpp"
Expand All @@ -31,22 +32,6 @@ enum ComparisonKind : std::uint8_t;
namespace qasm3 {
class InstVisitor;

struct DebugInfo {
size_t line;
size_t column;
std::string filename;
std::shared_ptr<DebugInfo> parent;

DebugInfo(const size_t l, const size_t c, std::string file,
std::shared_ptr<DebugInfo> parentDebugInfo = nullptr)
: line(l), column(c), filename(std::move(std::move(file))),
parent(std::move(parentDebugInfo)) {}

[[nodiscard]] std::string toString() const {
return filename + ":" + std::to_string(line) + ":" + std::to_string(column);
}
};

// Expressions
class Expression {
public:
Expand Down
6 changes: 4 additions & 2 deletions mlir/include/mlir/Dialect/QC/Translation/TranslateQASM3ToQC.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace qc {
* @brief Translate an OpenQASM 3 program to a QC program.
*
* @param sourceMgr Source manager containing the OpenQASM3 program.
* @param context MLIRContext to create the module in.
* @param context The MLIRContext to create the module in.
* @return A module containing the QC program.
*/
[[nodiscard]] OwningOpRef<ModuleOp>
translateQASM3ToQC(llvm::SourceMgr& sourceMgr, MLIRContext* context);
Expand All @@ -35,7 +36,8 @@ translateQASM3ToQC(llvm::SourceMgr& sourceMgr, MLIRContext* context);
* @brief Translate an OpenQASM 3 program to a QC program.
*
* @param source String containing the OpenQASM3 program.
* @param context MLIRContext to create the module in.
* @param context The MLIRContext to create the module in.
* @return A module containing the QC program.
*/
[[nodiscard]] OwningOpRef<ModuleOp> translateQASM3ToQC(StringRef source,
MLIRContext* context);
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/QC/Translation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_mlir_library(
MLIRQCTranslation
TranslateQuantumComputationToQC.cpp
TranslateQASM3ToQC.cpp
QASM3Parser.cpp
LINK_LIBS
MLIRArithDialect
MLIRFuncDialect
Expand Down
Loading
Loading