r272342 - RenderScript support in the Frontend
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 10 07:39:40 PDT 2016
On Thu, Jun 9, 2016 at 7:34 PM, Pirama Arumuga Nainar via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: pirama
> Date: Thu Jun 9 18:34:20 2016
> New Revision: 272342
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272342&view=rev
> Log:
> RenderScript support in the Frontend
>
> Summary:
>
> Create a new Frontend LangOpt to specify the renderscript language. It
> is enabled by the "-x renderscript" option from the driver.
>
> Add a "kernel" function attribute only for RenderScript (an "ignored
> attribute" warning is generated otherwise).
>
> Make the NativeHalfType and NativeHalfArgsAndReturns LangOpts be implied
> by the RenderScript LangOpt.
>
> Reviewers: rsmith
>
> Subscribers: cfe-commits, srhines
>
> Differential Revision: http://reviews.llvm.org/D21198
>
> Added:
> cfe/trunk/test/Sema/renderscript.rs
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Frontend/FrontendOptions.h
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Frontend/FrontendActions.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/CodeGen/fp16-ops.c
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Thu Jun 9 18:34:20 2016
> @@ -728,6 +728,12 @@ def OpenCLNoSVM : Attr {
> let ASTNode = 0;
> }
>
> +def Kernel : Attr {
Please rename this to RenderScriptKernel. We have another attribute
that is spelled "kernel" already, and we want to distinguish between
them to reduce confusion.
> + let Spellings = [GNU<"kernel">];
Is there a reason this isn't also spelled with a C++ attribute spelling?
> + let Subjects = SubjectList<[Function]>;
> + let Documentation = [Undocumented];
> +}
> +
> def Deprecated : InheritableAttr {
> let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
> CXX11<"","deprecated", 201309>];
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Jun 9 18:34:20 2016
> @@ -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")
>
> Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Jun 9 18:34:20 2016
> @@ -74,6 +74,7 @@ enum InputKind {
> IK_OpenCL,
> IK_CUDA,
> IK_PreprocessedCuda,
> + IK_RenderScript,
> IK_AST,
> IK_LLVM_IR
> };
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 9 18:34:20 2016
> @@ -1292,6 +1292,7 @@ static InputKind ParseFrontendArgs(Front
> .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
> case IK_PreprocessedObjCXX:
> LangStd = LangStandard::lang_gnucxx98;
> break;
> + case IK_RenderScript:
> + LangStd = LangStandard::lang_c99;
> + break;
> }
> }
>
> @@ -1537,6 +1541,12 @@ void CompilerInvocation::setLangDefaults
> 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;
>
>
> Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
> +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jun 9 18:34:20 2016
> @@ -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;
> }
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jun 9 18:34:20 2016
> @@ -4185,6 +4185,17 @@ static void handleTypeTagForDatatypeAttr
> 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";
> + }
This is the wrong way to handle this; please add a LangOpt subclass in
Attr.td and make this a target-specific attribute there.
~Aaron
> +}
> +
> +
> //===----------------------------------------------------------------------===//
> // Checker-specific attribute handlers.
> //===----------------------------------------------------------------------===//
> @@ -5914,6 +5925,10 @@ static void ProcessDeclAttribute(Sema &S
> case AttributeList::AT_TypeTagForDatatype:
> handleTypeTagForDatatypeAttr(S, D, Attr);
> break;
> +
> + case AttributeList::AT_Kernel:
> + handleKernelAttr(S, D, Attr);
> + break;
> }
> }
>
>
> Modified: cfe/trunk/test/CodeGen/fp16-ops.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fp16-ops.c?rev=272342&r1=272341&r2=272342&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/fp16-ops.c (original)
> +++ cfe/trunk/test/CodeGen/fp16-ops.c Thu Jun 9 18:34:20 2016
> @@ -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;
>
> Added: cfe/trunk/test/Sema/renderscript.rs
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/renderscript.rs?rev=272342&view=auto
> ==============================================================================
> --- cfe/trunk/test/Sema/renderscript.rs (added)
> +++ cfe/trunk/test/Sema/renderscript.rs Thu Jun 9 18:34:20 2016
> @@ -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 at +2 {{kernel attribute ignored}}
> +#endif
> +void __attribute__((kernel)) kernel();
> +
> +// expected-warning at +1 {{'kernel' attribute only applies to functions}}
> +int __attribute__((kernel)) global;
> +
> +#ifndef __RENDERSCRIPT__
> +// expected-error at +2 {{function return value cannot have __fp16 type; did you forget * ?}}
> +#endif
> +__fp16 fp16_return();
> +
> +#ifndef __RENDERSCRIPT__
> +// expected-error at +2 {{parameters cannot have __fp16 type; did you forget * ?}}
> +#endif
> +void fp16_arg(__fp16 p);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list