[PATCH] D151483: [LLVM-C] Add GetFunctionType Method

William Moses via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 12:07:58 PDT 2023


wsmoses created this revision.
wsmoses added reviewers: vchuravy, nikic, jdoerfert.
Herald added a reviewer: deadalnix.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
wsmoses requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds a get functiontype from function method to the LLVM C ABI. This is required to support opaque pointers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151483

Files:
  llvm/include/llvm-c/Core.h
  llvm/lib/IR/Core.cpp


Index: llvm/lib/IR/Core.cpp
===================================================================
--- llvm/lib/IR/Core.cpp
+++ llvm/lib/IR/Core.cpp
@@ -2410,6 +2410,10 @@
     static_cast<CallingConv::ID>(CC));
 }
 
+LLVMTypeRef LLVMGetFunctionType(LLVMValueRef Fn) {
+  return wrap(unwrap<Function>(Fn)->getFunctionType());
+}
+
 const char *LLVMGetGC(LLVMValueRef Fn) {
   Function *F = unwrap<Function>(Fn);
   return F->hasGC()? F->getGC().c_str() : nullptr;
Index: llvm/include/llvm-c/Core.h
===================================================================
--- llvm/include/llvm-c/Core.h
+++ llvm/include/llvm-c/Core.h
@@ -2631,6 +2631,13 @@
  */
 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
 
+/**
+ * Obtain the function type of a function.
+ *
+ * @see llvm::Function::getFunctionType()
+ */
+unsigned LLVMGetFunctionType(LLVMValueRef Fn);
+
 /**
  * Obtain the name of the garbage collector to use during code
  * generation.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151483.525743.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/43ca9cfe/attachment.bin>


More information about the llvm-commits mailing list