slang_rs.h revision cf6af6abc1de499920571308b14a27e19cf57097
1e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/*
2e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Copyright 2010, The Android Open Source Project
3e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy *
4163935113919a184122b8b3bd672ef08c8df65dcRomain Guy * Licensed under the Apache License, Version 2.0 (the "License");
5163935113919a184122b8b3bd672ef08c8df65dcRomain Guy * you may not use this file except in compliance with the License.
6163935113919a184122b8b3bd672ef08c8df65dcRomain Guy * You may obtain a copy of the License at
7564acf7c9bff822f608cda0d5df0a64a9f9aaefdChris Craik *
86e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy *     http://www.apache.org/licenses/LICENSE-2.0
9e4aa95e3627226bcb0d8cc3e42dca6e4df8f421cChris Craik *
108550c4c7b5952b7a4e1e0ede95c9492d03099a13Romain Guy * Unless required by applicable law or agreed to in writing, software
115dc7fa709646799a5207a5d217f70aa02bf4a3aaRomain Guy * distributed under the License is distributed on an "AS IS" BASIS,
129f5dab3fc228fa11c32b483e6101ec086895a32bRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139f5dab3fc228fa11c32b483e6101ec086895a32bRomain Guy * See the License for the specific language governing permissions and
1455bfb4e728fe1db619af5d2c287f4abe711b3343ztenghui * limitations under the License.
15e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck */
1668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck
173b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy#ifndef _SLANG_COMPILER_SLANG_RS_HPP
18e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck#define _SLANG_COMPILER_SLANG_RS_HPP
19163935113919a184122b8b3bd672ef08c8df65dcRomain Guy
20b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#include "slang.h"
21dd78ccacff83f0714ad90be98b58ad85f5d08c66Chet Haase
220776a6069365bdea83855db154fa2d37f9d1d808Chris Craik#include <list>
23c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik#include <vector>
2404fc583c3dd3144bc6b718fcac4b3e1afdfdb067John Reck#include <string>
259c1e23baf5bfbebd1aebbd6d9a18c225325567ceChet Haase
2603750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy#include "slang_rs_reflect_utils.h"
27211efea7376371ee755edd2ad03e83ef6eea464eRomain Guy
28fe5e7b7346a54537b980796ceeca66bfdbd05561John Recknamespace slang {
293bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy  class RSContext;
3003750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy
31163935113919a184122b8b3bd672ef08c8df65dcRomain Guyclass SlangRS : public Slang {
321212c9dafe932f70956651338568c5e1fdf21bcfRomain Guy private:
33e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck  // Context for RenderScript
34d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase  RSContext *mRSContext;
35163935113919a184122b8b3bd672ef08c8df65dcRomain Guy
366c319ca1275c8db892c39b48fc54864c949f9171Romain Guy  bool mAllowRSPrefix;
37163935113919a184122b8b3bd672ef08c8df65dcRomain Guy
38163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  // The package name that's really applied will be filled in RealPackageName.
39163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  bool reflectToJava(const std::string &OutputPathBase,
40163935113919a184122b8b3bd672ef08c8df65dcRomain Guy                     const std::string &OutputPackageName,
41163935113919a184122b8b3bd672ef08c8df65dcRomain Guy                     std::string *RealPackageName);
4265cd612face362d054a85d0f7e5881c59cd523beChris Craik
43cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy  bool generateBitcodeAccessor(const std::string &OutputPathBase,
44163935113919a184122b8b3bd672ef08c8df65dcRomain Guy                               const std::string &PackageName);
45163935113919a184122b8b3bd672ef08c8df65dcRomain Guy
468d4aeb7111afac0c3c7e56d4ad5d92f9cfce2ffdRomain Guy protected:
47113e0824d6bddf4376240681f9cf6a2deded9498John Reck  virtual void initDiagnostic();
48acb6f07623b7df3d4179f70ae03ade574616ffa6John Reck  virtual void initPreprocessor();
493b20251a355c88193c439f928a84ae69483fb488John Reck  virtual void initASTContext();
505c13d89c1332fcc499379b9064b891187b75ca32Chet Haase
5155bfb4e728fe1db619af5d2c287f4abe711b3343ztenghui  virtual clang::ASTConsumer
52163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  *createBackend(const clang::CodeGenOptions& CodeGenOpts,
53ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy                 llvm::raw_ostream *OS,
547b4516e7ea552ad08d6e7277d311ef11bd8f12e8ztenghui                 Slang::OutputType OT);
5514e513058ed4168c94e015638d16f5f87fd8063aChris Craik
560baaac5e9adf3ee280ae1239e2e58754a9d2b099Romain Guy
5705f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik public:
588aa195d7081b889f3a7b1f426cbd8556377aae5eRomain Guy  static bool IsRSHeaderFile(const char *File);
591e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
601e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy  SlangRS(const std::string &Triple, const std::string &CPU,
61710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik          const std::vector<std::string> &Features);
62e4aa95e3627226bcb0d8cc3e42dca6e4df8f421cChris Craik
63cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck  // Compile bunch of RS files given in the llvm-rs-cc arguments. Return true if
6423b797ab5151eb2474f3bdd679f2f07bfd723042John Reck  // all given input files are successfully compiled without errors.
65668f0e38ef0277d55d3118af37e17b8c435df85cJohn Reck  //
663b20251a355c88193c439f928a84ae69483fb488John Reck  // @IOFiles - List of pairs of <input file path, output file path>.
674f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck  //
68cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck  // @DepFiles - List of pairs of <output dep. file path, dependent bitcode
6918f16e6fba74eda173e1e7c869e6e2e2acc073ffJohn Reck  //             target>. If @OutputDep is true, this parameter must be given
7018f16e6fba74eda173e1e7c869e6e2e2acc073ffJohn Reck  //             with the same number of pairs given in @IOFiles.
71cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck  //
72f2d8ccc15d7272b3416f73605c1f31d1d346bd40Chris Craik  // @IncludePaths - User-defined include path.
73f2d8ccc15d7272b3416f73605c1f31d1d346bd40Chris Craik  //
74163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  // @AdditionalDepTargets - User-defined files added to the dependencies.
75950fe8f8d4d654e645fa7205ca275b5a03feb214Derek Sollenberger  //
7685bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy  // @OutputType - See Slang::OutputType.
773b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy  //
78e63f7c622a2086aefa80983c6f41b74fb166bb42Chris Craik  // @BitcodeStorage - See BitCodeStorageType in slang_rs_reflect_util.cpp.
79163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  //
8004fc583c3dd3144bc6b718fcac4b3e1afdfdb067John Reck  // @AllowRSPrefix - true to allow user-defined function prefixed with 'rs'.
81163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  //
82163935113919a184122b8b3bd672ef08c8df65dcRomain Guy  // @OutputDep - true if output dependecies file.
838a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy  //
84ce444ca4006cfe0e2151d858da732fc413a716bdJohn Reck  // @JavaReflectionPathBase - The path base for storing reflection files.
85ce444ca4006cfe0e2151d858da732fc413a716bdJohn Reck  //
8609d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy  // @JavaReflectionPackageName - The package name given by user in command
8709d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy  //                              line. This may override the package name
88ce444ca4006cfe0e2151d858da732fc413a716bdJohn Reck  //                              specified in the .rs using #pragma.
8909d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy  //
9009d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy  bool compile(const std::list<std::pair<const char*, const char*> > &IOFiles,
9109d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy               const std::list<std::pair<const char*, const char*> > &DepFiles,
92ce444ca4006cfe0e2151d858da732fc413a716bdJohn Reck               const std::vector<std::string> &IncludePaths,
9309d3636485eb1601c5beaf0d8682bb3027d2271dRomain Guy               const std::vector<std::string> &AdditionalDepTargets,
94e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill               Slang::OutputType OutputType, BitCodeStorageType BitcodeStorage,
958a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy               bool AllowRSPrefix, bool OutputDep,
968a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy               const std::string &JavaReflectionPathBase,
978a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy               const std::string &JavaReflectionPackageName);
988a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy
998a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy  virtual ~SlangRS();
1008a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy};
1018a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy}
1028a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy
103a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck#endif  // _SLANG_COMPILER_SLANG_RS_HPP
104a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck