Skip to content
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
38 changes: 38 additions & 0 deletions llvm/include/llvm/SandboxIR/Argument.h
Original file line number Diff line number Diff line change
@@ -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
20 changes: 1 addition & 19 deletions llvm/include/llvm/SandboxIR/SandboxIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/SandboxIR/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions llvm/lib/SandboxIR/Argument.cpp
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions llvm/lib/SandboxIR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_llvm_component_library(LLVMSandboxIR
Argument.cpp
Context.cpp
Module.cpp
Pass.cpp
Expand Down
11 changes: 1 addition & 10 deletions llvm/lib/SandboxIR/SandboxIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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!");
Expand Down
Loading