Commit 3dbd5344 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

making pragmahandlers and externalsemasources plugins in the xacc framework....


making pragmahandlers and externalsemasources plugins in the xacc framework. added submit method to api that takes a pre-created buffer

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 01b75235
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -12,9 +12,11 @@ add_library(${LIBRARY_NAME} SHARED ${SRC})
target_include_directories(${LIBRARY_NAME}
                            PUBLIC .
                                ${XACC_INCLUDE_DIRS}
                                ${CLANG_INCLUDE_DIRS}
                                ${LLVM_INCLUDE_DIRS}
                                )

target_link_libraries(${LIBRARY_NAME} PUBLIC xacc)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc qcor-ast-plugin ${CLANG_LIBS} ${LLVM_LIBS})

set(_bundle_name qcor_compiler)
set_target_properties(${LIBRARY_NAME}
+5 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "clang/FuzzyParsingExternalSemaSource.hpp"
#include "clang/QCORExternalSemaSource.hpp"

#include <memory>
#include <set>
@@ -23,6 +25,9 @@ public:

    auto s = std::make_shared<qcor::QCORCompiler>();
    context.RegisterService<xacc::Compiler>(s);

    auto es = std::make_shared<qcor::compiler::FuzzyParsingExternalSemaSource>();
    context.RegisterService<qcor::compiler::QCORExternalSemaSource>(es);
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -32,3 +32,4 @@ configure_file(qcor-driver.in.cpp
add_executable(qcor-driver ${CMAKE_BINARY_DIR}/compiler/clang/qcor-driver.cpp)
target_link_libraries(qcor-driver PRIVATE qcor-ast-plugin qcor xacc)
install(PROGRAMS ${CMAKE_BINARY_DIR}/compiler/clang/qcor-driver DESTINATION bin)
install (FILES QCORPragmaHandler.hpp DESTINATION include/qcor)
 No newline at end of file
+4 −7
Original line number Diff line number Diff line
@@ -10,9 +10,7 @@ using namespace clang;
namespace qcor {
namespace compiler {

FuzzyParsingExternalSemaSource::FuzzyParsingExternalSemaSource(
    ASTContext &context)
    : m_Context(context) {
void FuzzyParsingExternalSemaSource::initialize() {
  auto irProvider = xacc::getService<xacc::IRProvider>("quantum");
  validInstructions = irProvider->getInstructions();
  validInstructions.push_back("CX");
@@ -20,7 +18,6 @@ FuzzyParsingExternalSemaSource::FuzzyParsingExternalSemaSource(
  for (auto& irg : irgens) {
      validInstructions.push_back(irg);
  }

}

bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R,
@@ -39,10 +36,10 @@ bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R,
    IdentifierInfo *II = Name.getAsIdentifierInfo();
    SourceLocation Loc = R.getNameLoc();
    auto fdecl = FunctionDecl::Create(
        m_Context, R.getSema().getFunctionLevelDeclContext(), Loc, Loc, Name,
        m_Context.DependentTy, 0, SC_None);
        *m_Context, R.getSema().getFunctionLevelDeclContext(), Loc, Loc, Name,
        m_Context->DependentTy, 0, SC_None);

    Stmt *S = new (m_Context) NullStmt(Stmt::EmptyShell());
    Stmt *S = new (*m_Context) NullStmt(Stmt::EmptyShell());

    fdecl->setBody(S);

+5 −6
Original line number Diff line number Diff line
#ifndef COMPILER_FUZZYPARSINGEXTERNALSEMASOURCE_HPP_
#define COMPILER_FUZZYPARSINGEXTERNALSEMASOURCE_HPP_

#include "clang/AST/ASTContext.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/Sema/Lookup.h"
#include "QCORExternalSemaSource.hpp"

using namespace clang;

namespace qcor {
namespace compiler {
class FuzzyParsingExternalSemaSource : public ExternalSemaSource {
class FuzzyParsingExternalSemaSource : public QCORExternalSemaSource {
private:
  ASTContext &m_Context;
  std::vector<std::string> validInstructions;

public:
  FuzzyParsingExternalSemaSource(ASTContext &context);
  FuzzyParsingExternalSemaSource() = default;
  void initialize() override;

  bool LookupUnqualified(clang::LookupResult &R, clang::Scope *S) override;
};
} // namespace compiler
Loading