Compiler

class Compiler : public xacc::OptionsProvider, public xacc::Identifiable

The Compiler class provides an extensible interface for injecting custom compilation mechanisms into the XACC framework. Implementations provide a compile method that takes the kernel source code string, performs compiler-specific compilation mechanism, and returns a valid XACC IR instance modeling the result of the compilation.

Subclassed by xacc::quantum::DWQMICompiler, xacc::quantum::OQASMCompiler, xacc::quantum::QuilCompiler

Public Functions

virtual std::shared_ptr<IR> compile(const std::string &src, std::shared_ptr<Accelerator> acc) = 0

This method is to be implemented by derived Compilers and is in charge of executing the compilation mechanism on the provided source string. Implementations also are given access to the Accelerator that this source code is intended for.

Return

ir Intermediate representation for provided source kernel code.

Parameters
  • src: The kernel source string.

  • acc: The Accelerator this code will be executed on

virtual std::shared_ptr<IR> compile(const std::string &src) = 0

This method is to be implemented by derived Compilers and is in charge of executing the compilation mechanism on the provided source string.

Return

Parameters
  • src:

virtual const std::string translate(const std::string &bufferVariable, std::shared_ptr<Function> function) = 0

This method is to be implemented by derived Compilers and is in charge of taking the provided Function IR and converting it to source code in this Compiler’s language.

Return

src The source code as a string

Parameters

virtual OptionPairs getOptions()

Return an empty options_description, this is for subclasses to implement.

virtual bool handleOptions(const std::map<std::string, std::string> &arg_map)

Given user-input command line options, perform some operation. Returns true if runtime should exit, false otherwise.

Return

exit True if exit, false otherwise

Parameters
  • map: The mapping of options to values

virtual ~Compiler()

The destructor