Commit 96510b15 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updates to mac driver

parent 1ddc0cc6
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ def main(argv=None):
    compiler = '@CLANG_EXECUTABLE@'
    verbose=False
    baseLibs = ['-rdynamic', '-Wl,-rpath,@XACC_ROOT@/lib', '-Wl,-rpath,@LLVM_INSTALL_PREFIX@/lib', '-Wl,-rpath,@CMAKE_INSTALL_PREFIX@/clang-plugins',
                            '-L', '@GCC_STDCXX_PATH@','-lstdc++', '-stdlib=libstdc++', '-L', '@XACC_ROOT@/lib', '-lxacc', '-lCppMicroServices', '-lxacc-quantum-gate', '-lxacc-pauli', '-lxacc-fermion', 
                            '-L', '@XACC_ROOT@/lib', '-lxacc', '-lCppMicroServices', '-lxacc-quantum-gate', '-lxacc-pauli', '-lxacc-fermion', 
                            '-L', '@CMAKE_INSTALL_PREFIX@/lib', '-lqcor', '-lqrt', '-lqcor-hybrid', '-lqcor-jit', '-lqcor-quasimo',
                            '-lpthread']
    baseIncludes = ['-I', '@XACC_ROOT@/include/xacc', '-I', '@CMAKE_INSTALL_PREFIX@/include/qcor', '-I', '@XACC_ROOT@/include/quantum/gate', '-I', '@XACC_ROOT@/include/eigen']
@@ -284,15 +284,39 @@ def main(argv=None):
    if '@QCOR_APPEND_PLUGIN_PATH@':
        sys.argv += ['-D__internal__qcor__compile__plugin__path=\"@QCOR_APPEND_PLUGIN_PATH@\"']
        
    # Get the filename we are compiling or the object file
    filename = ''
    fileType = ''
    for arg in sys.argv[1:]:
        if os.path.isfile(arg) and mimetypes.guess_type(arg)[0] is not None:
            filename = arg
            fileType = mimetypes.guess_type(filename)[0]
            if fileType == 'text/x-c':
            if fileType == 'text/x-c++src':
                break
        if os.path.isfile(arg) and os.path.splitext(arg)[1] == '.qasm':
            fileType = 'openqasm'
            filename = arg
        
    if fileType == 'openqasm':
        # Convert to MLIR and then to LLVM QIR
        base_name = os.path.splitext(filename)[0]
        ll_file_name = base_name + '.ll'
        bc_file_name = base_name + '.bc'
        object_file_name = base_name+'.o'
        extra_args = []
        if '-no-entrypoint' in sys.argv[1:]:
            sys.argv.remove('-no-entrypoint')
            extra_args.append('-no-entrypoint')
        result = subprocess.run(['@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool', filename] + extra_args, check=True)
        llvm_bin_path = str(pathlib.Path(compiler).parent)
        result = subprocess.run([llvm_bin_path+'/llvm-as', ll_file_name, '-o', bc_file_name ], check=True)
        result = subprocess.run([llvm_bin_path+'/llc', '-filetype=obj', bc_file_name ], check=True)
        if '-no-entrypoint' in extra_args:
            exit(0)

        sys.argv.remove(filename)
        sys.argv.append(base_name+'.o')
        fileType = None
        filename = None                

    # If it is a C++ file
    if fileType == 'text/x-c':
+0 −2
Original line number Diff line number Diff line
@@ -312,8 +312,6 @@ def main(argv=None):
        fileType = None
        filename = None


    # exit(0)           
    # If it is a C++ file
    if fileType == 'text/x-c++src':
        fileIdx = sys.argv[1:].index(filename)