[PATCH] D153185: [C API]: Add getters for inline assembly template string, constraints, and flags

Benji Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 16:55:52 PDT 2023


Benjins created this revision.
Benjins added reviewers: deadalnix, bogner.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Benjins requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This change adds support for accessing information about inline assembly calls through the C API, enough to be able to round-trip the information. This partially addresses https://github.com/llvm/llvm-project/issues/42037 which points out gaps in the C API

Getters for each of the parameters to LLVMGetInlineAsm/InlineAsm::get have been added, such that the C API now has enough surface to clone inline assembly calls

NB: LLVMGetInlineAsm has been changed to accept a const char* for its assembly and constraint strings. This isn't strictly needed, but does make using the API a bit easier to use since the results of LLVMGetInlineAsmAsmString/LLVMGetInlineAsmConstraintString can be passed to LLVMGetInlineAsm without having to make an explicit mutable copy. As far as I understand, changing this from char* to const char* shouldn't break existing users, but if it's something we want to avoid I can leave it

This API currently only returns the raw constraint string via LLVMGetInlineAsmConstraintString: it may be prudent to also expose the parsed constraints via InlineAsm::ParseConstraints, but I wasn't sure how that should look like. This at least exposes the information for clients

This is my first patch sent to LLVM, so if there's anything I've missed please let me know


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153185

Files:
  llvm/include/llvm-c/Core.h
  llvm/lib/IR/Core.cpp
  llvm/test/Bindings/llvm-c/echo.ll
  llvm/tools/llvm-c-test/echo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153185.532332.patch
Type: text/x-patch
Size: 7555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/5c5d4dad/attachment.bin>


More information about the llvm-commits mailing list