Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.

Mostly mechanical with some manual reformatting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135390 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frits van Bommel
2011-07-18 12:00:32 +00:00
parent c48e1ef0e2
commit 39b5abf507
12 changed files with 38 additions and 45 deletions

View File

@ -234,7 +234,7 @@ public:
/// ///
virtual virtual
ArrayRef<unsigned> getRawAllocationOrder(const MachineFunction &MF) const { ArrayRef<unsigned> getRawAllocationOrder(const MachineFunction &MF) const {
return ArrayRef<unsigned>(begin(), getNumRegs()); return makeArrayRef(begin(), getNumRegs());
} }
/// getSize - Return the size of the register in bytes, which is also the size /// getSize - Return the size of the register in bytes, which is also the size

View File

@ -1358,8 +1358,7 @@ static Value *BuildSubAggregate(Value *From, Value* To, Type *IndexedType,
return NULL; return NULL;
// Insert the value in the new (sub) aggregrate // Insert the value in the new (sub) aggregrate
return llvm::InsertValueInst::Create(To, V, return llvm::InsertValueInst::Create(To, V, makeArrayRef(Idxs).slice(IdxSkip),
ArrayRef<unsigned>(Idxs).slice(IdxSkip),
"tmp", InsertBefore); "tmp", InsertBefore);
} }
@ -1435,9 +1434,7 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
// %C = insertvalue {i32, i32 } %A, i32 11, 1 // %C = insertvalue {i32, i32 } %A, i32 11, 1
// which allows the unused 0,0 element from the nested struct to be // which allows the unused 0,0 element from the nested struct to be
// removed. // removed.
return BuildSubAggregate(V, return BuildSubAggregate(V, makeArrayRef(idx_range.begin(), req_idx),
ArrayRef<unsigned>(idx_range.begin(),
req_idx),
InsertBefore); InsertBefore);
else else
// We can't handle this without inserting insertvalues // We can't handle this without inserting insertvalues
@ -1455,7 +1452,7 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
// requested (though possibly only partially). Now we recursively look at // requested (though possibly only partially). Now we recursively look at
// the inserted value, passing any remaining indices. // the inserted value, passing any remaining indices.
return FindInsertedValue(I->getInsertedValueOperand(), return FindInsertedValue(I->getInsertedValueOperand(),
ArrayRef<unsigned>(req_idx, idx_range.end()), makeArrayRef(req_idx, idx_range.end()),
InsertBefore); InsertBefore);
} else if (ExtractValueInst *I = dyn_cast<ExtractValueInst>(V)) { } else if (ExtractValueInst *I = dyn_cast<ExtractValueInst>(V)) {
// If we're extracting a value from an aggregrate that was extracted from // If we're extracting a value from an aggregrate that was extracted from

View File

@ -2519,8 +2519,8 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
return Error(ID.Loc, "element " + Twine(i) + return Error(ID.Loc, "element " + Twine(i) +
" of struct initializer doesn't match struct element type"); " of struct initializer doesn't match struct element type");
V = ConstantStruct::get(ST, ArrayRef<Constant*>(ID.ConstantStructElts, V = ConstantStruct::get(ST, makeArrayRef(ID.ConstantStructElts,
ID.UIntVal)); ID.UIntVal));
} else } else
return Error(ID.Loc, "constant expression type mismatch"); return Error(ID.Loc, "constant expression type mismatch");
return false; return false;

View File

@ -115,7 +115,7 @@ public:
LiveInterval *get(unsigned idx) const { return newRegs_[idx+firstNew_]; } LiveInterval *get(unsigned idx) const { return newRegs_[idx+firstNew_]; }
ArrayRef<LiveInterval*> regs() const { ArrayRef<LiveInterval*> regs() const {
return ArrayRef<LiveInterval*>(newRegs_).slice(firstNew_); return makeArrayRef(newRegs_).slice(firstNew_);
} }
/// FIXME: Temporary accessors until we can get rid of /// FIXME: Temporary accessors until we can get rid of

View File

