Clover Git
OpenCL 1.1 software implementation
Public Member Functions | Private Attributes

Coal::Compiler Class Reference

Compiler using Clang. More...

#include <compiler.h>

Collaboration diagram for Coal::Compiler:

List of all members.

Public Member Functions

 Compiler (DeviceInterface *device)
 ~Compiler ()
bool compile (const std::string &options, llvm::MemoryBuffer *source)
 Compile source to produce a LLVM module.
const std::string & log () const
 Compilation log.
const std::string & options () const
 Options given at compile()
bool optimize () const
 Optimization enabled.
llvm::Module * module () const
 LLVM module generated.
void appendLog (const std::string &log)
 Append a string to the log.

Private Attributes

clang::CompilerInstance p_compiler
llvm::Module * p_module
bool p_optimize
std::string p_log
std::string p_options
llvm::raw_string_ostream p_log_stream
clang::TextDiagnosticPrinter * p_log_printer

Detailed Description

Compiler using Clang.

This class builds a Clang instance, runs it and then retains compilation logs and produced data.

Definition at line 63 of file compiler.h.

Constructor & Destructor Documentation

Compiler::Compiler ( DeviceInterface device)


deviceCoal::DeviceInterface for which code will be compiled

Definition at line 51 of file compiler.cpp.

Compiler::~Compiler ( )

Definition at line 58 of file compiler.cpp.

Member Function Documentation

void Compiler::appendLog ( const std::string &  log)

Append a string to the log.

This function can be used to append linking or code-gen logs to the internal compilation log kept by this class

loglog to be appended

Definition at line 237 of file compiler.cpp.

References log(), and p_log.

Referenced by Coal::Program::build().

bool Compiler::compile ( const std::string &  options,
llvm::MemoryBuffer *  source 

Compile source to produce a LLVM module.

optionsoptions given to the compiler, described in the OpenCL spec
sourcesource to be compiled
true if the compilation is successful, false otherwise
See also:

Definition at line 63 of file compiler.cpp.

References log(), options(), p_compiler, p_log_printer, p_log_stream, p_module, p_optimize, and p_options.

Referenced by Coal::Program::build(), and main().

const std::string & Compiler::log ( ) const

Compilation log.

appendLog() can also be used to append custom info at the end of the log, for instance to keep compilation and linking logs in the same place

Definition at line 217 of file compiler.cpp.

References p_log.

Referenced by appendLog(), Coal::Program::build(), Coal::Program::buildInfo(), and compile().

llvm::Module * Compiler::module ( ) const

LLVM module generated.

LLVM module generated by the compilation, 0 if an error occured

Definition at line 232 of file compiler.cpp.

References p_module.

Referenced by Coal::Program::build().

bool Compiler::optimize ( ) const

Optimization enabled.

true if -cl-opt-disable was given in the options, false otherwise

Definition at line 227 of file compiler.cpp.

References p_optimize.

Referenced by Coal::Program::build().

const std::string & Compiler::options ( ) const

Options given at compile()

options used during compilation

Definition at line 222 of file compiler.cpp.

References p_options.

Referenced by Coal::Program::buildInfo(), and compile().

Member Data Documentation

clang::CompilerInstance Coal::Compiler::p_compiler [private]

Definition at line 122 of file compiler.h.

Referenced by compile().

Definition at line 121 of file compiler.h.

std::string Coal::Compiler::p_log [private]

Definition at line 126 of file compiler.h.

Referenced by appendLog(), and log().

clang::TextDiagnosticPrinter* Coal::Compiler::p_log_printer [private]

Definition at line 128 of file compiler.h.

Referenced by compile().

llvm::raw_string_ostream Coal::Compiler::p_log_stream [private]

Definition at line 127 of file compiler.h.

Referenced by compile().

llvm::Module* Coal::Compiler::p_module [private]

Definition at line 123 of file compiler.h.

Referenced by compile(), and module().

Definition at line 124 of file compiler.h.

Referenced by compile(), and optimize().

std::string Coal::Compiler::p_options [private]

Definition at line 126 of file compiler.h.

Referenced by compile(), and options().

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines