Skip to content

Commit 14afac0

Browse files
author
vporpo
authored
[SandboxIR][NFC] Move Argument into a separate file (#110174)
1 parent a82fd98 commit 14afac0

File tree

6 files changed

+66
-29
lines changed

6 files changed

+66
-29
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===- Argument.h -----------------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_SANDBOXIR_ARGUMENT_H
10+
#define LLVM_SANDBOXIR_ARGUMENT_H
11+
12+
#include "llvm/IR/Argument.h"
13+
#include "llvm/SandboxIR/Value.h"
14+
15+
namespace llvm::sandboxir {
16+
17+
/// Argument of a sandboxir::Function.
18+
class Argument : public sandboxir::Value {
19+
Argument(llvm::Argument *Arg, sandboxir::Context &Ctx)
20+
: Value(ClassID::Argument, Arg, Ctx) {}
21+
friend class Context; // For constructor.
22+
23+
public:
24+
static bool classof(const sandboxir::Value *From) {
25+
return From->getSubclassID() == ClassID::Argument;
26+
}
27+
#ifndef NDEBUG
28+
void verify() const final {
29+
assert(isa<llvm::Argument>(Val) && "Expected Argument!");
30+
}
31+
void printAsOperand(raw_ostream &OS) const;
32+
void dumpOS(raw_ostream &OS) const final;
33+
#endif
34+
};
35+
36+
} // namespace llvm::sandboxir
37+
38+
#endif // LLVM_SANDBOXIR_ARGUMENT_H

llvm/include/llvm/SandboxIR/SandboxIR.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
#include "llvm/IR/PatternMatch.h"
110110
#include "llvm/IR/User.h"
111111
#include "llvm/IR/Value.h"
112+
#include "llvm/SandboxIR/Argument.h"
112113
#include "llvm/SandboxIR/Context.h"
113114
#include "llvm/SandboxIR/Module.h"
114115
#include "llvm/SandboxIR/Tracker.h"
@@ -189,25 +190,6 @@ class CmpInst;
189190
class ICmpInst;
190191
class FCmpInst;
191192

192-
/// Argument of a sandboxir::Function.
193-
class Argument : public sandboxir::Value {
194-
Argument(llvm::Argument *Arg, sandboxir::Context &Ctx)
195-
: sandboxir::Value(ClassID::Argument, Arg, Ctx) {}
196-
friend class Context; // For constructor.
197-
198-
public:
199-
static bool classof(const sandboxir::Value *From) {
200-
return From->getSubclassID() == ClassID::Argument;
201-
}
202-
#ifndef NDEBUG
203-
void verify() const final {
204-
assert(isa<llvm::Argument>(Val) && "Expected Argument!");
205-
}
206-
void printAsOperand(raw_ostream &OS) const;
207-
void dumpOS(raw_ostream &OS) const final;
208-
#endif
209-
};
210-
211193
class Constant : public sandboxir::User {
212194
protected:
213195
Constant(llvm::Constant *C, sandboxir::Context &SBCtx)

llvm/include/llvm/SandboxIR/Value.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace llvm::sandboxir {
1616

1717
// Forward declare all classes to avoid some MSVC build errors.
1818
#define DEF_INSTR(ID, OPC, CLASS) class CLASS;
19+
#define DEF_CONST(ID, CLASS) class CLASS;
20+
#define DEF_USER(ID, CLASS) class CLASS;
1921
#include "llvm/SandboxIR/SandboxIRValues.def"
2022
class Context;
2123
class FuncletPadInst;

llvm/lib/SandboxIR/Argument.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===- Argument.cpp - The function Argument class of Sandbox IR -----------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "llvm/SandboxIR/Argument.h"
10+
11+
namespace llvm::sandboxir {
12+
13+
#ifndef NDEBUG
14+
void Argument::printAsOperand(raw_ostream &OS) const {
15+
printAsOperandCommon(OS);
16+
}
17+
void Argument::dumpOS(raw_ostream &OS) const {
18+
dumpCommonPrefix(OS);
19+
dumpCommonSuffix(OS);
20+
}
21+
#endif // NDEBUG
22+
23+
} // namespace llvm::sandboxir

llvm/lib/SandboxIR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_llvm_component_library(LLVMSandboxIR
2+
Argument.cpp
23
Context.cpp
34
Module.cpp
45
Pass.cpp

llvm/lib/SandboxIR/SandboxIR.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "llvm/ADT/SmallPtrSet.h"
1111
#include "llvm/ADT/SmallVector.h"
1212
#include "llvm/IR/Constants.h"
13+
#include "llvm/SandboxIR/Argument.h"
1314
#include "llvm/Support/Debug.h"
1415
#include <sstream>
1516

@@ -105,16 +106,6 @@ int OperandUseIterator::operator-(const OperandUseIterator &Other) const {
105106
return ThisOpNo - OtherOpNo;
106107
}
107108

108-
#ifndef NDEBUG
109-
void Argument::printAsOperand(raw_ostream &OS) const {
110-
printAsOperandCommon(OS);
111-
}
112-
void Argument::dumpOS(raw_ostream &OS) const {
113-
dumpCommonPrefix(OS);
114-
dumpCommonSuffix(OS);
115-
}
116-
#endif // NDEBUG
117-
118109
BBIterator &BBIterator::operator++() {
119110
auto ItE = BB->end();
120111
assert(It != ItE && "Already at end!");

0 commit comments

Comments
 (0)