diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-06 14:42:22 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-06 14:42:22 +0000 |
| commit | a801f4a81dc22cccb7b9a6f2cceae124e0f80176 (patch) | |
| tree | ccfbe255a0a2bbed4201cd29863ba75604926b0c | |
| parent | 68e2c7bee3ab337cc3134ff99fdd1ce2ddb33c2f (diff) | |
| download | bcm5719-llvm-a801f4a81dc22cccb7b9a6f2cceae124e0f80176.tar.gz bcm5719-llvm-a801f4a81dc22cccb7b9a6f2cceae124e0f80176.zip | |
Expose __builtin_bswap16.
GCC has always supported this on PowerPC and 4.8 supports it on all platforms,
so it's a good idea to expose it in clang too. LLVM supports this on all targets.
llvm-svn: 165362
| -rw-r--r-- | clang/include/clang/Basic/Builtins.def | 1 | ||||
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 1 | ||||
| -rw-r--r-- | clang/test/CodeGen/builtins.c | 1 | ||||
| -rw-r--r-- | clang/test/Sema/constant-builtins-2.c | 5 | ||||
| -rw-r--r-- | clang/test/Sema/constant-builtins.c | 5 |
6 files changed, 10 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index 13205e9f91f..7a1b4aabc1f 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -388,6 +388,7 @@ BUILTIN(__builtin_popcountll, "iULLi", "nc") // FIXME: These type signatures are not correct for targets with int != 32-bits // or with ULL != 64-bits. +BUILTIN(__builtin_bswap16, "UsUs", "nc") BUILTIN(__builtin_bswap32, "UiUi", "nc") BUILTIN(__builtin_bswap64, "ULLiULLi", "nc") diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index e21c83b64f6..323a1746bfb 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4296,6 +4296,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { return Error(E); } + case Builtin::BI__builtin_bswap16: case Builtin::BI__builtin_bswap32: case Builtin::BI__builtin_bswap64: { APSInt Val; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index a084be1f71e..b83e75ad238 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -356,6 +356,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, "expval"); return RValue::get(Result); } + case Builtin::BI__builtin_bswap16: case Builtin::BI__builtin_bswap32: case Builtin::BI__builtin_bswap64: { Value *ArgValue = EmitScalarExpr(E->getArg(0)); diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c index 65b9ad111fd..9ba12bbf2fe 100644 --- a/clang/test/CodeGen/builtins.c +++ b/clang/test/CodeGen/builtins.c @@ -113,6 +113,7 @@ int main() { // Whatever + P(bswap16, (N)); P(bswap32, (N)); P(bswap64, (N)); // FIXME diff --git a/clang/test/Sema/constant-builtins-2.c b/clang/test/Sema/constant-builtins-2.c index d78a176ef49..13d81fe13cb 100644 --- a/clang/test/Sema/constant-builtins-2.c +++ b/clang/test/Sema/constant-builtins-2.c @@ -48,8 +48,9 @@ extern int f(); int h0 = __builtin_types_compatible_p(int, float); //int h1 = __builtin_choose_expr(1, 10, f()); //int h2 = __builtin_expect(0, 0); -int h3 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f(); -int h4 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f(); +int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f(); +int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f(); +int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f(); extern long int bi0; extern __typeof__(__builtin_expect(0, 0)) bi0; diff --git a/clang/test/Sema/constant-builtins.c b/clang/test/Sema/constant-builtins.c index 1562623c0af..0045ea03d49 100644 --- a/clang/test/Sema/constant-builtins.c +++ b/clang/test/Sema/constant-builtins.c @@ -16,8 +16,9 @@ extern int f(); int h0 = __builtin_types_compatible_p(int,float); //int h1 = __builtin_choose_expr(1, 10, f()); //int h2 = __builtin_expect(0, 0); -int h3 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f(); -int h4 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f(); +int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f(); +int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f(); +int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f(); short somefunc(); |

