[llvm] 14afac0 - [SandboxIR][NFC] Move Argument into a separate file (#110174)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 16:37:29 PDT 2024
Author: vporpo
Date: 2024-09-26T16:37:24-07:00
New Revision: 14afac0d1a5d4d64a7d9622b78dc38ba5c925c56
URL: https://github.com/llvm/llvm-project/commit/14afac0d1a5d4d64a7d9622b78dc38ba5c925c56
DIFF: https://github.com/llvm/llvm-project/commit/14afac0d1a5d4d64a7d9622b78dc38ba5c925c56.diff
LOG: [SandboxIR][NFC] Move Argument into a separate file (#110174)
Added:
llvm/include/llvm/SandboxIR/Argument.h
llvm/lib/SandboxIR/Argument.cpp
Modified:
llvm/include/llvm/SandboxIR/SandboxIR.h
llvm/include/llvm/SandboxIR/Value.h
llvm/lib/SandboxIR/CMakeLists.txt
llvm/lib/SandboxIR/SandboxIR.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/SandboxIR/Argument.h b/llvm/include/llvm/SandboxIR/Argument.h
new file mode 100644
index 00000000000000..aed886e8f22f28
--- /dev/null
+++ b/llvm/include/llvm/SandboxIR/Argument.h
@@ -0,0 +1,38 @@
+//===- Argument.h -----------------------------------------------*- 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 LLVM_SANDBOXIR_ARGUMENT_H
+#define LLVM_SANDBOXIR_ARGUMENT_H
+
+#include "llvm/IR/Argument.h"
+#include "llvm/SandboxIR/Value.h"
+
+namespace llvm::sandboxir {
+
+/// Argument of a sandboxir::Function.
+class Argument : public sandboxir::Value {
+ Argument(llvm::Argument *Arg, sandboxir::Context &Ctx)
+ : Value(ClassID::Argument, Arg, Ctx) {}
+ friend class Context; // For constructor.
+
+public:
+ static bool classof(const sandboxir::Value *From) {
+ return From->getSubclassID() == ClassID::Argument;
+ }
+#ifndef NDEBUG
+ void verify() const final {
+ assert(isa<llvm::Argument>(Val) && "Expected Argument!");
+ }
+ void printAsOperand(raw_ostream &OS) const;
+ void dumpOS(raw_ostream &OS) const final;
+#endif
+};
+
+} // namespace llvm::sandboxir
+
+#endif // LLVM_SANDBOXIR_ARGUMENT_H
diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h
index 3d206bca9eae6c..66de9ee078d619 100644
--- a/llvm/include/llvm/SandboxIR/SandboxIR.h
+++ b/llvm/include/llvm/SandboxIR/SandboxIR.h
@@ -109,6 +109,7 @@
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
+#include "llvm/SandboxIR/Argument.h"
#include "llvm/SandboxIR/Context.h"
#include "llvm/SandboxIR/Module.h"
#include "llvm/SandboxIR/Tracker.h"
@@ -189,25 +190,6 @@ class CmpInst;
class ICmpInst;
class FCmpInst;
-/// Argument of a sandboxir::Function.
-class Argument : public sandboxir::Value {
- Argument(llvm::Argument *Arg, sandboxir::Context &Ctx)
- : sandboxir::Value(ClassID::Argument, Arg, Ctx) {}
- friend class Context; // For constructor.
-
-public:
- static bool classof(const sandboxir::Value *From) {
- return From->getSubclassID() == ClassID::Argument;
- }
-#ifndef NDEBUG
- void verify() const final {
- assert(isa<llvm::Argument>(Val) && "Expected Argument!");
- }
- void printAsOperand(raw_ostream &OS) const;
- void dumpOS(raw_ostream &OS) const final;
-#endif
-};
-
class Constant : public sandboxir::User {
protected:
Constant(llvm::Constant *C, sandboxir::Context &SBCtx)
diff --git a/llvm/include/llvm/SandboxIR/Value.h b/llvm/include/llvm/SandboxIR/Value.h
index 5dc06c5fc39bf8..49bd9be82b0df5 100644
--- a/llvm/include/llvm/SandboxIR/Value.h
+++ b/llvm/include/llvm/SandboxIR/Value.h
@@ -16,6 +16,8 @@ namespace llvm::sandboxir {
// Forward declare all classes to avoid some MSVC build errors.
#define DEF_INSTR(ID, OPC, CLASS) class CLASS;
+#define DEF_CONST(ID, CLASS) class CLASS;
+#define DEF_USER(ID, CLASS) class CLASS;
#include "llvm/SandboxIR/SandboxIRValues.def"
class Context;
class FuncletPadInst;
diff --git a/llvm/lib/SandboxIR/Argument.cpp b/llvm/lib/SandboxIR/Argument.cpp
new file mode 100644
index 00000000000000..e35da2d1dbcb7b
--- /dev/null
+++ b/llvm/lib/SandboxIR/Argument.cpp
@@ -0,0 +1,23 @@
+//===- Argument.cpp - The function Argument class of Sandbox IR -----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/SandboxIR/Argument.h"
+
+namespace llvm::sandboxir {
+
+#ifndef NDEBUG
+void Argument::printAsOperand(raw_ostream &OS) const {
+ printAsOperandCommon(OS);
+}
+void Argument::dumpOS(raw_ostream &OS) const {
+ dumpCommonPrefix(OS);
+ dumpCommonSuffix(OS);
+}
+#endif // NDEBUG
+
+} // namespace llvm::sandboxir
diff --git a/llvm/lib/SandboxIR/CMakeLists.txt b/llvm/lib/SandboxIR/CMakeLists.txt
index 6386fc908388a0..d9259db970da58 100644
--- a/llvm/lib/SandboxIR/CMakeLists.txt
+++ b/llvm/lib/SandboxIR/CMakeLists.txt
@@ -1,4 +1,5 @@
add_llvm_component_library(LLVMSandboxIR
+ Argument.cpp
Context.cpp
Module.cpp
Pass.cpp
diff --git a/llvm/lib/SandboxIR/SandboxIR.cpp b/llvm/lib/SandboxIR/SandboxIR.cpp
index 92b1ebeedc55b0..12cac66480b0c3 100644
--- a/llvm/lib/SandboxIR/SandboxIR.cpp
+++ b/llvm/lib/SandboxIR/SandboxIR.cpp
@@ -10,6 +10,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Constants.h"
+#include "llvm/SandboxIR/Argument.h"
#include "llvm/Support/Debug.h"
#include <sstream>
@@ -105,16 +106,6 @@ int OperandUseIterator::operator-(const OperandUseIterator &Other) const {
return ThisOpNo - OtherOpNo;
}
-#ifndef NDEBUG
-void Argument::printAsOperand(raw_ostream &OS) const {
- printAsOperandCommon(OS);
-}
-void Argument::dumpOS(raw_ostream &OS) const {
- dumpCommonPrefix(OS);
- dumpCommonSuffix(OS);
-}
-#endif // NDEBUG
-
BBIterator &BBIterator::operator++() {
auto ItE = BB->end();
assert(It != ItE && "Already at end!");
More information about the llvm-commits
mailing list