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),
#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
///
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) {
}
class build_error : public error {
public:
- build_error(const compat::string &what = "") :
+ build_error(const std::string &what = "") :
error(CL_COMPILE_PROGRAM_FAILURE, what) {
}
};
_opts.insert({ &dev, opts });
- compat::string log;
+ std::string log;
try {
auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
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);
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;
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;
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
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);
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();
}
} // 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();
}
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;
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;
- };
}
}