summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/Attr.td6
-rw-r--r--clang/include/clang/Basic/LangOptions.def1
-rw-r--r--clang/include/clang/Frontend/FrontendOptions.h1
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp10
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp1
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp15
-rw-r--r--clang/test/CodeGen/fp16-ops.c2
-rw-r--r--clang/test/Sema/renderscript.rs20
8 files changed, 56 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index e90c124cbd7..0187f829f09 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -728,6 +728,12 @@ def OpenCLNoSVM : Attr {
let ASTNode = 0;
}
+def Kernel : Attr {
+ let Spellings = [GNU<"kernel">];
+ let Subjects = SubjectList<[Function]>;
+ let Documentation = [Undocumented];
+}
+
def Deprecated : InheritableAttr {
let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
CXX11<"","deprecated", 201309>];
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index d3a85b76fea..0f67ed3a3b6 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -185,6 +185,7 @@ LANGOPT(CUDA , 1, 0, "CUDA")
LANGOPT(OpenMP , 32, 0, "OpenMP support and version of OpenMP (31, 40 or 45)")
LANGOPT(OpenMPUseTLS , 1, 0, "Use TLS for threadprivates or runtime calls")
LANGOPT(OpenMPIsDevice , 1, 0, "Generate code only for OpenMP target device")
+LANGOPT(RenderScript , 1, 0, "RenderScript")
LANGOPT(CUDAIsDevice , 1, 0, "compiling for CUDA device")
LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "allowing variadic functions in CUDA device code")
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h
index 1ae662a4804..d49d8de6f58 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -74,6 +74,7 @@ enum InputKind {
IK_OpenCL,
IK_CUDA,
IK_PreprocessedCuda,
+ IK_RenderScript,
IK_AST,
IK_LLVM_IR
};
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a948653ee72..b217db96c7e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1292,6 +1292,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
.Case("objective-c++-header", IK_ObjCXX)
.Cases("ast", "pcm", IK_AST)
.Case("ir", IK_LLVM_IR)
+ .Case("renderscript", IK_RenderScript)
.Default(IK_None);
if (DashX == IK_None)
Diags.Report(diag::err_drv_invalid_value)
@@ -1495,6 +1496,9 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
case IK_PreprocessedObjCXX:
LangStd = LangStandard::lang_gnucxx98;
break;
+ case IK_RenderScript:
+ LangStd = LangStandard::lang_c99;
+ break;
}
}
@@ -1537,6 +1541,12 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
LangStd == LangStandard::lang_cuda;
+ Opts.RenderScript = IK == IK_RenderScript;
+ if (Opts.RenderScript) {
+ Opts.NativeHalfType = 1;
+ Opts.NativeHalfArgsAndReturns = 1;
+ }
+
// OpenCL and C++ both have bool, true, false keywords.
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 21dd37d43cb..dd5479ca71a 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -735,6 +735,7 @@ void PrintPreambleAction::ExecuteAction() {
case IK_PreprocessedObjCXX:
case IK_AST:
case IK_LLVM_IR:
+ case IK_RenderScript:
// We can't do anything with these.
return;
}
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index f4cce2febd9..e99876b10b7 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4185,6 +4185,17 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D,
Attr.getAttributeSpellingListIndex()));
}
+static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+ if (S.LangOpts.RenderScript) {
+ D->addAttr(::new (S.Context)
+ KernelAttr(Attr.getRange(), S.Context,
+ Attr.getAttributeSpellingListIndex()));
+ } else {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
+ }
+}
+
+
//===----------------------------------------------------------------------===//
// Checker-specific attribute handlers.
//===----------------------------------------------------------------------===//
@@ -5914,6 +5925,10 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_TypeTagForDatatype:
handleTypeTagForDatatypeAttr(S, D, Attr);
break;
+
+ case AttributeList::AT_Kernel:
+ handleKernelAttr(S, D, Attr);
+ break;
}
}
diff --git a/clang/test/CodeGen/fp16-ops.c b/clang/test/CodeGen/fp16-ops.c
index 7cd08a03d64..c96727f3d3f 100644
--- a/clang/test/CodeGen/fp16-ops.c
+++ b/clang/test/CodeGen/fp16-ops.c
@@ -7,6 +7,8 @@
// RUN: | FileCheck %s --check-prefix=NATIVE-HALF
// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-none-linux-gnueabi -fnative-half-type %s \
// RUN: | FileCheck %s --check-prefix=NATIVE-HALF
+// RUN: %clang_cc1 -emit-llvm -o - -x renderscript %s \
+// RUN: | FileCheck %s --check-prefix=NATIVE-HALF
typedef unsigned cond_t;
volatile cond_t test;
diff --git a/clang/test/Sema/renderscript.rs b/clang/test/Sema/renderscript.rs
new file mode 100644
index 00000000000..c6ffb4df1cf
--- /dev/null
+++ b/clang/test/Sema/renderscript.rs
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x renderscript -D__RENDERSCRIPT__ %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c %s
+
+#ifndef __RENDERSCRIPT__
+// expected-warning@+2 {{kernel attribute ignored}}
+#endif
+void __attribute__((kernel)) kernel();
+
+// expected-warning@+1 {{'kernel' attribute only applies to functions}}
+int __attribute__((kernel)) global;
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{function return value cannot have __fp16 type; did you forget * ?}}
+#endif
+__fp16 fp16_return();
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{parameters cannot have __fp16 type; did you forget * ?}}
+#endif
+void fp16_arg(__fp16 p);
OpenPOWER on IntegriCloud