@ -684,7 +684,7 @@ void RAGreedy::addThroughConstraints(InterferenceCache::Cursor Intf,
assert(T < GroupSize && "Array overflow"); assert(T < GroupSize && "Array overflow");
TBS[T] = Number; TBS[T] = Number;
if (++T == GroupSize) { if (++T == GroupSize) {
SpillPlacer->addLinks(ArrayRef<unsigned>(TBS, T)); SpillPlacer->addLinks(makeArrayRef(TBS, T));
T = 0; T = 0;
} }
continue; continue;
@ -714,7 +714,7 @@ void RAGreedy::addThroughConstraints(InterferenceCache::Cursor Intf,
ArrayRef<SpillPlacement::BlockConstraint> Array(BCS, B); ArrayRef<SpillPlacement::BlockConstraint> Array(BCS, B);
SpillPlacer->addConstraints(Array); SpillPlacer->addConstraints(Array);
SpillPlacer->addLinks(ArrayRef<unsigned>(TBS, T)); SpillPlacer->addLinks(makeArrayRef(TBS, T));
} }
void RAGreedy::growRegion(GlobalSplitCandidate &Cand) { void RAGreedy::growRegion(GlobalSplitCandidate &Cand) {
@ -749,8 +749,7 @@ void RAGreedy::growRegion(GlobalSplitCandidate &Cand) {
// Any new blocks to add? // Any new blocks to add?
if (ActiveBlocks.size() == AddedTo) if (ActiveBlocks.size() == AddedTo)
break; break;
addThroughConstraints(Cand.Intf, addThroughConstraints(Cand.Intf, makeArrayRef(ActiveBlocks).slice(AddedTo));
ArrayRef<unsigned>(ActiveBlocks).slice(AddedTo));
AddedTo = ActiveBlocks.size(); AddedTo = ActiveBlocks.size();
// Perhaps iterating can enable more bundles? // Perhaps iterating can enable more bundles?

View File

@ -32,7 +32,7 @@ class RegisterClassInfo {
RCInfo() : Tag(0), NumRegs(0) {} RCInfo() : Tag(0), NumRegs(0) {}
operator ArrayRef<unsigned>() const { operator ArrayRef<unsigned>() const {
return ArrayRef<unsigned>(Order.get(), NumRegs); return makeArrayRef(Order.get(), NumRegs);
} }
}; };

View File

@ -261,7 +261,7 @@ Type *TypeMapTy::getImpl(Type *Ty) {
cast<PointerType>(Ty)->getAddressSpace()); cast<PointerType>(Ty)->getAddressSpace());
case Type::FunctionTyID: case Type::FunctionTyID:
return *Entry = FunctionType::get(ElementTypes[0], return *Entry = FunctionType::get(ElementTypes[0],
ArrayRef<Type*>(ElementTypes).slice(1), makeArrayRef(ElementTypes).slice(1),
cast<FunctionType>(Ty)->isVarArg()); cast<FunctionType>(Ty)->isVarArg());
case Type::StructTyID: case Type::StructTyID:
// Note that this is only reached for anonymous structs. // Note that this is only reached for anonymous structs.

View File

@ -487,19 +487,19 @@ ARMBaseRegisterInfo::getRawAllocationOrder(const TargetRegisterClass *RC,
if (!TFI->hasFP(MF)) { if (!TFI->hasFP(MF)) {
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPREven1); return makeArrayRef(GPREven1);
else else
return ArrayRef<unsigned>(GPREven4); return makeArrayRef(GPREven4);
} else if (FramePtr == ARM::R7) { } else if (FramePtr == ARM::R7) {
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPREven2); return makeArrayRef(GPREven2);
else else
return ArrayRef<unsigned>(GPREven5); return makeArrayRef(GPREven5);
} else { // FramePtr == ARM::R11 } else { // FramePtr == ARM::R11
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPREven3); return makeArrayRef(GPREven3);
else else
return ArrayRef<unsigned>(GPREven6); return makeArrayRef(GPREven6);
} }
} else if (HintType == ARMRI::RegPairOdd) { } else if (HintType == ARMRI::RegPairOdd) {
if (isPhysicalRegister(HintReg) && getRegisterPairOdd(HintReg, MF) == 0) if (isPhysicalRegister(HintReg) && getRegisterPairOdd(HintReg, MF) == 0)
@ -509,19 +509,19 @@ ARMBaseRegisterInfo::getRawAllocationOrder(const TargetRegisterClass *RC,
if (!TFI->hasFP(MF)) { if (!TFI->hasFP(MF)) {
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPROdd1); return makeArrayRef(GPROdd1);
else else
return ArrayRef<unsigned>(GPROdd4); return makeArrayRef(GPROdd4);
} else if (FramePtr == ARM::R7) { } else if (FramePtr == ARM::R7) {
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPROdd2); return makeArrayRef(GPROdd2);
else else
return ArrayRef<unsigned>(GPROdd5); return makeArrayRef(GPROdd5);
} else { // FramePtr == ARM::R11 } else { // FramePtr == ARM::R11
if (!STI.isR9Reserved()) if (!STI.isR9Reserved())
return ArrayRef<unsigned>(GPROdd3); return makeArrayRef(GPROdd3);
else else
return ArrayRef<unsigned>(GPROdd6); return makeArrayRef(GPROdd6);
} }
} }
return RC->getRawAllocationOrder(MF); return RC->getRawAllocationOrder(MF);

