[llvm] f404207 - [SandboxIR] Implement a few Instruction member functions (#109820)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 10:12:16 PDT 2024
Author: vporpo
Date: 2024-09-24T10:12:12-07:00
New Revision: f4042077e2e3946ee35c1df8cab8237de6086480
URL: https://github.com/llvm/llvm-project/commit/f4042077e2e3946ee35c1df8cab8237de6086480
DIFF: https://github.com/llvm/llvm-project/commit/f4042077e2e3946ee35c1df8cab8237de6086480.diff
LOG: [SandboxIR] Implement a few Instruction member functions (#109820)
This patch implements a few sandboxir::Instruction predicate functions.
Added:
Modified:
llvm/include/llvm/SandboxIR/SandboxIR.h
llvm/unittests/SandboxIR/SandboxIRTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h
index d5e239e70da613..d4c907ce8327dd 100644
--- a/llvm/include/llvm/SandboxIR/SandboxIR.h
+++ b/llvm/include/llvm/SandboxIR/SandboxIR.h
@@ -1935,6 +1935,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.
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index 1fcc9cbea152cd..42df09609b675c 100644
--- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp
+++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
@@ -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
}
@@ -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().
More information about the llvm-commits
mailing list