Since the enum values for each arch's builtins overlap, it is not appropriate to check them when compiling or other archs. Fixes a problem where compiling for NEON would use x86 sema rules.

llvm-svn: 105593
This commit is contained in:
Nate Begeman 2010-06-08 02:47:44 +00:00
parent bbd44ef673
commit 4904e32d46
2 changed files with 36 additions and 4 deletions

View File

@ -4520,6 +4520,9 @@ private:
Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID,
CallExpr *TheCall);
bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
bool SemaBuiltinVAStart(CallExpr *TheCall);
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);

View File

@ -27,6 +27,7 @@
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include <limits>
using namespace clang;
@ -202,18 +203,46 @@ Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
if (SemaBuiltinAtomicOverloaded(TheCall))
return ExprError();
break;
// Target specific builtins start here.
}
// Since the target specific builtins for each arch overlap, only check those
// of the arch we are compiling for.
if (BuiltinID >= Builtin::FirstTSBuiltin) {
switch (Context.Target.getTriple().getArch()) {
case llvm::Triple::arm:
case llvm::Triple::thumb:
if (CheckARMBuiltinFunctionCall(BuiltinID, TheCall))
return ExprError();
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
if (CheckX86BuiltinFunctionCall(BuiltinID, TheCall))
return ExprError();
break;
default:
break;
}
}
return move(TheCallResult);
}
bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
switch (BuiltinID) {
case X86::BI__builtin_ia32_palignr128:
case X86::BI__builtin_ia32_palignr: {
llvm::APSInt Result;
if (SemaBuiltinConstantArg(TheCall, 2, Result))
return ExprError();
return true;
break;
}
}
return false;
}
return move(TheCallResult);
bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
// TODO: verify NEON intrinsic constant args.
return false;
}
/// CheckFunctionCall - Check a direct function call for various correctness