[llvm-commits] [llvm-gcc-4.2] r84677 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
Bob Wilson
bob.wilson at apple.com
Tue Oct 20 14:05:42 PDT 2009
Author: bwilson
Date: Tue Oct 20 16:05:42 2009
New Revision: 84677
URL: http://llvm.org/viewvc/llvm-project?rev=84677&view=rev
Log:
Add a function to build int32 constants. Remove some redundant "Context"s.
Modified:
llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=84677&r1=84676&r2=84677&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Oct 20 16:05:42 2009
@@ -47,6 +47,10 @@
(int fcode, neon_itype *itype, enum neon_builtins *neon_code);
}
+static ConstantInt *getInt32Const(int c) {
+ return ConstantInt::get(Type::getInt32Ty(Context), c);
+}
+
/// UnexpectedError - Report errors about unexpected uses of builtins. The
/// msg argument should begin with a "%H" so that the location of the
/// expression is printed in the error message.
@@ -131,8 +135,6 @@
/// element of a vector.
static Value *BuildDup(const Type *ResultType, Value *Val,
LLVMBuilder &Builder) {
- LLVMContext &Context = getGlobalContext();
-
// GCC may promote the scalar argument; cast it back.
const VectorType *VTy = dyn_cast<const VectorType>(ResultType);
assert(VTy && "expected a vector type");
@@ -145,16 +147,14 @@
// Insert the value into lane 0 of an undef vector.
Value *Undef = UndefValue::get(ResultType);
- Value *Result =
- Builder.CreateInsertElement(Undef, Val,
- ConstantInt::get(Type::getInt32Ty(Context), 0));
+ Value *Result = Builder.CreateInsertElement(Undef, Val, getInt32Const(0));
// Use a shuffle to move the value into the other lanes.
unsigned NUnits = VTy->getNumElements();
if (NUnits > 1) {
std::vector<Constant*> Idxs;
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
+ Idxs.push_back(getInt32Const(0));
Result = Builder.CreateShuffleVector(Result, Undef,
ConstantVector::get(Idxs));
}
@@ -167,9 +167,8 @@
LLVMBuilder &Builder) {
// Translate this to a vector shuffle.
std::vector<Constant*> Idxs;
- LLVMContext &Context = getGlobalContext();
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), LaneVal));
+ Idxs.push_back(getInt32Const(LaneVal));
return Builder.CreateShuffleVector(Vec, UndefValue::get(Vec->getType()),
ConstantVector::get(Idxs));
}
@@ -217,7 +216,6 @@
return false;
// Right shifts are represented in NEON intrinsics by a negative shift count.
- LLVMContext &Context = getGlobalContext();
Cnt = ConstantInt::get(IntegerType::get(Context, ElemBits),
NegateRightShift ? -CntVal : CntVal);
Op = BuildConstantSplatVector(GET_MODE_NUNITS(Mode), Cnt);
@@ -259,8 +257,6 @@
if (FnCode < ARM_BUILTIN_NEON_BASE)
return false;
- LLVMContext &Context = getGlobalContext();
-
neon_builtins neon_code;
enum insn_code icode = locate_neon_builtin_icode (FnCode, 0, &neon_code);
@@ -1686,7 +1682,7 @@
unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[0].mode);
std::vector<Constant*> Idxs;
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), i));
+ Idxs.push_back(getInt32Const(i));
Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
ConstantVector::get(Idxs));
break;
@@ -1698,7 +1694,7 @@
std::vector<Constant*> Idxs;
unsigned Idx = (neon_code == NEON_BUILTIN_vget_low ? 0 : NUnits);
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), Idx++));
+ Idxs.push_back(getInt32Const(Idx++));
Result = Builder.CreateShuffleVector(Ops[0],
UndefValue::get(Ops[0]->getType()),
ConstantVector::get(Idxs));
@@ -1762,7 +1758,7 @@
// Translate to a vector shuffle.
std::vector<Constant*> Idxs;
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), i + ImmVal));
+ Idxs.push_back(getInt32Const(i + ImmVal));
Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
ConstantVector::get(Idxs));
break;
@@ -1788,7 +1784,7 @@
unsigned NUnits = VTy->getNumElements();
for (unsigned c = ChunkElts; c <= NUnits; c += ChunkElts) {
for (unsigned i = 0; i != ChunkElts; ++i) {
- Idxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), c - i - 1));
+ Idxs.push_back(getInt32Const(c - i - 1));
}
}
Result = Builder.CreateShuffleVector(Ops[0], UndefValue::get(ResultType),
@@ -1934,12 +1930,11 @@
case NEON_BUILTIN_vtrn: {
// Translate this to a pair of vector shuffles.
unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
- const Type *Int32Ty = Type::getInt32Ty(Context);
for (unsigned Elt = 0; Elt != 2; ++Elt) {
std::vector<Constant*> Idxs;
for (unsigned i = 0; i < NUnits; i += 2) {
- Idxs.push_back(ConstantInt::get(Int32Ty, i + Elt));
- Idxs.push_back(ConstantInt::get(Int32Ty, i + NUnits + Elt));
+ Idxs.push_back(getInt32Const(i + Elt));
+ Idxs.push_back(getInt32Const(i + NUnits + Elt));
}
Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
ConstantVector::get(Idxs));
@@ -1953,13 +1948,12 @@
case NEON_BUILTIN_vzip: {
// Translate this to a pair of vector shuffles.
unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
- const Type *Int32Ty = Type::getInt32Ty(Context);
unsigned Idx = 0;
for (unsigned Elt = 0; Elt != 2; ++Elt) {
std::vector<Constant*> Idxs;
for (unsigned i = 0; i != NUnits; i += 2) {
- Idxs.push_back(ConstantInt::get(Int32Ty, Idx));
- Idxs.push_back(ConstantInt::get(Int32Ty, Idx + NUnits));
+ Idxs.push_back(getInt32Const(Idx));
+ Idxs.push_back(getInt32Const(Idx + NUnits));
Idx += 1;
}
Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
@@ -1974,11 +1968,10 @@
case NEON_BUILTIN_vuzp: {
// Translate this to a pair of vector shuffles.
unsigned NUnits = GET_MODE_NUNITS(insn_data[icode].operand[1].mode);
- const Type *Int32Ty = Type::getInt32Ty(Context);
for (unsigned Elt = 0; Elt != 2; ++Elt) {
std::vector<Constant*> Idxs;
for (unsigned i = 0; i != NUnits; ++i)
- Idxs.push_back(ConstantInt::get(Int32Ty, 2 * i + Elt));
+ Idxs.push_back(getInt32Const(2 * i + Elt));
Result = Builder.CreateShuffleVector(Ops[0], Ops[1],
ConstantVector::get(Idxs));
Value *Addr = Builder.CreateConstInBoundsGEP2_32(DestLoc->Ptr, 0, Elt);
@@ -2109,7 +2102,7 @@
for (unsigned n = 0; n != NumVecs; ++n) {
Args.push_back(UndefValue::get(VTy));
}
- Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
+ Args.push_back(getInt32Const(0));
Result = Builder.CreateCall(intFn, Args.begin(), Args.end());
// Now splat the values in lane 0 to the rest of the elements.
More information about the llvm-commits
mailing list