fix breakage from last night, simplify code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35560 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-04-01 20:49:36 +00:00
parent 77c2af6b64
commit 3e9f1d09c0

View File

@ -17,6 +17,7 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/InlineAsm.h" #include "llvm/InlineAsm.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
using namespace llvm; using namespace llvm;
@ -199,24 +200,14 @@ bool X86TargetAsmInfo::LowerToBSwap(CallInst *CI) const {
!CI->getType()->isInteger()) !CI->getType()->isInteger())
return false; return false;
const Type *Ty = CI->getType(); const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
const char *IntName; if (!Ty || Ty->getBitWidth() % 16 != 0)
if (const IntegerType *ITy = dyn_cast<IntegerType>(Ty)) {
unsigned BitWidth = ITy->getBitWidth();
if (BitWidth == 16)
IntName = "llvm.bswap.i16";
else if (BitWidth == 32)
IntName = "llvm.bswap.i32";
else if (BitWidth == 64)
IntName = "llvm.bswap.i64";
else
return false;
} else
return false; return false;
// Okay, we can do this xform, do so now. // Okay, we can do this xform, do so now.
const Type *Tys[] = { Ty, Ty };
Module *M = CI->getParent()->getParent()->getParent(); Module *M = CI->getParent()->getParent()->getParent();
Constant *Int = M->getOrInsertFunction(IntName, Ty, Ty, (Type*)0); Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 2);
Value *Op = CI->getOperand(1); Value *Op = CI->getOperand(1);
Op = new CallInst(Int, Op, CI->getName(), CI); Op = new CallInst(Int, Op, CI->getName(), CI);