skip to content
==> src/link.h <==
1/* The commands of the cluster-float-mode PTX link: llvm-link, opt, llc. */
2#ifndef MESH_PTX_LINK_H
3#define MESH_PTX_LINK_H
4
5#include <stdbool.h>
6#include <stddef.h>
7
8typedef struct {
9    const char *const *inputs; /* LLVM bitcode (or IR) files */
10    size_t ninputs;
11    const char *const *exports; /* symbols kept public; NULL: mesh_main, MESH_RT_ABI */
12    size_t nexports;
13    const char *output; /* the .ptx */
14    const char *cpu;    /* sm_NN */
15    int opt;            /* 0..3 */
16    bool debug;         /* keep debug info */
17    const char *llvm_link, *opt_tool, *llc; /* the tools */
18} mesh_ptx_link;
19
20/* The three commands, each a NULL-terminated argv the caller frees with
21 * mesh_ptx_link_free_argv; they use <output without .ptx>.o, .optimized.o and
22 * .symbols.txt beside the output, as the Rust linker script. */
23char **mesh_ptx_link_argv_link(const mesh_ptx_link *l);
24char **mesh_ptx_link_argv_opt(const mesh_ptx_link *l);
25char **mesh_ptx_link_argv_llc(const mesh_ptx_link *l);
26void mesh_ptx_link_free_argv(char **argv);
27/* The symbols file's text: one exported symbol a line. Caller frees. */
28char *mesh_ptx_link_symbols(const mesh_ptx_link *l);
29/* "<output without .ptx>" + suffix. Caller frees. */
30char *mesh_ptx_link_side(const mesh_ptx_link *l, const char *suffix);
31/* An LLVM tool: $env if set, else name on PATH, else name-21 .. name-15 on
32 * PATH, else the newest /usr/lib/llvm-N/bin/name. NULL when none exists. Caller frees. */
33char *mesh_ptx_link_find_tool(const char *name, const char *env);
34/* true for sm_NN, sm_NNN, with an optional a / f (MESH_PTX_ARCH's rule). */
35bool mesh_ptx_link_valid_arch(const char *arch);
36
37#endif