[llvm] [SandboxIR] Add more functions to sandboxir:Instruction class. (PR #110050)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 15:23:43 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c8365feed7af6d17cd2cc04cdc7fe0247f87e9c8 011176fe33cc6b01c3d37defc6e1efa57f4170e7 --extensions h,cpp -- llvm/include/llvm/SandboxIR/SandboxIR.h llvm/unittests/SandboxIR/SandboxIRTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h
index 81dc7d498c..6874f0ab89 100644
--- a/llvm/include/llvm/SandboxIR/SandboxIR.h
+++ b/llvm/include/llvm/SandboxIR/SandboxIR.h
@@ -1942,15 +1942,13 @@ public:
/// state to allow for new SandboxIR-specific instructions.
Opcode getOpcode() const { return Opc; }
- const char *getOpcodeName() const {
- return getOpcodeName(Opc);
- }
+ const char *getOpcodeName() const { return getOpcodeName(Opc); }
- // Note that these functions below are calling into llvm::Instruction.
+ // Note that these functions below are calling into llvm::Instruction.
// A sandbox IR instruction could introduce a new opcode that could change the
- // behavior of one of these functions. It is better that these functions are only
- // added as needed and new sandbox IR instructions must explicitly check if any
- // of these functions could have a different behavior.
+ // behavior of one of these functions. It is better that these functions are
+ // only added as needed and new sandbox IR instructions must explicitly check
+ // if any of these functions could have a different behavior.
bool isTerminator() const {
return cast<llvm::Instruction>(Val)->isTerminator();
@@ -1962,22 +1960,32 @@ public:
}
bool isShift() const { return cast<llvm::Instruction>(Val)->isShift(); }
bool isCast() const { return cast<llvm::Instruction>(Val)->isCast(); }
- bool isFuncletPad() const { return cast<llvm::Instruction>(Val)->isFuncletPad(); }
- bool isSpecialTerminator() const { return cast<llvm::Instruction>(Val)->isSpecialTerminator(); }
- bool isOnlyUserOfAnyOperand() const { return cast<llvm::Instruction>(Val)->isOnlyUserOfAnyOperand(); }
- bool isLogicalShift() const { return cast<llvm::Instruction>(Val)->isLogicalShift(); }
+ bool isFuncletPad() const {
+ return cast<llvm::Instruction>(Val)->isFuncletPad();
+ }
+ bool isSpecialTerminator() const {
+ return cast<llvm::Instruction>(Val)->isSpecialTerminator();
+ }
+ bool isOnlyUserOfAnyOperand() const {
+ return cast<llvm::Instruction>(Val)->isOnlyUserOfAnyOperand();
+ }
+ bool isLogicalShift() const {
+ return cast<llvm::Instruction>(Val)->isLogicalShift();
+ }
//===--------------------------------------------------------------------===//
// Metadata manipulation.
//===--------------------------------------------------------------------===//
/// Return true if the instruction has any metadata attached to it.
- bool hasMetadata() const { return cast<llvm::Instruction>(Val)->hasMetadata(); }
+ bool hasMetadata() const {
+ return cast<llvm::Instruction>(Val)->hasMetadata();
+ }
/// Return true if this instruction has metadata attached to it other than a
/// debug location.
bool hasMetadataOtherThanDebugLoc() const {
- return cast<llvm::Instruction>(Val)->hasMetadataOtherThanDebugLoc();
+ return cast<llvm::Instruction>(Val)->hasMetadataOtherThanDebugLoc();
}
/// Return true if this instruction has the given type of metadata attached.
@@ -1991,7 +1999,7 @@ public:
return cast<llvm::Instruction>(Val)->getMetadata(KindID);
}
- /// Get the metadata of given kind attached to this Instruction.
+ /// Get the metadata of given kind attached to this Instruction.
/// If the metadata is not found then return null.
MDNode *getMetadata(StringRef Kind) const {
return cast<llvm::Instruction>(Val)->getMetadata(Kind);
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index acb5fd38e2..cb58d9757c 100644
--- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp
+++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
@@ -1872,7 +1872,9 @@ bb1:
EXPECT_EQ(I1->getOpcodeName(), "Sub");
EXPECT_EQ(Ret->getOpcodeName(), "Ret");
- EXPECT_EQ(sandboxir::Instruction::getOpcodeName(sandboxir::Instruction::Opcode::Alloca), "Alloca");
+ EXPECT_EQ(sandboxir::Instruction::getOpcodeName(
+ sandboxir::Instruction::Opcode::Alloca),
+ "Alloca");
// Check moveBefore(I).
I1->moveBefore(I0);
@@ -1953,9 +1955,11 @@ bb1:
// Check hasMetadata().
EXPECT_EQ(LLVMI.hasMetadata(), I.hasMetadata());
// Check hasMetadataOtherThanDebugLoc().
- EXPECT_EQ(LLVMI.hasMetadataOtherThanDebugLoc(), I.hasMetadataOtherThanDebugLoc());
+ EXPECT_EQ(LLVMI.hasMetadataOtherThanDebugLoc(),
+ I.hasMetadataOtherThanDebugLoc());
// Check getMetadata(unsigned).
- EXPECT_EQ(LLVMI.getMetadata(LLVMContext::MD_dbg), I.getMetadata(LLVMContext::MD_dbg));
+ EXPECT_EQ(LLVMI.getMetadata(LLVMContext::MD_dbg),
+ I.getMetadata(LLVMContext::MD_dbg));
// Check getMetadata(StringRef).
EXPECT_EQ(LLVMI.getMetadata("dbg"), I.getMetadata("dbg"));
// Check isAssociative().
``````````
</details>
https://github.com/llvm/llvm-project/pull/110050
More information about the llvm-commits
mailing list