clover: remove compat::string
authorEdB <edb+mesa@sigluy.net>
Fri, 24 Apr 2015 10:59:55 +0000 (12:59 +0200)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 29 Apr 2015 12:45:00 +0000 (12:45 +0000)
Acked-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/state_trackers/clover/api/program.cpp
src/gallium/state_trackers/clover/core/compiler.hpp
src/gallium/state_trackers/clover/core/error.hpp
src/gallium/state_trackers/clover/core/program.cpp
src/gallium/state_trackers/clover/llvm/invocation.cpp
src/gallium/state_trackers/clover/tgsi/compiler.cpp
src/gallium/state_trackers/clover/util/compat.hpp

index c9856901c2e59d24812855f389b6cbb77d763f33..b3be2b8d1bb287d6daf50f5bc959e32f80a01d47 100644 (file)
@@ -216,7 +216,7 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
             throw error(CL_INVALID_OPERATION);
 
          if (!any_of(key_equals(name), headers))
-            headers.push_back(std::pair<compat::string, compat::string>(
+            headers.push_back(std::pair<std::string, std::string>(
                                  name, header.source()));
       },
       range(header_names, num_headers),
index bec8aacf65dc51388364bd5385d9283e329a17e6..62c0f476040dcb1faa1a96ce5a8ff31b94ea490d 100644 (file)
 #include "pipe/p_defines.h"
 
 namespace clover {
-   typedef compat::vector<std::pair<compat::string,
-                                       compat::string> > header_map;
+   typedef compat::vector<std::pair<std::string,
+                                       std::string> > header_map;
 
-   module compile_program_llvm(const compat::string &source,
+   module compile_program_llvm(const std::string &source,
                                const header_map &headers,
                                pipe_shader_ir ir,
-                               const compat::string &target,
-                               const compat::string &opts,
-                               compat::string &r_log);
+                               const std::string &target,
+                               const std::string &opts,
+                               std::string &r_log);
 
-   module compile_program_tgsi(const compat::string &source);
+   module compile_program_tgsi(const std::string &source);
 }
 
 #endif
index 45a38c1165b00dd381f8b4c661c4fe29986461b5..805a0eceb6aa1a4f09c858c177571736cfed0655 100644 (file)
@@ -54,7 +54,7 @@ namespace clover {
    ///
    class error : public std::runtime_error {
    public:
-      error(cl_int code, compat::string what = "") :
+      error(cl_int code, std::string what = "") :
          std::runtime_error(what), code(code) {
       }
 
@@ -68,7 +68,7 @@ namespace clover {
 
    class build_error : public error {
    public:
-      build_error(const compat::string &what = "") :
+      build_error(const std::string &what = "") :
          error(CL_COMPILE_PROGRAM_FAILURE, what) {
       }
    };
index c07548c8f628abedc7ce8a51a330edd0e7555461..50ac01b4ee6cc00ef2a0519162a3bcf6c67a1538 100644 (file)
@@ -52,7 +52,7 @@ program::build(const ref_vector<device> &devs, const char *opts,
 
          _opts.insert({ &dev, opts });
 
-         compat::string log;
+         std::string log;
 
          try {
             auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
index e07d95b1dbee6441205084c2e645a7f6470be187..21579094a94672051470075fe5c0d9673c6a98fb 100644 (file)
@@ -136,7 +136,7 @@ namespace {
                 const std::string &name, const std::string &triple,
                 const std::string &processor, const std::string &opts,
                 clang::LangAS::Map& address_spaces, unsigned &optimization_level,
-                compat::string &r_log) {
+                std::string &r_log) {
 
       clang::CompilerInstance c;
       clang::EmitLLVMOnlyAction act(&llvm_ctx);
@@ -470,7 +470,7 @@ namespace {
    emit_code(LLVMTargetMachineRef tm, LLVMModuleRef mod,
              LLVMCodeGenFileType file_type,
              LLVMMemoryBufferRef *out_buffer,
-             compat::string &r_log) {
+             std::string &r_log) {
       LLVMBool err;
       char *err_message = NULL;
 
@@ -491,7 +491,7 @@ namespace {
    std::vector<char>
    compile_native(const llvm::Module *mod, const std::string &triple,
                   const std::string &processor, unsigned dump_asm,
-                  compat::string &r_log) {
+                  std::string &r_log) {
 
       std::string log;
       LLVMTargetRef target;
@@ -545,7 +545,7 @@ namespace {
    std::map<std::string, unsigned>
    get_kernel_offsets(std::vector<char> &code,
                       const std::vector<llvm::Function *> &kernels,
-                      compat::string &r_log) {
+                      std::string &r_log) {
 
       // One of the libelf implementations
       // (http://www.mr511.de/software/english.htm) requires calling
@@ -611,7 +611,7 @@ namespace {
                        const llvm::Module *mod,
                        const std::vector<llvm::Function *> &kernels,
                        const clang::LangAS::Map &address_spaces,
-                       compat::string &r_log) {
+                       std::string &r_log) {
 
       std::map<std::string, unsigned> kernel_offsets =
             get_kernel_offsets(code, kernels, r_log);
@@ -641,12 +641,12 @@ namespace {
    void
    diagnostic_handler(const llvm::DiagnosticInfo &di, void *data) {
       if (di.getSeverity() == llvm::DS_Error) {
-         std::string message = *(compat::string*)data;
+         std::string message = *(std::string*)data;
          llvm::raw_string_ostream stream(message);
          llvm::DiagnosticPrinterRawOStream dp(stream);
          di.print(dp);
          stream.flush();
-         *(compat::string*)data = message;
+         *(std::string*)data = message;
 
          throw build_error();
       }
@@ -686,12 +686,12 @@ namespace {
 } // End anonymous namespace
 
 module
-clover::compile_program_llvm(const compat::string &source,
+clover::compile_program_llvm(const std::string &source,
                              const header_map &headers,
                              enum pipe_shader_ir ir,
-                             const compat::string &target,
-                             const compat::string &opts,
-                             compat::string &r_log) {
+                             const std::string &target,
+                             const std::string &opts,
+                             std::string &r_log) {
 
    init_targets();
 
index 93dfeb54fa63bf7df7b61b559ab8b9a122e77517..9e959f7bb2e9e276f9b6c17853069f709d0f95dc 100644 (file)
@@ -88,11 +88,12 @@ namespace {
 }
 
 module
-clover::compile_program_tgsi(const compat::string &source) {
-   const char *body = source.find("COMP\n");
+clover::compile_program_tgsi(const std::string &source) {
+   const size_t body_pos = source.find("COMP\n");
+   const char *body = &source[body_pos];
    module m;
 
-   read_header({ source.begin(), body }, m);
+   read_header({ source.begin(), source.begin() + body_pos }, m);
    read_body(body, m);
 
    return m;
index ea7d3a000beb52124c1a5843e81e1dd02d5ec994..dc063344c3c4f548f33a3a8ca9e6dfbdb9400c5c 100644 (file)
@@ -307,110 +307,6 @@ namespace clover {
          size_t offset;
       };
 
-      class string {
-      public:
-         typedef char *iterator;
-         typedef const char *const_iterator;
-         typedef char value_type;
-         typedef char &reference;
-         typedef const char &const_reference;
-         typedef std::ptrdiff_t difference_type;
-         typedef std::size_t size_type;
-
-         string() : v() {
-         }
-
-         string(const char *p) : v(p, std::strlen(p)) {
-         }
-
-         template<typename C>
-         string(const C &v) : v(v) {
-         }
-
-         operator std::string() const {
-            return std::string(v.begin(), v.end());
-         }
-
-         bool
-         operator==(const string &s) const {
-            return this->v == s.v;
-         }
-
-         void
-         reserve(size_type n) {
-            v.reserve(n);
-         }
-
-         void
-         resize(size_type n, char x = char()) {
-            v.resize(n, x);
-         }
-
-         void
-         push_back(char x) {
-            v.push_back(x);
-         }
-
-         size_type
-         size() const {
-            return v.size();
-         }
-
-         size_type
-         capacity() const {
-            return v.capacity();
-         }
-
-         iterator
-         begin() {
-            return v.begin();
-         }
-
-         const_iterator
-         begin() const {
-            return v.begin();
-         }
-
-         iterator
-         end() {
-            return v.end();
-         }
-
-         const_iterator
-         end() const {
-            return v.end();
-         }
-
-         reference
-         operator[](size_type i) {
-            return v[i];
-         }
-
-         const_reference
-         operator[](size_type i) const {
-            return v[i];
-         }
-
-         const char *
-         c_str() const {
-            v.reserve(size() + 1);
-            *v.end() = 0;
-            return v.begin();
-         }
-
-         const char *
-         find(const string &s) const {
-            for (size_t i = 0; i + s.size() < size(); ++i) {
-               if (!std::memcmp(begin() + i, s.begin(), s.size()))
-                  return begin() + i;
-            }
-
-            return end();
-         }
-
-      private:
-         mutable vector<char> v;
-      };
    }
 }