//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Chandler Carruth and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
-#include "llvm/ParameterAttributes.h"
#include "llvm/Intrinsics.h"
+#include "llvm/ADT/SmallVector.h"
+#include <cstring>
using namespace llvm;
if (Name.compare(5,10,"x86.mmx.ps",10) == 0 &&
(Name.compare(13,4,"psll", 4) == 0 ||
Name.compare(13,4,"psra", 4) == 0 ||
- Name.compare(13,4,"psrl", 4) == 0)) {
+ Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') {
const llvm::Type *VT = VectorType::get(IntegerType::get(64), 1);
return;
}
- switch(NewFn->getIntrinsicID()) {
+ switch (NewFn->getIntrinsicID()) {
default: assert(0 && "Unknown function for CallInst upgrade.");
case Intrinsic::x86_mmx_psll_d:
case Intrinsic::x86_mmx_psll_q:
case Intrinsic::x86_mmx_psrl_d:
case Intrinsic::x86_mmx_psrl_q:
case Intrinsic::x86_mmx_psrl_w: {
- SmallVector<Value*, 2> Operands;
+ Value *Operands[2];
- Operands.push_back(CI->getOperand(1));
+ Operands[0] = CI->getOperand(1);
// Cast the second parameter to the correct type.
BitCastInst *BC = new BitCastInst(CI->getOperand(2),
NewFn->getFunctionType()->getParamType(1),
"upgraded", CI);
- Operands.push_back(BC);
+ Operands[1] = BC;
// Construct a new CallInst
- CallInst *NewCI = new CallInst(NewFn, Operands.begin(), Operands.end(),
- "upgraded."+CI->getName(), CI);
+ CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+2,
+ "upgraded."+CI->getName(), CI);
NewCI->setTailCall(CI->isTailCall());
NewCI->setCallingConv(CI->getCallingConv());
}
case Intrinsic::ctlz:
case Intrinsic::ctpop:
- case Intrinsic::cttz:
+ case Intrinsic::cttz: {
// Build a small vector of the 1..(N-1) operands, which are the
// parameters.
- SmallVector<Value*, 8> Operands(CI->op_begin()+1, CI->op_end());
+ SmallVector<Value*, 8> Operands(CI->op_begin()+1, CI->op_end());
// Construct a new CallInst
- CallInst *NewCI = new CallInst(NewFn, Operands.begin(), Operands.end(),
- "upgraded."+CI->getName(), CI);
+ CallInst *NewCI = CallInst::Create(NewFn, Operands.begin(), Operands.end(),
+ "upgraded."+CI->getName(), CI);
NewCI->setTailCall(CI->isTailCall());
NewCI->setCallingConv(CI->getCallingConv());
// Handle any uses of the old CallInst.
if (!CI->use_empty()) {
// Check for sign extend parameter attributes on the return values.
- bool SrcSExt = NewFn->getParamAttrs() &&
- NewFn->getParamAttrs()->paramHasAttr(0,ParamAttr::SExt);
- bool DestSExt = F->getParamAttrs() &&
- F->getParamAttrs()->paramHasAttr(0,ParamAttr::SExt);
+ bool SrcSExt = NewFn->getParamAttrs().paramHasAttr(0, ParamAttr::SExt);
+ bool DestSExt = F->getParamAttrs().paramHasAttr(0, ParamAttr::SExt);
// Construct an appropriate cast from the new return type to the old.
CastInst *RetCast = CastInst::create(
// Clean up the old call now that it has been completely upgraded.
CI->eraseFromParent();
- break;
+ }
+ break;
}
}