MIPS: Implement __builtin_mips_shll_qb builtin function overloading.

This function has two versions. The first one is used for a register operand.
The second one is used for an immediate number.

llvm-svn: 160308
This commit is contained in:
Simon Atanasyan 2012-07-16 18:52:02 +00:00
parent ef2128c12c
commit a06d06b660
3 changed files with 43 additions and 0 deletions

View File

@ -1378,6 +1378,11 @@ Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
return EmitPPCBuiltinExpr(BuiltinID, E);
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
return EmitMipsBuiltinExpr(BuiltinID, E);
default:
return 0;
}
@ -2563,3 +2568,27 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
}
}
}
Value *CodeGenFunction::EmitMipsBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
SmallVector<Value*, 4> Ops;
for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
Ops.push_back(EmitScalarExpr(E->getArg(i)));
Intrinsic::ID ID = Intrinsic::not_intrinsic;
switch (BuiltinID) {
default: return 0;
case Mips::BI__builtin_mips_shll_qb:
llvm::APSInt Value;
if (E->getArg(1)->isIntegerConstantExpr(Value, getContext()))
ID = Intrinsic::mips_shll_qb;
else
ID = Intrinsic::mips_shll_qb_v;
break;
}
llvm::Function *F = CGM.getIntrinsic(ID);
return Builder.CreateCall(F, Ops, "");
}

View File

@ -2276,6 +2276,7 @@ public:
llvm::Value *BuildVector(ArrayRef<llvm::Value*> Ops);
llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitMipsBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);

View File

@ -0,0 +1,13 @@
// REQUIRES: mips-registered-target
// RUN: %clang_cc1 -triple mips-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
typedef signed char v4i8 __attribute__ ((vector_size(4)));
void foo() {
v4i8 a = {1, 2, 3, 4};
int shift = 1;
// CHECK: {{%.*}} = call <4 x i8> @llvm.mips.shll.qb(<4 x i8> {{%.*}}, i32 1)
v4i8 r1 = __builtin_mips_shll_qb(a, 1);
// CHECK: {{%.*}} = call <4 x i8> @llvm.mips.shll.qb.v(<4 x i8> {{%.*}}, i32 {{%.*}})
v4i8 r2 = __builtin_mips_shll_qb(a, shift);
}