[llvm] [RemoveDIs] Add iterator-taking constructors and Create methods (PR #82778)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 07:48:17 PST 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 be083dba95dfbbb0286d798cc06fbe021715bc03 e49779b5e5bcb016ee96d0d169bea5b263a1c9f3 -- llvm/include/llvm/IR/InstrTypes.h llvm/include/llvm/IR/Instruction.h llvm/include/llvm/IR/Instructions.h llvm/lib/IR/Instruction.cpp llvm/lib/IR/Instructions.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 4ee51cd192..87985b4ed7 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -105,8 +105,8 @@ class UnaryOperator : public UnaryInstruction {
void AssertOK();
protected:
- UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
- const Twine &Name, BasicBlock::iterator InsertBefore);
+ UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name,
+ BasicBlock::iterator InsertBefore);
UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
const Twine &Name, Instruction *InsertBefore);
UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
@@ -162,10 +162,10 @@ public:
return Create(Instruction::OPC, V, Name, I);\
}
#include "llvm/IR/Instruction.def"
-#define HANDLE_UNARY_INST(N, OPC, CLASS) \
- static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
- BasicBlock::iterator It) {\
- return Create(Instruction::OPC, V, Name, It);\
+#define HANDLE_UNARY_INST(N, OPC, CLASS) \
+ static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
+ BasicBlock::iterator It) { \
+ return Create(Instruction::OPC, V, Name, It); \
}
#include "llvm/IR/Instruction.def"
@@ -286,10 +286,10 @@ public:
return Create(Instruction::OPC, V1, V2, Name, I);\
}
#include "llvm/IR/Instruction.def"
-#define HANDLE_BINARY_INST(N, OPC, CLASS) \
- static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const Twine &Name, BasicBlock::iterator It) {\
- return Create(Instruction::OPC, V1, V2, Name, It);\
+#define HANDLE_BINARY_INST(N, OPC, CLASS) \
+ static BinaryOperator *Create##OPC(Value *V1, Value *V2, const Twine &Name, \
+ BasicBlock::iterator It) { \
+ return Create(Instruction::OPC, V1, V2, Name, It); \
}
#include "llvm/IR/Instruction.def"
@@ -642,10 +642,10 @@ public:
/// Create a ZExt or BitCast cast instruction
static CastInst *CreateZExtOrBitCast(
- Value *S, ///< The value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a ZExt or BitCast cast instruction
@@ -666,10 +666,10 @@ public:
/// Create a SExt or BitCast cast instruction
static CastInst *CreateSExtOrBitCast(
- Value *S, ///< The value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a SExt or BitCast cast instruction
@@ -698,10 +698,10 @@ public:
/// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static CastInst *CreatePointerCast(
- Value *S, ///< The pointer value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The pointer value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
@@ -722,10 +722,10 @@ public:
/// Create a BitCast or an AddrSpaceCast cast instruction.
static CastInst *CreatePointerBitCastOrAddrSpaceCast(
- Value *S, ///< The pointer value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The pointer value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a BitCast or an AddrSpaceCast cast instruction.
@@ -743,10 +743,10 @@ public:
/// destination a pointer type, creates an IntToPtr cast. Otherwise, creates
/// a bitcast.
static CastInst *CreateBitOrPointerCast(
- Value *S, ///< The pointer value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The pointer value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
@@ -764,11 +764,11 @@ public:
/// Create a ZExt, BitCast, or Trunc for int -> int casts.
static CastInst *CreateIntegerCast(
- Value *S, ///< The pointer value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- bool isSigned, ///< Whether to regard S as signed or not
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The pointer value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ bool isSigned, ///< Whether to regard S as signed or not
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a ZExt, BitCast, or Trunc for int -> int casts.
@@ -791,10 +791,10 @@ public:
/// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
static CastInst *CreateFPCast(
- Value *S, ///< The floating point value to be casted
- Type *Ty, ///< The floating point type to cast to
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The floating point value to be casted
+ Type *Ty, ///< The floating point type to cast to
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
@@ -815,10 +815,10 @@ public:
/// Create a Trunc or BitCast cast instruction
static CastInst *CreateTruncOrBitCast(
- Value *S, ///< The value to be casted (operand 0)
- Type *Ty, ///< The type to which cast should be made
- const Twine &Name, ///< Name for the instruction
- BasicBlock::iterator InsertBefore ///< Place to insert the instruction
+ Value *S, ///< The value to be casted (operand 0)
+ Type *Ty, ///< The type to which cast should be made
+ const Twine &Name, ///< Name for the instruction
+ BasicBlock::iterator InsertBefore ///< Place to insert the instruction
);
/// Create a Trunc or BitCast cast instruction
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index bc357074e5..c644ce2e90 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1267,17 +1267,16 @@ protected:
public:
/// Constructor with insert-before-instruction semantics.
- ICmpInst(
- BasicBlock::iterator InsertBefore, ///< Where to insert
- Predicate pred, ///< The predicate to use for the comparison
- Value *LHS, ///< The left-hand-side of the expression
- Value *RHS, ///< The right-hand-side of the expression
- const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(makeCmpResultType(LHS->getType()),
- Instruction::ICmp, pred, LHS, RHS, NameStr,
- InsertBefore) {
+ ICmpInst(BasicBlock::iterator InsertBefore, ///< Where to insert
+ Predicate pred, ///< The predicate to use for the comparison
+ Value *LHS, ///< The left-hand-side of the expression
+ Value *RHS, ///< The right-hand-side of the expression
+ const Twine &NameStr = "" ///< Name of the instruction
+ )
+ : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS,
+ RHS, NameStr, InsertBefore) {
#ifndef NDEBUG
- AssertOK();
+ AssertOK();
#endif
}
@@ -1454,15 +1453,14 @@ protected:
public:
/// Constructor with insert-before-instruction semantics.
- FCmpInst(
- BasicBlock::iterator InsertBefore, ///< Where to insert
- Predicate pred, ///< The predicate to use for the comparison
- Value *LHS, ///< The left-hand-side of the expression
- Value *RHS, ///< The right-hand-side of the expression
- const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(makeCmpResultType(LHS->getType()),
- Instruction::FCmp, pred, LHS, RHS, NameStr,
- InsertBefore) {
+ FCmpInst(BasicBlock::iterator InsertBefore, ///< Where to insert
+ Predicate pred, ///< The predicate to use for the comparison
+ Value *LHS, ///< The left-hand-side of the expression
+ Value *RHS, ///< The right-hand-side of the expression
+ const Twine &NameStr = "" ///< Name of the instruction
+ )
+ : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS,
+ RHS, NameStr, InsertBefore) {
AssertOK();
}
@@ -2700,8 +2698,7 @@ public:
static ExtractValueInst *Create(Value *Agg, ArrayRef<unsigned> Idxs,
const Twine &NameStr,
BasicBlock::iterator InsertBefore) {
- return new
- ExtractValueInst(Agg, Idxs, NameStr, InsertBefore);
+ return new ExtractValueInst(Agg, Idxs, NameStr, InsertBefore);
}
static ExtractValueInst *Create(Value *Agg,
@@ -2918,13 +2915,12 @@ struct OperandTraits<InsertValueInst> :
public FixedNumOperandTraits<InsertValueInst, 2> {
};
-InsertValueInst::InsertValueInst(Value *Agg,
- Value *Val,
- ArrayRef<unsigned> Idxs,
- const Twine &NameStr,
+InsertValueInst::InsertValueInst(Value *Agg, Value *Val,
+ ArrayRef<unsigned> Idxs, const Twine &NameStr,
BasicBlock::iterator InsertBefore)
- : Instruction(Agg->getType(), InsertValue, OperandTraits<InsertValueInst>::op_begin(this),
- 2, InsertBefore) {
+ : Instruction(Agg->getType(), InsertValue,
+ OperandTraits<InsertValueInst>::op_begin(this), 2,
+ InsertBefore) {
init(Agg, Val, Idxs, NameStr);
}
@@ -3489,7 +3485,7 @@ public:
static BranchInst *Create(BasicBlock *IfTrue,
BasicBlock::iterator InsertBefore) {
- return new(1) BranchInst(IfTrue, InsertBefore);
+ return new (1) BranchInst(IfTrue, InsertBefore);
}
static BranchInst *Create(BasicBlock *IfTrue,
@@ -3499,7 +3495,7 @@ public:
static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
Value *Cond, BasicBlock::iterator InsertBefore) {
- return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
+ return new (3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
}
static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
@@ -5347,10 +5343,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
TruncInst(
- Value *S, ///< The value to be truncated
- Type *Ty, ///< The (smaller) type to truncate to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be truncated
+ Type *Ty, ///< The (smaller) type to truncate to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5394,10 +5390,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
ZExtInst(
- Value *S, ///< The value to be zero extended
- Type *Ty, ///< The type to zero extend to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be zero extended
+ Type *Ty, ///< The type to zero extend to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5441,10 +5437,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
SExtInst(
- Value *S, ///< The value to be sign extended
- Type *Ty, ///< The type to sign extend to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be sign extended
+ Type *Ty, ///< The type to sign extend to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5488,10 +5484,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
FPTruncInst(
- Value *S, ///< The value to be truncated
- Type *Ty, ///< The type to truncate to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be truncated
+ Type *Ty, ///< The type to truncate to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5535,10 +5531,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
FPExtInst(
- Value *S, ///< The value to be extended
- Type *Ty, ///< The type to extend to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be extended
+ Type *Ty, ///< The type to extend to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5582,10 +5578,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
UIToFPInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5629,10 +5625,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
SIToFPInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5676,10 +5672,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
FPToUIInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5723,10 +5719,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
FPToSIInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5766,10 +5762,10 @@ public:
/// Constructor with insert-before-instruction semantics
IntToPtrInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5821,10 +5817,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
PtrToIntInst(
- Value *S, ///< The value to be converted
- Type *Ty, ///< The type to convert to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be converted
+ Type *Ty, ///< The type to convert to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5880,10 +5876,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
BitCastInst(
- Value *S, ///< The value to be casted
- Type *Ty, ///< The type to casted to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be casted
+ Type *Ty, ///< The type to casted to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
@@ -5928,10 +5924,10 @@ protected:
public:
/// Constructor with insert-before-instruction semantics
AddrSpaceCastInst(
- Value *S, ///< The value to be casted
- Type *Ty, ///< The type to casted to
- const Twine &NameStr, ///< A name for the new instruction
- BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
+ Value *S, ///< The value to be casted
+ Type *Ty, ///< The type to casted to
+ const Twine &NameStr, ///< A name for the new instruction
+ BasicBlock::iterator InsertBefore ///< Where to insert the new instruction
);
/// Constructor with insert-before-instruction semantics
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 25778570eb..ebfb56b993 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -990,8 +990,7 @@ ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
Op<0>() = retVal;
}
-ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
- Instruction *InsertBefore)
+ReturnInst::ReturnInst(LLVMContext &C, Value *retVal, Instruction *InsertBefore)
: Instruction(Type::getVoidTy(C), Instruction::Ret,
OperandTraits<ReturnInst>::op_end(this) - !!retVal, !!retVal,
InsertBefore) {
@@ -3610,20 +3609,34 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
assert(castIsValid(op, S, Ty) && "Invalid cast!");
// Construct and return the appropriate CastInst subclass
switch (op) {
- case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
- case ZExt: return new ZExtInst (S, Ty, Name, InsertBefore);
- case SExt: return new SExtInst (S, Ty, Name, InsertBefore);
- case FPTrunc: return new FPTruncInst (S, Ty, Name, InsertBefore);
- case FPExt: return new FPExtInst (S, Ty, Name, InsertBefore);
- case UIToFP: return new UIToFPInst (S, Ty, Name, InsertBefore);
- case SIToFP: return new SIToFPInst (S, Ty, Name, InsertBefore);
- case FPToUI: return new FPToUIInst (S, Ty, Name, InsertBefore);
- case FPToSI: return new FPToSIInst (S, Ty, Name, InsertBefore);
- case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertBefore);
- case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertBefore);
- case BitCast: return new BitCastInst (S, Ty, Name, InsertBefore);
- case AddrSpaceCast: return new AddrSpaceCastInst (S, Ty, Name, InsertBefore);
- default: llvm_unreachable("Invalid opcode provided");
+ case Trunc:
+ return new TruncInst(S, Ty, Name, InsertBefore);
+ case ZExt:
+ return new ZExtInst(S, Ty, Name, InsertBefore);
+ case SExt:
+ return new SExtInst(S, Ty, Name, InsertBefore);
+ case FPTrunc:
+ return new FPTruncInst(S, Ty, Name, InsertBefore);
+ case FPExt:
+ return new FPExtInst(S, Ty, Name, InsertBefore);
+ case UIToFP:
+ return new UIToFPInst(S, Ty, Name, InsertBefore);
+ case SIToFP:
+ return new SIToFPInst(S, Ty, Name, InsertBefore);
+ case FPToUI:
+ return new FPToUIInst(S, Ty, Name, InsertBefore);
+ case FPToSI:
+ return new FPToSIInst(S, Ty, Name, InsertBefore);
+ case PtrToInt:
+ return new PtrToIntInst(S, Ty, Name, InsertBefore);
+ case IntToPtr:
+ return new IntToPtrInst(S, Ty, Name, InsertBefore);
+ case BitCast:
+ return new BitCastInst(S, Ty, Name, InsertBefore);
+ case AddrSpaceCast:
+ return new AddrSpaceCastInst(S, Ty, Name, InsertBefore);
+ default:
+ llvm_unreachable("Invalid opcode provided");
}
}
@@ -3848,9 +3861,11 @@ CastInst *CastInst::CreateIntegerCast(Value *C, Type *Ty, bool isSigned,
unsigned SrcBits = C->getType()->getScalarSizeInBits();
unsigned DstBits = Ty->getScalarSizeInBits();
Instruction::CastOps opcode =
- (SrcBits == DstBits ? Instruction::BitCast :
- (SrcBits > DstBits ? Instruction::Trunc :
- (isSigned ? Instruction::SExt : Instruction::ZExt)));
+ (SrcBits == DstBits
+ ? Instruction::BitCast
+ : (SrcBits > DstBits
+ ? Instruction::Trunc
+ : (isSigned ? Instruction::SExt : Instruction::ZExt)));
return Create(opcode, C, Ty, Name, InsertBefore);
}
@@ -3889,8 +3904,9 @@ CastInst *CastInst::CreateFPCast(Value *C, Type *Ty, const Twine &Name,
unsigned SrcBits = C->getType()->getScalarSizeInBits();
unsigned DstBits = Ty->getScalarSizeInBits();
Instruction::CastOps opcode =
- (SrcBits == DstBits ? Instruction::BitCast :
- (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
+ (SrcBits == DstBits
+ ? Instruction::BitCast
+ : (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
return Create(opcode, C, Ty, Name, InsertBefore);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/82778
More information about the llvm-commits
mailing list