View File

@ -3559,7 +3559,7 @@ void CWriter::visitInsertValueInst(InsertValueInst &IVI) {
i != e; ++i) { i != e; ++i) {
Type *IndexedTy = Type *IndexedTy =
ExtractValueInst::getIndexedType(IVI.getOperand(0)->getType(), ExtractValueInst::getIndexedType(IVI.getOperand(0)->getType(),
ArrayRef<unsigned>(b, i+1)); makeArrayRef(b, i+1));
if (IndexedTy->isArrayTy()) if (IndexedTy->isArrayTy())
Out << ".array[" << *i << "]"; Out << ".array[" << *i << "]";
else else
@ -3581,7 +3581,7 @@ void CWriter::visitExtractValueInst(ExtractValueInst &EVI) {
i != e; ++i) { i != e; ++i) {
Type *IndexedTy = Type *IndexedTy =
ExtractValueInst::getIndexedType(EVI.getOperand(0)->getType(), ExtractValueInst::getIndexedType(EVI.getOperand(0)->getType(),
ArrayRef<unsigned>(b, i+1)); makeArrayRef(b, i+1));
if (IndexedTy->isArrayTy()) if (IndexedTy->isArrayTy())
Out << ".array[" << *i << "]"; Out << ".array[" << *i << "]";
else else

View File

@ -1242,7 +1242,7 @@ Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
Value *NewEV = Builder->CreateExtractValue(IV->getAggregateOperand(), Value *NewEV = Builder->CreateExtractValue(IV->getAggregateOperand(),
EV.getIndices()); EV.getIndices());
return InsertValueInst::Create(NewEV, IV->getInsertedValueOperand(), return InsertValueInst::Create(NewEV, IV->getInsertedValueOperand(),
ArrayRef<unsigned>(insi, inse)); makeArrayRef(insi, inse));
} }
if (insi == inse) if (insi == inse)
// The insert list is a prefix of the extract list // The insert list is a prefix of the extract list
@ -1254,7 +1254,7 @@ Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
// with // with
// %E extractvalue { i32 } { i32 42 }, 0 // %E extractvalue { i32 } { i32 42 }, 0
return ExtractValueInst::Create(IV->getInsertedValueOperand(), return ExtractValueInst::Create(IV->getInsertedValueOperand(),
ArrayRef<unsigned>(exti, exte)); makeArrayRef(exti, exte));
} }
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Agg)) { if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Agg)) {
// We're extracting from an intrinsic, see if we're the only user, which // We're extracting from an intrinsic, see if we're the only user, which

View File

@ -506,7 +506,7 @@ LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
unsigned Count) { unsigned Count) {
return wrap(MDNode::get(*unwrap(C), return wrap(MDNode::get(*unwrap(C),
ArrayRef<Value*>(unwrap<Value>(Vals, Count), Count))); makeArrayRef(unwrap<Value>(Vals, Count), Count)));
} }
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) { LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
@ -575,8 +575,7 @@ LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
LLVMValueRef *ConstantVals, LLVMValueRef *ConstantVals,
unsigned Count, LLVMBool Packed) { unsigned Count, LLVMBool Packed) {
Constant **Elements = unwrap<Constant>(ConstantVals, Count); Constant **Elements = unwrap<Constant>(ConstantVals, Count);
return wrap(ConstantStruct::getAnon(*unwrap(C), return wrap(ConstantStruct::getAnon(*unwrap(C), makeArrayRef(Elements, Count),
ArrayRef<Constant*>(Elements, Count),
Packed != 0)); Packed != 0));
} }
@ -602,11 +601,11 @@ LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
Constant **Elements = unwrap<Constant>(ConstantVals, Count); Constant **Elements = unwrap<Constant>(ConstantVals, Count);
StructType *Ty = cast<StructType>(unwrap(StructTy)); StructType *Ty = cast<StructType>(unwrap(StructTy));
return wrap(ConstantStruct::get(Ty, ArrayRef<Constant*>(Elements, Count))); return wrap(ConstantStruct::get(Ty, makeArrayRef(Elements, Count)));
} }
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) { LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
return wrap(ConstantVector::get(ArrayRef<Constant*>( return wrap(ConstantVector::get(makeArrayRef(
unwrap<Constant>(ScalarConstantVals, Size), Size))); unwrap<Constant>(ScalarConstantVals, Size), Size)));
} }
/*--.. Constant expressions ................................................--*/ /*--.. Constant expressions ................................................--*/
@ -934,8 +933,7 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
unsigned NumIdx) { unsigned NumIdx) {
return wrap(ConstantExpr::getExtractValue(unwrap<Constant>(AggConstant), return wrap(ConstantExpr::getExtractValue(unwrap<Constant>(AggConstant),
ArrayRef<unsigned>(IdxList, makeArrayRef(IdxList, NumIdx)));
NumIdx)));
} }
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
@ -943,8 +941,7 @@ LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
unsigned *IdxList, unsigned NumIdx) { unsigned *IdxList, unsigned NumIdx) {
return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant), return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant),
unwrap<Constant>(ElementValueConstant), unwrap<Constant>(ElementValueConstant),
ArrayRef<unsigned>(IdxList, makeArrayRef(IdxList, NumIdx)));
NumIdx)));
} }
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
@ -1680,7 +1677,7 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
const char *Name) { const char *Name) {
return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch), return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
ArrayRef<Value *>(unwrap(Args), NumArgs), makeArrayRef(unwrap(Args), NumArgs),
Name)); Name));
} }
@ -2064,7 +2061,7 @@ LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs, LLVMValueRef *Args, unsigned NumArgs,
const char *Name) { const char *Name) {
return wrap(unwrap(B)->CreateCall(unwrap(Fn), return wrap(unwrap(B)->CreateCall(unwrap(Fn),
ArrayRef<Value *>(unwrap(Args), NumArgs), makeArrayRef(unwrap(Args), NumArgs),
Name)); Name));
} }

View File

@ -526,9 +526,9 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << " };\n"; OS << " };\n";
} }
OS << " static const ArrayRef<unsigned> Order[] = {\n" OS << " static const ArrayRef<unsigned> Order[] = {\n"
<< " ArrayRef<unsigned>(" << RC.getName(); << " makeArrayRef(" << RC.getName();
for (unsigned oi = 1, oe = RC.getNumOrders(); oi != oe; ++oi) for (unsigned oi = 1, oe = RC.getNumOrders(); oi != oe; ++oi)
OS << "),\n ArrayRef<unsigned>(AltOrder" << oi; OS << "),\n makeArrayRef(AltOrder" << oi;
OS << ")\n };\n const unsigned Select = " << RC.getName() OS << ")\n };\n const unsigned Select = " << RC.getName()
<< "AltOrderSelect(MF);\n assert(Select < " << RC.getNumOrders() << "AltOrderSelect(MF);\n assert(Select < " << RC.getNumOrders()
<< ");\n return Order[Select];\n}\n"; << ");\n return Order[Select];\n}\n";