Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

omp-maptype-info.nvim

A Neovim plugin for decoding OpenMP target offload map-type bitmasks from LLVM IR.

When working with LLVM IR generated by OpenMP offloading, map-type arguments appear as opaque integer constants (e.g., 0xff00ffffff9e0140). This plugin lets you place your cursor on such a number and instantly see which OMP_MAP_* flags are set.

It also provides general-purpose hex/decimal conversion for any number under the cursor.

Features

  • Map-type decoding — break down a map-type integer into its constituent OMP_MAP_* flags, including MEMBER_OF extraction
  • Hex/Dec conversion — convert the word under the cursor between hex and decimal, with full unsigned 64-bit support
  • Dynamic flag definitions — fetch the latest OpenMPOffloadMappingFlags enum directly from the LLVM source on GitHub
  • Fork support — point at any LLVM fork (e.g., one with vendor-specific extensions) to pick up additional flags
  • Private repo support — uses gh CLI for authenticated GitHub access when available, falls back to curl for public repos

Requirements

  • Neovim >= 0.10
  • nui.nvim (for popup display)
  • gh (optional, for fetching from private repos)

Installation

Using lazy.nvim:

{
  "abhinavgaba/omp-maptype-info.nvim",

  dependencies = { "MunifTanjim/nui.nvim" },
  keys = { "<leader>oh", "<leader>od", "<leader>om", "<leader>oc" },
  cmd = { "OmpMapTypeSync" },
  opts = {},
}

The plugin is lazy-loaded until one of the keymaps is pressed or :OmpMapTypeSync is called. On first trigger, the plugin loads and setup() registers the actual keymaps and commands.

Configuration

Default configuration:

require("omp_maptype_info").setup({
  keymaps = {
    hex = "<leader>oh",        -- show word under cursor in hex
    dec = "<leader>od",        -- show word under cursor in decimal
    maptype = "<leader>om",    -- decode word as OpenMP map-type bitmask
    cheatsheet = "<leader>oc", -- show all known map-type flags
  },
  source = {
    repo = "llvm/llvm-project",
    branch = "main",
    path = "llvm/include/llvm/Frontend/OpenMP/OMPConstants.h",
  },
})

Set any keymap to false to disable it.

Overriding keymaps

To use different keymaps, pass them via opts. When using lazy.nvim, make sure the keys field matches so lazy-loading triggers correctly:

{
  "abhinavgaba/omp-maptype-info.nvim",

  dependencies = { "MunifTanjim/nui.nvim" },
  keys = { "<leader>xh", "<leader>xd", "<leader>xm", "<leader>xc" },
  cmd = { "OmpMapTypeSync" },
  opts = {
    keymaps = {
      hex = "<leader>xh",
      dec = "<leader>xd",
      maptype = "<leader>xm",
      cheatsheet = "<leader>xc",
    },
  },
}

Using a custom LLVM fork

If you work with an LLVM fork that defines additional map-type flags, point source at your fork:

opts = {
  source = {
    repo = "my-org/llvm-project",
    branch = "my-branch",
  },
}

Then run :OmpMapTypeSync to fetch and cache the flags from that repo.

Commands

Command Description
:OmpMapTypeSync Fetch the latest map-type flags from the configured source and cache them locally
:OmpMapTypeSync {url} Fetch from a specific GitHub URL instead of the configured source

The URL should be a GitHub blob URL pointing to a file that contains lines matching the pattern OMP_MAP_<NAME> = 0x<hex> (such as LLVM's OMPConstants.h):

:OmpMapTypeSync https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h

Usage

Place your cursor on a number in a buffer (decimal or hex) and press:

Keymap Action
<leader>oh Show the number in hexadecimal
<leader>od Show the number in decimal
<leader>om Decode as an OpenMP map-type bitmask
<leader>oc Show cheat-sheet of all known map-type flags

A popup appears at the cursor showing the result. Move the cursor to dismiss it.

Example

With the cursor on 0xff00ffffff9e0140, pressing <leader>om shows:

╭─────────MAP_TYPE:0xff00ffffff9e0140──────────╮
│0xff00000000000000 = MEMBER_OF(65280 = 0xff00)│
│              0x40 = RETURN_PARAM             │
│             0x100 = LITERAL                  │
│    0x100000000000 = NON_CONTIG               │
│    0xefffff9e0000 = UNKNOWN                  │
╰──────────────────────────────────────────────╯

Pressing <leader>oc shows the cheat-sheet of all known flags:

╭───────────OpenMP Map-Type Cheat-Sheet────────────╮
│               0x1 = TO           (1)             │
│               0x2 = FROM         (2)             │
│               0x4 = ALWAYS       (4)             │
│               0x8 = DELETE       (8)             │
│              0x10 = PTR_AND_OBJ  (16)            │
│              0x20 = TARGET_PARAM (32)            │
│              0x40 = RETURN_PARAM (64)            │
│              0x80 = PRIVATE      (128)           │
│             0x100 = LITERAL      (256)           │
│             0x200 = IMPLICIT     (512)           │
│             0x400 = CLOSE        (1024)          │
│            0x1000 = PRESENT      (4096)          │
│            0x2000 = OMPX_HOLD    (8192)          │
│            0x4000 = ATTACH       (16384)         │
│            0x8000 = FB_NULLIFY   (32768)         │
│    0x100000000000 = NON_CONTIG   (17592186044416)│
│0xffff000000000000 = MEMBER_OF    (bits 48-63)    │
╰──────────────────────────────────────────────────╯

How it works

The plugin uses LuaJIT FFI to call the system C library's strtoull/sprintf directly for unsigned 64-bit string-to-hex/decimal conversion. This avoids Lua/Vimscript's signed 64-bit integer limitations without requiring any compiled C code.

Map-type flag definitions are loaded from a local cache (populated by :OmpMapTypeSync) or from a built-in default set matching upstream LLVM. The decoder splits off the top 16 bits for MEMBER_OF extraction, then tests remaining bits against each known flag.

License

MIT

About

Neovim plugin for decoding OpenMP target offload map-type bitmasks from LLVM IR

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages