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
16 changes: 16 additions & 0 deletions llvm/include/llvm/SandboxIR/SandboxIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,22 @@ class Instruction : public sandboxir::User {
/// \Returns this Instruction's opcode. Note that SandboxIR has its own opcode
/// state to allow for new SandboxIR-specific instructions.
Opcode getOpcode() const { return Opc; }

// TODO: Missing function getOpcodeName().

bool isTerminator() const {
return cast<llvm::Instruction>(Val)->isTerminator();
}
bool isUnaryOp() const { return cast<llvm::Instruction>(Val)->isUnaryOp(); }
bool isBinaryOp() const { return cast<llvm::Instruction>(Val)->isBinaryOp(); }
bool isIntDivRem() const {
return cast<llvm::Instruction>(Val)->isIntDivRem();
}
bool isShift() const { return cast<llvm::Instruction>(Val)->isShift(); }
bool isCast() const { return cast<llvm::Instruction>(Val)->isCast(); }

// TODO: More missing functions

/// Detach this from its parent BasicBlock without deleting it.
void removeFromParent();
/// Detach this Value from its parent and delete it.
Expand Down
13 changes: 13 additions & 0 deletions llvm/unittests/SandboxIR/SandboxIRTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,7 @@ define void @foo(i8 %v1, ptr %ptr) {
store volatile i8 %ld0, ptr %ptr
%atomicrmw = atomicrmw add ptr %ptr, i8 %v1 acquire
%udiv = udiv i8 %ld0, %v1
%urem = urem i8 %ld0, %v1
call void @foo()
ret void
}
Expand Down Expand Up @@ -1861,6 +1862,18 @@ define void @foo(i8 %v1, ptr %ptr) {

for (auto &LLVMI : *LLVMBB1) {
auto &I = cast<sandboxir::Instruction>(*Ctx.getValue(&LLVMI));
// Check isTerminator().
EXPECT_EQ(LLVMI.isTerminator(), I.isTerminator());
// Check isUnaryOp().
EXPECT_EQ(LLVMI.isUnaryOp(), I.isUnaryOp());
// Check isBinaryOp().
EXPECT_EQ(LLVMI.isBinaryOp(), I.isBinaryOp());
// Check isIntDivRem().
EXPECT_EQ(LLVMI.isIntDivRem(), I.isIntDivRem());
// Check isShift().
EXPECT_EQ(LLVMI.isShift(), I.isShift());
// Check isCast().
EXPECT_EQ(LLVMI.isCast(), I.isCast());
// Check isAssociative().
EXPECT_EQ(LLVMI.isAssociative(), I.isAssociative());
// Check isCommutative().
Expand Down